Logique et données
Reuse answers, send callers down different paths, show live data from your systems, and reuse other apps.
La documentation est rédigée en anglais. Les pages traduites arrivent.
Saved answers (variables)
Every answer saved with Save the answer as, every value saved from an API, and a few built-in values can be used anywhere text is typed: screen text, API addresses, request bodies and conditions.
| Write | Becomes |
|---|---|
{{amount}} | The answer saved as amount, e.g. 50 |
{{MobileNumber}} | The number that dialled, as the network sent it, e.g. 233241234567 |
{{SessionId}} | The session’s unique id, handy for matching payments |
{{Network}} | The caller’s network, as your aggregator names it |
{{MobileNumber}} is always the caller's own number. To act on a different number, ask for it with Ask a Question, save it under a name of your own such as recipientNumber, and use that name. A step cannot save under MobileNumber or SessionId: the builder shows a message under the field and will not deploy until the name changes.
{{amount}}. In Smart Router conditions, write the plain name: amount > 100.Smart Router
Sends the caller down different paths depending on a value, without showing them anything. For example: balances over GHS 100 go to one screen, everything else to another.
Add a Smart Router
Click Smart Router in the toolbox and connect the previous screen to it.Build a condition
Open its Branches section. Each branch is a rule: pick the saved answer, the comparison and the value, for examplebalance, is more than,100. Add a rule adds another to the same branch, and you choose whether All of these are true or Any of these is true. Add branch adds another way out.Connect each branch
Each branch gets its own dot on the router. Drag each one to the screen it should lead to.Connect ELSE
The router always has an ELSE dot, for every caller no branch matched. Connect it, usually to a friendly closing screen. Check flow reports a router with nothing on ELSE, and the app will not deploy.
| Operator | Example | True when |
|---|---|---|
== / != | network == MTN | equal / not equal |
> < >= <= | amount >= 10 | comparing numbers |
contains | name contains Mensah | the text includes it |
startsWith / endsWith | phone startsWith 024 | the text begins / ends with it |
is empty / is not empty | token is empty | the answer was never saved, or is blank |
AND / OR | age >= 18 AND status == active | both / either are true |
- Write branches so that only one can be true for any caller. When two are true, the one whose connection you drew first is taken, which is easy to lose track of.
- As text, a condition reads name, operator, value, with spaces between:
name contains Mensah. Quotes around the value are optional. - Text comparisons ignore upper and lower case.
- AND and OR can be mixed. AND is worked out first, so
tier == gold AND balance > 0 OR role == staffmeans gold with a balance, or staff. A mixed condition is edited as text; the rule builder shows conditions that use only one of the two. - A comparison about an answer that was never saved is false,
!=included, so that caller leaves by ELSE. Useis emptyto test for a missing value.
Send Data
Calls your system (any web API) in the middle of a session, for example to look up a balance or register a customer, and saves values from the reply for later screens. The caller sees nothing while it runs.
Add Send Data and open its settings
Click Send Data in the toolbox, then open the Request section.Enter the address
Choose the method (GET to fetch, POST to send; your API's documentation says which) and type the address. You can put saved answers in it:API URLhttps://api.example.com/customers/{{MobileNumber}}/balanceAdd a body (POST, PUT or PATCH)
Type the JSON to send. Saved answers work here too:Request body{ "phone": "{{MobileNumber}}", "amount": "{{amount}}" }Add headers if your API needs them
For example anAuthorizationheader with your API key.Save values from the reply
Under Save From Response, press Add and pair a path in the reply with a name. If your API answers:thenYour API's reply{ "data": { "balance": 125.50, "name": "Ama" } }$.data.balance→balancelets a later screen say:Hi Ama, your balance is GHS 125.50.
When the call fails
Send Data has a second dot, FAIL. A caller takes it when your API cannot be reached, answers with an error, or takes longer than 2 seconds. Connect it to a "Please try again later" screen.
When your API is slow
If an answer can take longer than 2 seconds, open the Timeout section and turn on Let a slow call finish while the caller waits, then set Give up after (seconds), from 3 to 25. After 2 seconds the caller sees the step's text with 1. Check again while the call carries on. The request is sent once. If their session drops, dialling again within 5 minutes brings them back to the same place. Past the limit, the caller takes the FAIL route.
For safety, Send Data only calls public internet addresses, never private or local network addresses.
Sub-flow
Runs another of your published apps inside this one, then comes back. Build a common piece once, such as registration, and reuse it in several apps.
Publish the app you want to reuse
Only published apps can be used as sub-flows.Add a Sub-flow screen
Click Sub-flow in the toolbox, open it, and choose the app under App to run.Pass values in and out (optional)
Inputs passed in copies values into the sub-flow; Outputs passed back copies answers back out, for example the sub-flow'snameinto this app'smemberName.Connect what comes next
When the sub-flow reaches an End Session screen, the caller continues at the screen connected after the Sub-flow screen and never sees that end screen. Connect FAIL too: a caller takes it when the app cannot be run, for example because it was unpublished.
Example
A "Member hub" app runs your "Register" app as a sub-flow, then greets the caller by the name they just entered:
Back in the hub. Welcome, Akua Mensah!