USSD MENU

✅ 1. Callback URL Setup

Know that:

You must provide a callback URL that will be called when a USSD session hits your shortcode. Your server must respond with a JSON response to guide the USSD flow.

✅ 2. Request Parameters

The following GET parameters will be sent to their URL:


ParameterDescriptionExample
session_idUnique ID for the USSD session123456789
session_msisdnUser's phone number (MSISDN)2348000000000
session_msgThe latest user input (menu response)1
session_operationRequest operation type: begin or continuebegin or continue
session_fromUSSD shortcodeexample *123#or #123*45#
session_typeUsually 1, expect user reply1
session_mnoMobile network operatorMTN, AIRTEL, 9MOBILE, GLO

✅ 3. Expected JSON Response

Your callback URL must return a JSON response like this:

{
"session_operation": "continue",
"session_type": 1,
"session_id": "123456789",
"session_msg": "Welcome to MyService\n1. Airtime\n2. Data"
}


FieldDescription
session_operationcontinue (expecting more input) or end (exit)
session_typeUsually 1 for continue, 4 for end
session_idSame session ID received
session_msgText shown to the user

✅ 4. Sample Flow

User Dials: *123#

Provider Sends to Client:

Client Responds with:

{
"session_operation": "continue",
"session_type": 1,
"session_id": "123456",
"session_msg": "Welcome to My Service\n1. Airtime\n2. Data"
}


User Enters: 1

  1. Provider Sends to Client:

  2. ✅ 5. Final Response to End Session

  3. {
    "session_operation": "end",
    "session_type": 4,
    "session_id": "123456",
    "session_msg": "Thank you for using MyService."
    }
    ✅ 6. Important Notes

    Use only GET requests.
    
    Always return valid JSON with proper headers.
    
    Timeout limit: 5–10 seconds.
    
    URL must be HTTPS.
    

    ✅ 7. Sample PHP Response Code

  4. header('Content-Type: application/json');
    echo json_encode([
    'session_operation' => 'continue',
    'session_type' => 1,
    'session_id' => $_GET['session_id'],
    'session_msg' => "Welcome to MyService\n1. Airtime\n2. Data"
    ]);

SAMPLE: Create ussd.php in your root and save this