-
Notifications
You must be signed in to change notification settings - Fork 7
Looping Menus
Looping menus are USSD screens that should be shown severally depending on a condition. Let's assume we have a USSD flow that goes through these steps :-
- [SCREEN 1] Select Register Clients
- [SCREEN 2] How many clients would you like to register?
- [SCREEN 3] Enter Client's First Name and Last Name
Our condition in this case is the number of clients we would like to register. If we register 1 client, there will be no need to repeat/loop SCREEN 3. If we register 2 clients we will need to repeat/loop SCREEN 3 two times
Here is how the ussd_menus config looks like
$ussdMenus = [
"home_screen_one" => [
"title" => "Welcome to InstantUssd",
"menu_items" => [
[
"next_screen" => "screen_two",
"description" => "Register Clients"
]
]
],
"screen_two" => [
"title" => "How many clients would you like to register?",
"body" => "(Enter a value between 1 and 5)",
// --- BEGIN LOOPING KEY
// target_loopset sets the number of loops required for register_client
// loopset
"target_loopset" => "register_client",
// --- END LOOPING KEY
"menu_items" => [
[
"next_screen" => "screen_three"
]
]
],
"screen_three" => [
"title" => "Enter Client's First Name and Last Name",
// --- BEGIN LOOPING KEYS
"loopset_name" => "register_client",
// is_loop_end - indicates it's the last screen of a given loopset
"is_loop_end" => true,
// loop_start - may point to itself or to a previous menu_id in history with the
// same loopset_name
"loop_start" => "screen_three",
// --- END LO0PING KEYS
"menu_items" => [
[
// it will automatically exit
"next_screen" => ""
]
]
]
];String. It points to a looping set of menus. This screen will be used to set the number of loops that will have to be completed by the looping set referenced.
String. It's a unique name given to a looping set of menus.
Boolean, default false. It is a status key that indicates whether the current screen is the last one within its looping set.
MUST be provided if is_loop_end == true. It points back to the first menu within its looping set.