NewDash Dots are hereMini apps in Dash, with payments built inLearn more

Products · Developer guides

Variables

Read earlier answers, session details, your server's data and stored values with $(...), and know what happens when a value is missing.

Write $(scope.key) in a label or another supported field, and Monime fills in the value when the page is shown:

JSON
{
  "type": "display",
  "label": "Thanks $(page.enter_name.value). We sent SLE $(page.enter_amount.value) to Fatmata Kamara."
}

$(...) can also hold an expression, such as a comparison or a function call. See Expressions.

Scopes

ScopeSyntaxHolds
Page$(page.ID.value), $(page.ID.label)The subscriber's answer on an earlier page
Session$(session.KEY)Details of the current USSD session
Data$(data.KEY)Data your server sent with this page
Session context$(sc.KEY)A value you saved earlier in this session
Recurring context$(rc.KEY)A value you saved for this subscriber in an earlier session

Every value arrives as text, including numbers and true or false.

Page

$(page.ID.value) is what the subscriber entered or chose on the page with that ID. For a menu, it is the chosen item's value.

$(page.ID.label) is the page's label. For a menu, it is the chosen item's label.

JSON
{
  "id": "select_district",
  "component": {
    "type": "menu",
    "label": "Select your district",
    "items": [
      { "label": "Bo", "value": "bo" },
      { "label": "Kenema", "value": "kenema" }
    ]
  }
}

If the subscriber picks Kenema, $(page.select_district.value) is kenema and $(page.select_district.label) is Kenema.

A page's answer only exists once the subscriber has been through that page. Pages passed over by next_page or options.skip have no answer. See Missing Values.

Session

KeyValueExample
idThe session's ID
network_nameThe mobile network"Africell"
network_provider_nameThe network's mobile money service"Afrimoney"
subscriber_msisdnThe subscriber's phone number"+23276123456"
subscriber_idSame value as subscriber_msisdn inside a flow"+23276123456"

Your exchange endpoint receives a hashed subscriber ID and a masked phone number instead. If you save the subscriber's number or send it in dataExport, it is masked unless it came from a get_subscriber_msisdn page. See Subscriber Identification.

Data

data holds what your server sent in pageData when it chose this page through an exchange or a dynamic page. Some templates also set data; each template's page lists what it sets.

JSON
{
  "id": "show_balance",
  "component": {
    "type": "display",
    "label": "Your balance is $(data.currency) $(data.balance)."
  }
}

If your server replied with "pageData": { "currency": "SLE", "balance": "1250" }, the subscriber sees Your balance is SLE 1250.

Data belongs to the page your server sent the subscriber to. Later pages can't read it. To keep a value, save it with a mutation on that page:

JSON
{
  "on_done": {
    "action": "next",
    "session_context": { "mutations": { "balance": "$(data.balance)" } }
  }
}

A menu can take its whole list of items from data: "items": "$(data.accounts)", where accounts is a list of { "label": "…", "value": "…" }.

Session Context and Recurring Context

$(sc.KEY) reads a value saved with on_done.session_context.mutations earlier in the same session. $(rc.KEY) reads a value saved with on_done.recurring_context.mutations, in this session or an earlier one.

JSON
{
  "id": "welcome_back",
  "component": {
    "type": "display",
    "label": "Welcome back, $(rc.display_name)."
  }
}

How long each store keeps values, and its limits, are in Context Stores.

Missing Values

ReferenceIn a labelInside an expression
rc.KEY or sc.KEY that was never saved, or was clearedEmpty textnull
page.ID.value or page.ID.label for a page the subscriber hasn't been throughThe flow stops with an errorEmpty text
data.KEY that your server didn't send for this pageThe flow stops with an errorThe flow stops with an error
session.KEY that doesn't existThe flow stops with an errorThe flow stops with an error

When a label refers to a page ID that doesn't exist, or to an unknown session key, the error shows up as soon as a session starts, before the first page.

Give unset context values a default with ??: $(rc.display_name ?? 'friend'). A ?? default does not apply to empty text, so it doesn't help with a page the subscriber skipped.

Where $(...) Works

FieldWhat you can write
label on any pageText mixed with any number of $(...)
options.terminal_messageText mixed with any number of $(...)
Menu item label and valueText mixed with any number of $(...)
Menu item hidetrue, false, or one $(...). The item is hidden when it gives true.
Menu itemsOne $(data.KEY) that holds the whole list
options.skip, options.terminaltrue, false, or one $(...). Takes effect when it gives true.
on_done.next_pageA page ID, or one $(...) that gives a page ID
on_done.session_context.mutations, on_done.recurring_context.mutationsA plain value, or a $(...). The result is saved.
on_done.dataExportA plain value, or a $(...). The result is sent as text.
collect_payment amount and multiplierA number, or one plain reference to page, data, rc or sc. No expressions.
collect_payment reference, receipt_name and metadata valuesText mixed with any number of $(...)
on_done.url, dynamic page urlNot supported. Use a fixed URL.

For other template fields, see each template's page. The collect_payment label also takes the {{amount}} placeholder; see collect_payment.

Editor Autocomplete

In the flow editor, type $( to get suggestions: the scopes, then your page IDs, session keys, and the sc and rc keys your mutations save. New pages and keys show up as soon as you add them.

Keep reading