CallContext and Values
CallContext is the call argument that operations, lookups, identify() functions,
writers, and transfer functions receive: one request of the call. Values is the
values argument of prepare(): the operation’s fields as the model gave them.
CallContext properties
data
The call’s record as it came with the request.
account
The account as identify()’s load function returned it, or the account id when
there’s no load.
account_id
The identified account’s id, or "".
call_id
The platform’s id for the call.
medium
"voice" or "chat": the service’s medium, or the one found on the call’s first
request. "" when neither says.
state
Your own state for the call, such as a game’s hand or results a caller may pick from.
Kept in global_data between requests.
write_key
While a write runs, a key unique to that write in the call, for idempotent backends.
raw_data
The request’s data as the platform sent it.
service
The Operations service handling the request.
CallContext methods
Each returns the CallContext, so calls chain.
act
act(result) adds the platform actions of a FunctionResult to
this tool’s result, after everything else it does, such as hanging up or starting a
recording. The FunctionResult’s text isn’t used.
show
show(event) sends an event to the caller’s screen (a SWML user event) with this
tool’s result.
go
go(step) moves to a step when this tool’s result goes back: a phase declared with
phase(), or main. It applies from lookups, changes with confirm = False,
apply(), and identify(). A change that’s read back always waits in the confirm
step.
Values
Fields are attributes: values.order_id. A field that wasn’t given, or came as null,
an empty string, or "not said", is None. values.get(name, default=None) returns
the field’s value or default, and values.args holds the arguments as they came.