Action
Action blocks are where 3rd-party, coding logic or special operations can be added to your bot.
Last updated
Action blocks are where 3rd-party, coding logic or special operations can be added to your bot.
Last updated
From 1st October 2024, all Chatlayer customers will be migrated to the new web widget, Web V2. To learn more about the differences between V1 and V2, check this page. For a technical deep dive, check this page.
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:
Configure your JSON builder action to send a language key, with a variable retrieved from the session.
Set the toggle Send config to parent window on.
Add an Action block by dragging and dropping it to your flow.
Action blocks allow you to integrate third-party services, implement custom coding logic, or perform specialized operations within your bot
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 editorThere are also two tutorials in which we show you how the code editor can be used:
Retrieving data from Airtable (GET)Sending data to Airtable (POST)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.
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.
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.
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:
The Pause bot step will pause your bot when it reaches this block.
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.
You can for example use Delay before a Close conversation step.
Use a Clear session step to clear out variables that you don't need anymore.
The Set variable step facilitates the creation, formatting, and assignment of values to variables.
We've recently introduced a new expression syntax. To explore the full range of expressions and functions available, check out the comprehensive documentation provided here.
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.
Use the Go to variable bot dialog step to navigate to a block that is contained inside a variable.
The Send mail step sends an email with a message.
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.
From the Start recording the call step, the conversation with your voicebot is being recorded.
From the Stop recording the call step, the conversation with your voicebot will stop being recorded.
You can forward the call from your voicebot to a phone number by using the 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.
A Track event step can be used you to create custom dashboards and funnels to improve the analysis of your bot performance.
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:
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.
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
.
The bot will close the active conversation when the Close conversation step is reached.
This means that the session variables are erased.
Close conversation is now available on the Web channel, Voice channel, and Sinch Conversation API channel.
The Table operation step is about using your built-in Chatlayer Tables.
The Knowledge base AI step is about using your Knowledge base AI.
A user that reaches this action will be offloaded to a human customer support agent.
To be able to see this step in your bot, you will need to configure an offload provider.
Depending on your selected offloading provider, additional configuration may be required.