Navigation & Terminal Menus
Navigation & Terminal Menus
This guide covers navigation patterns in USSD applications, including global navigation actions, back/home keys, terminal menus, and navigation history management.
Navigation Overview
USSD applications navigate between menus based on user input. The platform supports several navigation patterns:
| Pattern | Description |
|---|---|
| Option selection | User selects a numbered option to navigate |
| Wildcard input | User enters free-form text matched by "*" option |
| Global actions | Consistent Back/Home keys across all menus |
| Terminal menus | End session after displaying content |
| Data-driven pagination | Navigate pages in data-driven menus |
Global Navigation Actions
Configure consistent Back and Home keys that work from any menu using the global_actions block.
Configuration
Code
Properties
| Property | Type | Description |
|---|---|---|
back_key | string | Key that returns to previous menu in history |
home_key | string | Key that returns to application's start menu |
Behavior
- Back key: Navigates to the previous menu in the navigation history stack
- Home key: Navigates directly to the
startmenu, clearing history - Global actions are checked before menu-specific options
- When at the start menu, the back key has no effect (nowhere to go)
Example
Code
Don't define explicit Back options (e.g., option "0" { goto = "Previous" }) when using global_actions. The global back key handles navigation automatically.
Navigation History
The platform maintains a navigation history stack for each session. This enables proper Back navigation through multiple menu levels.
How History Works
- When navigating from Menu A to Menu B, Menu A is pushed onto the history stack
- When user presses the back key, the platform pops Menu A and navigates to it
- Home navigation clears the entire history stack
Example Flow
Code
Terminal Menus
Terminal menus end the USSD session after displaying content. They're used for confirmations, results, and goodbye messages.
Implicit Terminal (No Options)
A menu with no options automatically ends the session:
Code
Explicit Terminal Flag
Use terminal = true to end the session even when options are defined:
Code
When to Use Terminal Menus
| Use Case | Recommendation |
|---|---|
| Success confirmation | terminal = true |
| Error with no retry | terminal = true |
| Goodbye message | Empty options (implicit) |
| Search results | Empty options (implicit) |
| Session timeout | terminal = true |
Example: Terminal Results
Code
Back Navigation Without Global Actions
If you don't use global_actions, define explicit Back options in each menu:
Code
Menu-to-menu back references are safe because they require user input. The platform only prevents action-to-action cycles that could cause infinite loops.
Data-Driven Menu Navigation
Data-driven menus have built-in pagination using reserved keys:
| Key | Action |
|---|---|
| 1-N | Select item N from current page |
| 8 | Previous page |
| 9 | Next page |
Code
Rendered Output (Page 1 of 3)
Code
When using data-driven menus, avoid using keys 8 and 9 for other options as they're reserved for pagination.
Combining Patterns
You can combine global actions with data-driven menus:
Code
Best Practices
-
Use
global_actionsfor consistency — Configure Back/Home once instead of in every menu. -
Don't duplicate Back options — If using
global_actions, omit explicit Back options to avoid confusion. -
Terminal menus for final states — Use terminal menus for success/error messages where no further action is needed.
-
Test navigation paths — Verify Back navigation works through multiple levels.
-
Consider Home for deep menus — For apps with many levels, provide a Home key for quick restart.
-
Document navigation — Include navigation instructions in menu text when needed:
Code