Docs »

Bots »

Interactions »

Chat Interactions

The goal of a chat interaction is to determine a human’s intent (what they want to accomplish), from their utterances in natural language, and then to fulfill those requests in a helpful way.

Chat interaction points

Interactions are triggered from interaction points, which provide context (e.g. who, what, when, where) and establish the initial intent of a conversation.

For instance:

  • In Cerb, an interaction could trigger when a worker clicks “Remind me” on a specific record. Through the interaction, the bot would know who the worker is and which record they’re looking at, so it could simply ask when and how they would like to be reminded. The bot also has access to the worker’s record, so it wouldn’t need to ask about contact details like an email address or mobile number.

  • On a website, an interaction could trigger when a visitor clicks a “Sign up” link. The bot would guide the visitor through the steps of creating and verifying a new account.

  • In an email, a personalized link could start an interaction with survey. The conversation would adapt based on a respondent’s answers, and results could be saved to custom fields or custom records.

Chat interaction lifecycle

There are three events in the lifecycle of an interaction: get interactions, handle interaction, and conversations.

Get interactions

When a user is near an interaction point, the Get interactions event runs on every bot to fetch the list of available interactions for that point. This allows the user to choose an interaction directly, rather than having to precisely answer the open-ended question, “How can I help?”.

Because this process is implemented using bot behaviors, decisions can filter the possible interactions situationally based on the current worker, the target record, the time of day, etc.

For instance, certain interactions may only be available for open ticket records in the Sales group.

These options are generally displayed in an interactions menu on a record’s card or profile.

Handle interaction

When a specific interaction from the above list is selected, Cerb runs its associated handler.

A single handler behavior can be shared by multiple interactions. The common convention is to have one “Get interactions” and one “Handle interaction” behavior per bot.

The handler takes parameters from the interaction and passes them to a conversational behavior.

If an interaction is being started from a link in email, a signature may be verified to detect tampering, etc.

With customer-facing bots on websites, the get interactions step is skipped and the handler is called directly when a link or button is clicked.

Conversation

The conversational behavior then starts, with its initial state provided by the interaction. It prompts the user for input, does something useful, and provides output. This process may repeat as many times as needed to achieve the desired outcome.

For instance, imagine a troubleshooter that has a user try multiple solutions to uncover a root cause. In some situations it may find a common issue right away, and in others it may need to ask many follow-up questions to identify an uncommon issue.

Conversational behaviors aren’t inherently associated with a specific record type. That means you can reuse the same conversational behavior for multiple interactions and adapt it to different record types.

Consider a “Remind me” interaction. With interactions, you can register a single “Remind me about this” interaction on every record at the same time (with interaction point record:*), which uses the same handler, and the same conversational behavior.

The ability to use wildcards like this is another reason why the handler step exists, rather than directly linking interactions to conversational behaviors.

Responses

In interactions, bots convey information to users through chat messages. Each message can include a delay to emulate typing in a human-to-human conversation.

The simplest messages are just text. However, messages can also be richly formatted with Markdown or HTML to include links, styles, colors, lists, images, tables, etc.

Messages can also include scripts with interactive functionality.

Prompts

Chat bots use prompts to ask for user input. The conversational behavior will pause at that point until the user responds.

Rather than always requiring the user to type an answer, prompts make it easier for them to respond in the right format.

There are different types of prompts available depending on the information your bot needs to collect:

The response to a prompt can determine the next step in a bot’s behavior.

Formatting

You can format a user’s response to a prompt before validating or saving it.

The formatting template has access to all of Cerb’s scripting functionality.

Format a number

This formats a number, removing thousands separators and decimal places:



{{message|replace({',':''})|number_format(0, '.', '')}}


Format a date as a Unix timestamp



{{message|date('U')}}


Validation

You can validate a user’s response to a prompt by running multiple tests using bot scripting.

Any output from this template is considered to be an error that will be displayed to the user.

Cerb will take care of automatically repeating your prompt for you until valid input is given.

When the template returns no output, the response is considered to be valid and Cerb will save it to your placeholder.

Validate a date



{% set ts = message|date('U') %}
{% if 0 == ts %}
Please enter a valid date. For instance, "Friday noon".
{% elseif ts < 'now'|date('U') %}
Please enter a date in the future.
{% endif %}


Validate a number within a range



{% if message is not numeric %}
Please enter a valid number.
{% elseif message < 1 or message > 100 %}
The number must be between 1 and 100.
{% endif %}


Validate an email address



{% set email = message|parse_emails|first %}
{% if message is empty %}
Please enter an email address.
{% elseif email.host == 'localhost' %}
Please enter a valid email address.
{% endif %}


Buttons

When prompting with buttons, the user selects from a list of pre-defined responses.

In a conversational bot behavior, add the Prompt With » Buttons action.

Options

A list of pre-defined responses that will be displayed as buttons. One response per line. You can use scripting to build the list.

Colors

You can configure a color gradient to automatically style the buttons.

For instance, a satisfaction survey asking about sentiment could start green (positive) and end red (negative).

Custom CSS style

You can include custom CSS rules to further style the buttons. In the example above, we’re configuring a fixed width and allowing the buttons to display inline (i.e. adjacent rather than stacked).

Save to a placeholder

Name a placeholder where a copy of the user’s response will be saved. You can then later refer to this answer when making decisions or giving responses.

Chooser

When prompting with a chooser, the user selects one or more existing records using a helper popup or autocomplete text box.

Chooser prompts are currently only available on worker-based chat interactions.

In a conversational bot behavior, add the Prompt With » Chooser action.

Type

The record type to be selected.

Query

The default query to pre-filter records in the chooser popup.

Selection

If selecting a single record, the popup will automatically close after the first selection. Otherwise the user is able to select multiple records.

Autocomplete

If enabled, an autocomplete textbox will be added to the chooser button. This is useful if the user may already know what they want to select, as they can bypass the chooser popup.

Save to a placeholder

Name a placeholder where a copy of the user’s response will be saved. You can then later refer to this answer when making decisions or giving responses.

If the name your placeholder ends with _id then all of the placeholders for the selected record will be available.

For instance, a placeholder like prompt_worker_id will be able to use prompt_worker__label and prompt_worker_first_name.

Date Input

When prompting with a date input, the user can enter an absolute (2020-12-31 08:00) or relative (tomorrow 8am) date. A calendar popup can also be used to select a specific date.

If a relative date is given, it is automatically converted into an absolute date before sending. This ensures that the bot is always receiving the response to a date prompt in a consistent format.

In a conversational bot behavior, add the Prompt With » Date Input action.

Placeholder

The instructive text shown in the date prompt before any text is entered.

Default

The default text in the date prompt.

Save to a placeholder

Name a placeholder where a copy of the user’s response will be saved. You can then later refer to this answer when making decisions or giving responses.

File Upload

When prompting with a file upload, the user selects a file from their computer to share with the bot.

File upload prompts are currently only available in worker-based chat interactions.

In a conversational bot behavior, add the Prompt With » File Upload action.

Save to a placeholder

Name a placeholder where a copy of the user’s response will be saved. You can then later refer to this answer when making decisions or giving responses.

If the name your placeholder ends with _id then all of the placeholders for the uploaded file will be available.

For instance, a placeholder like prompt_file_id will be able to use prompt_file_size and prompt_file_mime_type.

Images

When prompting with images, the user selects from a pre-defined list of responses represented by images.

In a conversational bot behavior, add the Prompt With » Images action.

Images

Click the (+) icon to add a new image-based response. Each response includes an image and a label.

  • Image: Upload or generate an image.
  • Label: Add a label for this image. This is the text response that will be sent when this image is selected.

Save to a placeholder

Name a placeholder where a copy of the user’s response will be saved. You can then later refer to this answer when making decisions or giving responses.

Text Input

When prompting with text input, the user is free to type anything.

In a conversational bot behavior, add the Prompt With » Text Input action.

Placeholders

The instructive text shown in the prompt before any text is entered.

Default

The default text in the prompt.

Options

Whether the text prompt accepts a single line of input, or multiple lines.

Save to a placeholder

Name a placeholder where a copy of the user’s response will be saved. You can then later refer to this answer when making decisions or giving responses.

Wait

The wait prompt is useful when your bot needs to run a potentially long-running action (e.g. remote API call) and you’d like to warn the user first.

Rather than leaving the working watching a loading spinner without an explanation, the bot can say “Let me check on that for you. This may take a moment…“, wait, and then run the action.

In a conversational bot behavior, add the Prompt With » Wait action.

You don’t need to configure anything for a wait prompt.

However, you can get creative with the responses that precede it. Using the random() function will add some variety to your bot.

Proactive chat interactions

Typically, workers initiate chat interactions. Proactive interactions allow a bot to start an interaction with a worker instead.

For instance, a bot may need to notify a worker about a monitoring alert, or show the current day’s schedule when a worker first logs in.

When a worker has at least one new proactive notification, an animated red message icon appears on the floating bot interaction button in the lower right of the browser. Opening the interaction menu will always first display any pending interactions.

Proactive interactions can be given an expiration date, and if a worker doesn’t start the interaction before that date then it will be dismissed automatically.

You can create proactive interactions with the Schedule proactive interaction action in any bot behavior.

Resources

You can import the Prompt Bot package with working examples.