Inbox commands¶
Example:
Add a "Thank you" message as suggestion to the operator input bar.
emit "$inbox", Inbox.suggest("Thank you"), to: :operator
Show a toast message to the user.
emit "$inbox", Inbox.toast("This person is not a paying member"), to: :operator
Note: This currently only works in the Inbox, not the studio inbox.
Inbox.form(opts)¶
Presents a form to the operator.
Options:
:schema: The JSON schema for the form. The root of the schema must be an object (that is, a schema with%{"type" => "object"}first).:ui_schema: The UI schema to accompany the schema.:data: Prefilled data for the form.:event: The event (string) that will be called when the form has been filled. Required. Theevent.payloadwill be a map with anoperatorkey containing the operator that submitted the form, and aformkey with the validated data.:cancel_event: The event (string) that will be called when the form has been cancelled. Optional. Theevent.payloadwill be a map with anoperatorkey containing the operator that submitted the form, and aformkey with the unfinished, non-validated data.
Inbox.set_input(text)¶
Set the input bar of the operator to the given text.
Examples:
emit "$inbox", Inbox.set_input("Did you turn the device off and back on?"), to: :operator
Inbox.suggest(message)¶
Suggest messages to the operator.
Examples:
emit "$inbox", Inbox.suggest("Did you turn the device off and back on?"), to: :operator
emit "$inbox", Inbox.suggest([
"First suggestion",
"Second suggestion"
]), to: :operator
Inbox.toast(text, opts \\ [])¶
Display a toast message to the operator.
The toast may either be a simple string, or a translations map where the key is the language ('en', 'nl', etc), and the value is the toast.
The message itself is rendered as markdown, so it may contain links.
Options:
:timeout: Automatically remove the toast after this many seconds. Defaults to no timeout.:intent: Either:normal,:error, or:warning. Defaults to:normal.:buttons: A list of commands that must also be present in theui_commands.
Example:
emit "$inbox", Inbox.toast("Hello operator, this is bot"), to: :operator
# With translations, based on the operator's language:
emit "$inbox", Inbox.toast(%{"en" => "Hello operator", "nl" => "Hallo operator"}), to: :operator