Action

Action blocks are where 3rd-party, coding logic or special operations can be added to your bot.

JSON builder step.

You can use the JSON builder in combination with the Web channel to receive window events on your webpage. These events will contain the data as configured in your JSON builder action.

To do this, you'll need to tick the Send config to parent window option. It will allow you to send data to the place where the widget is in a structured way.

Here's an example:

  1. Configure your JSON builder action to send a language key, with a variable retrieved from the session.

  2. Set the toggle Send config to parent window on.

JSON builder with a language field.

Add an Action block by dragging and dropping it to your flow.

Action tab.

Action blocks allow you to integrate third-party services, implement custom coding logic, or perform specialized operations within your bot

Example of an Action block.

Coding steps

Code

The code editor allows developers to quickly build custom logic on top of the bot by writing their own Javascript code blocks. Typically, the code editor is used to perform requests to external systems, or to do operations with variables.

You can find more information about the code editor here:

Code editor

There are also two tutorials in which we show you how the code editor can be used:

[Example] Retrieving data from Airtable (GET)[Example] Sending data to Airtable (POST)

API

The API step is an integration where you integrate Chatlayer with your back end or third party services in order to share data gathered in the conversation with the bot, or enrich the bot with data captured.

API step.

JSON builder

If your bot is published on the Webhook API channel, you can use the JSON Builder action to send messages to the conversation that don't need to result in an actual message to the user. Typically, it's used to send information about the user or bot conversation to the website the bot is published on.

Website window events

You can use the JSON builder action in combination with the webwidget channel to receive window events on your webpage. These events will contain the data as configured in your JSON builder action.

Here's an example: Configure your JSON builder action to send a language key, with a variable retrieved from the session, and the "Send config to parent window" toggled on.

JSON builder action with a language field

Your widget will trigger an event for that configuration to its parent window as a MessageEvent. The MessageEvent will contain a `data` field which contains the stringified result of the JSON builder configuration. Here's an example on how to listen to these events:

// Chatlayer JSON Builder Event Handler
window.addEventListener('message', (event) => {
    const data = event && event.data && JSON.parse(event.data) || {}
    const { type, payload } = data
    if (type !== 'CL_DISPATCH_EVENT') return;
    console.log('Chatlayer language received: ' + payload.language)
})

Pausing steps

Pause bot

The Pause bot step will pause your bot when it reaches this block.

Pause bot step.

Delay

Sometimes you need a slight delay between bot messages, either to create a natural pause or to make an API call without the bot being silent. These pauses can significantly enhance the user experience.

Delay step.

You can for example use Delay before a Close conversation step.

Variables steps

Clear session

Use a Clear session step to clear out variables that you don't need anymore.

Clear out variables inside a Clear session step.

Set variables

The Set variable step facilitates the creation, formatting, and assignment of values to variables.

Add an operation inside your variable value.

Operations allow you to perform calculations like addition, subtraction, multiplication, division, or finding the remainder of two numbers.

For a comprehensive list of available operations such as addition (+), multiplication (*), division (/), and more, please refer to the detailed documentation provided here.

Go to variable bot dialog

Use the Go to variable bot dialog step to navigate to a block that is contained inside a variable.

Go to variable bot dialog step.

Email steps

Send mail

The Send mail step sends an email with a message.

Send mail step.

Mail report

The Mail report step sends 2 things:

  • an email with a message

  • the bot conversation at the time where the message was send

All you need to do is to define the email title, recipients and body. Here you can also use variables between curly braces if you need to.

Mail report step.

Voicebot steps

Start recording the call

From the Start recording the call step, the conversation with your voicebot is being recorded.

Start recording the call step.

Stop recording the call

From the Stop recording the call step, the conversation with your voicebot will stop being recorded.

Stop recording the call step.

Forward call

You can forward the call from your voicebot to a phone number by using the Forward call step.

Forward call step.

The phone number should contain a country code but no leading zeros, only the '+' sign. For example: 0800 55 800 becomes +32 800 55 80

After setting up the phone number you wish to forward your call to, the bot will automatically hang up upon transferring. To reach the bot again, hang up the call and call a second time.

Other steps

Track event

A Track event step can be used you to create custom dashboards and funnels to improve the analysis of your bot performance.

Track event step.

iFrame

An iFrame is a custom element that can be used to show a different web page in the chat conversation. It can also be used to communicate with the parent window using the postMessage API.

Have a look at this basic example:

<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		</head>
		<body>
			<button onClick="window.parent.postMessage(JSON.stringify({target:'CL_API',type:'SEND_MESSAGE', payload:{text: 'You clicked the button'} }),'*')">
         SEND_MESSAGE
        </button>
		</body>
</html>

If this block of code is hosted and embedded within our iframe plugin, it will send the user a chat message when they click the button.

The postMessage API can also handle UPDATE_SESSION and GO_TO_DIALOGSTATE events.

Get time

The Get time step is about guiding your flow based on the current moment in time. You can reuse those time variables inside your conversation.

When you provide a timezone offset, the result of the plugin will contain time properties that are equal to UTC+offset.

Get time variables

If you do not provide a time zone offset, the current moment in time will be saved under the Target variable field. In our example, this variable will be called time. In this case, your Target variable will be accessible with the following variables:

  • (target).utc.year

  • (target).utc.month

  • (target).utc.dayOfMonth

  • (target).utc.dayOfWeek

  • (target).utc.hours

  • (target).utc.minutes

  • (target).utc.seconds

  • (target).utc.ISO

By default, the plugin result will contain properties related to the UTC time.

When you provide a timezone offset, the result will also contain time properties that are equal to UTC+<OFFSET>.

  • (target).offset.year

  • (target).offset.month

  • (target).offset.dayOfMonth

  • (target).offset.dayOfWeek

  • (target).offset.hours

  • (target).offset.minutes

  • (target).offset.seconds

  • (target).offset.ISO

Inside a message, you can use those variables for instance like this:

Today is {time.offset.dayOfMonth}/{time.offset.month}/{time.offset.year}

Get time step.
Route your flow depending on the time

Close conversation

The bot will close the active conversation when the Close conversation step is reached.

This means that the session variables are erased.

Close conversations step.
Example: Delay before Close conversation

You can for example use the Close conversation step together with a Delay step. This is useful in a situation where the user is not responding for a few minutes and you want to close the conversation from there.

Table operation

The Table operation step is about using your built-in Chatlayer Tables.

Table operation step

Knowledge base AI

The Knowledge base AI step is about using your Knowledge base AI.

Knowledge base AI step.

Send to offload provider

A user that reaches this action will be offloaded to a human customer support agent.

Depending on your selected offloading provider, additional configuration may be required.

Last updated

Was this helpful?