-
Notifications
You must be signed in to change notification settings - Fork 42
Docs ‐ Response
papamarfo edited this page Jul 30, 2026
·
2 revisions
Various USSD providers have different APIs to communicate with them. Responses provider you with the flexibility to write your application without worry about the response as part of the core of your application.
Laravel USSD ships Response implementations for common gateways, so most applications don't need to write their own:
| Class | Shape |
|---|---|
Speso\Ussd\Responses\AfricasTalkingResponse |
Plain text, prefixed CON /END
|
Speso\Ussd\Responses\NsanoResponse |
{"USSDResp": {"action": "input"|"prompt", "menus": "", "title": ...}} |
Speso\Ussd\Responses\NaloResponse |
{"USERID", "MSISDN", "USERDATA", "MSG", "MSGTYPE"} |
Speso\Ussd\Responses\MoolreResponse |
{"message", "reply"} |
Speso\Ussd\Responses\ArkeselResponse |
{"sessionID", "userID", "msisdn", "message", "continueSession"} |
<?php
use Speso\Ussd\Responses\AfricasTalkingResponse;
use Speso\Ussd\Ussd;
Ussd::build($context)
->useInitialState(WelcomeState::class)
->useResponse(AfricasTalkingResponse::class)
->run();ArkeselResponse echoes back a userID, which Arkesel issues per USSD subscription rather than per request — set it via config('services.arkesel.ussd_user_id').
Targeting a gateway that isn't listed above? Scaffold your own:
php artisan ussd:response YourGatewayResponse<?php
namespace App\Ussd\Responses;
use Speso\Ussd\Contracts\Response;
class YourGatewayResponse implements Response
{
public function respond(string $message, bool $terminating): mixed
{
return [
'message' => $message,
'terminating' => $terminating,
];
}
}