Overview
The ussd language syntax is declarative and intuitive. we’ve broken it into 5 easy parts to help us grasp it.
- Actions
- Variables
- Control flows
- Effects
- Modules
Actions
Section titled “Actions”Actions are used to define things that display on the users screen. They’re mostly defined ending with a colon.
We currently have
entry:, finish:, prompt:, list:, <number>:
<number>:is used for defining options.
example
1: Send money
2: Check balance
Variables
Section titled “Variables”A variable can be used to store some information throughout a session.
Example of a variable that takes users name and age then prints them at the end of the flow
entry: Profile updatorprompt: What's should we call you? -> name finish: You're called {name}.As seen above, we kept the user’s name in a name variable and then used that variable in the final action.
Control flows
Section titled “Control flows”These are used to control the path of a flow based on the state of a variable. We currenly support just the if-else control flow
Example USSD application that has two branching flows based on whether you entered a value or not.
entry: Age picker prompt: What's your age? -> age if age finish: You're {age} years old. else finish: You didn't enter your age.Effects
Section titled “Effects”Effects allow us to call external logic or APIs. This is actually where your business logic lives outside the definition of your USSD flow but can then be called from the flow.
Example USSD application that allows a user in when they’re above the age of 18.
entry: Age picker prompt: What's your age? -> age @checkAge(age) -> isValid if isValid finish: Welcome to our service. else finish: You're too young to be hereModules
Section titled “Modules”Modules are used to make a piece of USSD flow reusable.
An example is to wrap the code for asking user information into a module that can be reused.