Modules
Build a USSD (Unstructured Supplementary Service Data) request/response cycle out
of Ussd.State modules.
A one-shot decision point that runs once, with no screen shown to the caller, and resolves to the next module in the flow.
The storage contract Ussd.Record (and therefore session state) is built on.
Default Ussd.Cache implementation: a supervised GenServer owning a public, named
ETS table.
Groups repeated Ussd.use_*/2 setup so it can be shared across controllers/entry
points instead of copy-pasted.
The per-request context for a USSD interaction: who is dialing in (uid), which
group/session the request belongs to (gid), what they typed (input), and any
extra values the caller wants states/actions to see (bag).
Additional behaviour required of a state declared with use Ussd.State, continue: true.
The three ways a session can behave across a dropped call / redial
Something that can look at the caller's raw input and say yes or no.
Matches when low <= input <= high (numeric-aware, so Between.new(1, 10) matches
"9" and "10" correctly instead of comparing them as strings).
Matches when the input equals expected (numeric-aware: "7" matches 7).
Always matches. Use as the last transition/2 in a state to give it a default route.
Matches when the input is greater than expected (numeric-aware).
Matches when the input is greater than or equal to expected (numeric-aware).
Matches when the input equals one of values (numeric-aware).
Matches when the input parses fully as an integer or float.
Matches when the input is exactly length characters long.
Matches when the input is less than expected (numeric-aware).
Matches when the input is less than or equal to expected (numeric-aware).
Matches when the input is outside [low, high] (numeric-aware).
Matches when the input does not equal expected (numeric-aware).
Matches when the input equals none of values (numeric-aware).
Matches when the input matches pattern, e.g. Regex.new(~r/^[0-9]{4}$/).
Turns an exception raised while running a flow into a message the caller sees, instead of a dead session.
Raised when a session is marked as initialized but its active state is missing from the record.
Raised when a Ussd.Context is built with an empty gid.
Raised when Ussd.use_configurator/2 is given a module that doesn't implement Ussd.Configurator.
Raised when continuing mode is :confirm but no valid continuing state (continue: true, with confirm/0) was given.
Raised when Ussd.use_continuing_state/4 is given something other than :start, :continue or :confirm.
Raised when Ussd.use_exception_handler/2 is given something that isn't a 1-arity function or a Ussd.ExceptionHandler module.
Raised when Ussd.use_initial_state/2 is given a module that isn't a Ussd.State.
Raised when Ussd.use_response/2 is given something that isn't a 2-arity function or a Ussd.Response module.
Raised when an Ussd.Action chain resolves to a module that isn't a Ussd.State.
Raised when a Ussd.State has no transition, back, paginate or terminate
clause that matches the caller's input.
Raised by Ussd.Record.set_encrypted/4 and get_encrypted/4 when no encryption key
is configured. Set config :ussd, :encryption_key, "..." (any length; it is hashed
down to an AES-256 key).
Raised by Ussd.Menu.trans/4 when no Gettext backend is configured.
Raised by Ussd.run/1 when no initial state was set via Ussd.use_initial_state/2.
Raised when a Ussd.Context is built with an empty uid.
A fluent builder for the text a Ussd.State renders back to the caller.
Mix into a state alongside a paginate/1 declaration to page a long listing
without hand-rolling the bookkeeping
Per-session storage, scoped to a Ussd.Context's uid/gid and backed by a
pluggable Ussd.Cache.
Shapes the engine's result into whatever your gateway expects. Wired in via
Ussd.use_response/2, either as a module implementing this behaviour or as a
3-arity function (context, message, terminating? -> term).
Formats a response for the Africa's Talking USSD gateway.
Formats a response for the Arkesel USSD gateway.
Formats a response for the Moolre USSD gateway.
Formats a response for the Nalo USSD gateway.
Formats a response for the Nsano USSD gateway.
Formats a response for the Speso USSD gateway.
A screen in a USSD flow.
A fluent helper for exercising a USSD flow end-to-end in ExUnit tests, mirroring a caller dialing in and replying screen by screen.
Splits long text into width-wide chunks for truncate/1.
Mix Tasks
Generates a new Ussd.Action module.
Generates a new Ussd.Configurator module.
Generates a new Ussd.Decision implementation.
Generates a new Ussd.ExceptionHandler module.
Generates a new Ussd.Response module.
Generates a new Ussd.State module.