For the complete documentation index, see llms.txt. This page is also available as Markdown.

Custom actions

A custom action is a button that you add to the Shomi chat of a call. When a user of the Enreach Contact desktop app presses it, Shomi runs a task in your Shomi Custom bot, for example to create a ticket in your helpdesk or a follow-up task in your CRM. The task returns a short message, which Shomi shows in the chat.

You build actions in the same Shomi Custom bot that post-processes the transcripts, see Shomi Custom.

How it works

  1. After a call is transcribed, Shomi runs the custom_transcript task in your Shomi Custom bot. There you offer one button per action with add_shomi_action.

  2. The user opens the call in Shomi and sees your buttons in the chat.

  3. When the user presses a button, Shomi runs the action task you chose in your Shomi Custom bot. The task gets the call's transcript.

  4. The task returns a status, a message and optionally a link. Shomi shows the message to the user.

Prerequisites

  • A Shomi Custom bot, ordered as described on the Shomi Custom page, with the REST API channel enabled.

  • Version 1.6.0 or later of the Shomi Custom skill. Update the Smart App if your bot runs an older version.

  • Knowledge of BubbleScript.

There is nothing to configure in Shomi itself: it shows the buttons that a call's transcript contains.

Build your first action

1. Declare the action task

An action is a task that is declared with group: "shomi_action". The label is the default text of the button.

The in and out schemas come with the Shomi Custom skill. You don't need rest_api: true.

2. Write what the action does

The task receives the request as _args and returns a result.

3. Offer the action as a button

In your custom_transcript task, call add_shomi_action once for every button. One task can back several buttons, for example with a different params map.

4. Publish the bot

5. Test it

Use the DialoX test runner. The Shomi Custom bot ships with tests/actions.test.b, which shows how to test both the buttons and the action tasks:

run_shomi_action is the task Shomi calls when a button is pressed, so this test runs the action the same way Shomi does.

Reference

add_shomi_action

Key
Description

task

The action task (required). It must be declared with group: "shomi_action", otherwise no button is added and a message is logged.

id

Unique per call. Defaults to the task name. Adding the same id again replaces the earlier button.

label

The button text: a string, or an $i18n map such as %{"$i18n" => true, "en" => "Create lead", "nl" => "Lead aanmaken"}. Defaults to the label of the declared task, then to the task name.

params

Any map. It comes back unchanged in _args.params when the button is pressed.

repeatable

true keeps the button after the action is done. By default the button is hidden once the action returned done.

What the action task receives

The task gets _args with these keys:

Key
Description

id

The id of the button.

task

The name of the action task.

params

The params you added to the button.

transcript

The transcript as the Shomi chat has it, including edits made by the user. It is also available as the transcript variable. See the data structure of the transcript.

locale

The language of the user, for example nl.

What the action task returns

Key
Description

status

done (the default), failed or unavailable. See below.

message

Shown to the user as is. Translate it yourself, using _args.locale.

url

Optional link to what the action created. Shomi adds it to the message as an "Open" link.

Status
What the user sees
The button

done

Your message, or "Done."

Hidden, unless the button is repeatable

failed

Your message, or a general apology

Stays, so the user can try again

unavailable

"This action is no longer available."

Hidden

An action that returns nothing counts as done. A bare return does not: it doesn't match the shomi_action_result schema and the user gets an error.

Calling another system

Most actions call an external system. This example creates a ticket in a helpdesk. It sends an external_id that is the same for a second press of the same button, so a helpdesk that honours it creates one ticket, and it returns failed when the helpdesk doesn't answer, so the user can try again.

The URL and the fields are placeholders for your own system. Keep the API key in an integration, see the developer documentation on integrations and get_access_token.

Good to know

  • Pressing twice. A user can press a button a second time before the first answer arrives. Make actions that create something idempotent, for example by keying them on transcript.conversation_uuid and _args.id, as above.

  • The full transcript. _args.transcript contains the call text (text, caller_text) and the audio_url, whatever the setting "Allow full transcript to be pushed to email and CRM" says. That setting is only checked by Shomi's own email and CRM pushes, not by your actions. An action that sends data to another system should check transcript.allow_push_full_transcript before it includes the call text:

  • Languages. Shomi shows the label in the language of the user and falls back to English. The message is not translated for you: use _args.locale.

  • Typing instead of pressing. A user can also type the label of a button. Capitals don't matter. A button that is done or unavailable can't be run this way either.

  • Choose distinctive labels. A button whose label is the same as one of Shomi's own buttons is skipped.

  • Number of buttons. There is no fixed limit. Every button takes room in the chat, so keep the list short.

  • Reserved names. The group shomi_action and the schemas shomi_action_request and shomi_action_result belong to the Shomi Custom skill. Don't define the schemas in your own schemas.yml: the import fails with "Duplicate schema definition".

How long a conversation stays open

Shomi talks to your Shomi Custom bot over the REST API. One conversation per call processes the transcript, and the actions of that call run in the same conversation. Since version 1.6.0 of the skill such a conversation is closed after 24 hours without activity. It used to be 5 minutes.

  • The conversation stays open in your inbox for up to a day after the call. Every button press starts the 24 hours again.

  • A press after the conversation closed opens a new conversation for the call. Shomi does that by itself.

  • Closing is not deleting: a closed conversation keeps its data.

  • Send the transcript to another system with the push_transcript webhook, or with a custom webhook task that custom_transcript performs. See How to integrate. An integration on the standard conversation_close webhook now receives the transcript up to a day after the call, because that webhook fires when the conversation closes.

  • The 24 hours apply to every conversation of the bot, including Studio previews. To use another value, define @timeout in the main script of your own bot.

Troubleshooting

What you see
Likely cause

The button doesn't appear

custom_transcript didn't add it, or the task isn't declared with group: "shomi_action" (a message is logged), or the Shomi custom add-on isn't ordered for that user.

The button doesn't do what you changed

The bot isn't published. Actions run in the published version.

"Sorry, that didn't work. Please try again later."

The action couldn't run or raised an error, for instance because it returned a bare return. Open the conversation of that call in the Inbox of your Shomi Custom bot.

"This action is no longer available."

The task isn't declared with group: "shomi_action" any more, or returned unavailable.

The button is gone after pressing

The action returned done. Add "repeatable" => true to keep it.

Was this helpful?