Skip to content

Configuration

David Bwire edited this page Aug 22, 2017 · 28 revisions

InstantUssd configuration should all be accessible from instant_ussd key.

Top-level Keys

/* iussd.config.php */

use Bitmarshals\InstantUssd;

return [
    "instant_ussd" => [
        'db' => [
        // database config options
        ],
        'ussd_menus' => [
        // ussd menu config options
        ],

        // Pointer to UssdEventManager that aggregates all USSD event listeners.
        // You'll have to replace it's value with your custom UssdEventManager
        // class that extends Bitmarshals\InstantUssd\UssdEventManager
        "ussd_event_manager" => InstantUssd\UssdEventManager::class,

        "service_manager" => [
        // Internal InstantUssd config options
        // You don't need to change anything here
        ],
    ]
];

Ussd Menus

This is a top-level key that is an array of menu_id's. Each menu_id is an array defination of a ussd screen.

use Bitmarshals\InstantUssd\UssdMenuConfig;

$ussdMenus = [
    // it's an array of menu_id's representing a USSD screen
    // home_instant_ussd below is referred to as a menu_id
    "home_instant_ussd" => [
        "title" => "Welcome to InstantUssd", // optional string
        "body" => "", // optional string
        "footer" => "Questions? Call +254712***559", // optional string
        "valid_keys" => [1], // optional array of ints, default []
        "error_message" => "", // optional string
        "is_skippable" => false, // optional boolean, default false
        "menu_items_ranking_type" => UssdMenuConfig::RANKING_TYPE_PREDETERMINED, // optional string
        "loopset_name" => "", // optional string
        "target_loopset" => "", // optional string
        "is_loop_end" => false, // optional boolean, default false
        "loop_start" => "", // optional string
        // menu_items - optional array of arrays, default []
        "menu_items" => [
            [
                // empty next_screen will force an exit
                "next_screen" => "_exit_", // optional string, default _exit_
                "description" => "Register", // optional string
                "is_reset_previous_position" => false // optional boolean, default false
            ]
        ]
    ]
];

menu_id

It MUST be provided and SHOULD be unique.

title, body, footer

Optional. Used to generate menu title, menu body and menu footer respectively. You SHOULD provide at least one.

valid_keys

Optional. It's an array of ints that you expect the user to send back as a response.

error_message

Optional. It's a default error message that should be sent to the user in case s/he sends in an invalid response

is_skippable

Optional. It's a quick way to indicate that a screen is optional and thus should be skipped.

menu_items_ranking_type

Optional. It's currently not used.

menu_items

It's an array representing the different menu items.

  • next_screen Optional, default _exit_. Indicates the screen to display if the user selects this option
  • description Optional. It's the text that's displayed against a given key
  • is_reset_previous_position Optional, default false. Indicates whether next_screen had already been served before.

Looping Keys loopset_name, target_loopset, is_loop_end and loop_start

See Looping Menus

⇐ Installation | Looping Menus ⇒