USSD codes (Unstructured Supplementary Service Data codes) are short codes that allow users to interact with a telecom provider’s services without internet access, typically starting with and ending with # (e.g. 123#)[6]. To create your own USSD-based application, you need a backend server, connection to a USSD gateway (provided by a mobile operator), and logic to handle session-based requests from users[6].
Steps to make a USSD code and application:
- Design your menu: Plan the different screens and user options (e.g., main menu, sub-menus, input prompts). USSD applications are essentially state machines where the user’s response determines the next screen or action[1].
- Set up a backend service: Use a programming language (commonly PHP, Python, or Node.js) to create endpoints that respond to USSD gateway HTTP callbacks. Each USSD request includes a session identifier, user input, and more. The server logic must return responses in the format required by the mobile operator (often XML or plain text)[1].
- Connect to a USSD gateway: Register your desired USSD code (like *123#) with a mobile operator by following their technical and legal onboarding process. The gateway forwards user input to your endpoint and relays your responses back to the user in real time[6].
- Implement user input handling: At each menu level, process user responses (“1”, “2”, or custom input). Store session data as needed to track progress. For example, prompt for an amount and remember it for further actions like balance checking or transfers[1].
-
Example response (PHP):
<?php header('Content-Type: text/xml'); print '<?xml version="1.0" encoding="UTF-8"?>'; ?> <page version="2.0"> <div protocol="ussd"> <input navigationId="form" title="Enter Amount" name="amount" type="Number"/> </div> <navigation id="form" protocol="ussd"> <link pageId="transaction.php" ></link> </navigation> </page>This sample returns an input request for an amount, followed by navigation logic depending on user input[1].
- Test thoroughly: Use a USSD simulator provided by your operator or tools/platforms to validate the user experience and detect errors before going live[3].
- Popular use cases: Banks use USSD for balance checks and transfers, telecoms for subscription services, and businesses for surveys or customer feedback. Typical codes look like *123# or *99#, depending on the service[2][4].
Note: You must work with a mobile operator to deploy a public USSD code, as they control code allocation and the gateway. All data exchanges happen in real time and do not require mobile data or internet from the end user[6].