Handling errors

Chatbots are software. And software can break sometimes – you can have a wrong API call in a JSON block, Google integration can fail, or something else can happen unexpectedly. Handling errors properly is extremely important so that they do not break your end-user chatbot experiences.

You may have already noticed an “ERROR” button in some of the chatbot building blocks in Activechat. This button is for error handling.

Example of error handling in the chatbot
Example of error handling in the chatbot

This picture shows an example of error handling. If something goes wrong when the JSON block is executed, the “ERROR” button will get control and a TEXT block will be triggered. It will display an error message to your bot user, offering an option to click the button to retry the action. Please note that this “Retry” button is connected back to the JSON block so that it will be triggered again when a user clicks the button.

You can definitely build a more complex error handling, maybe even create specific skills for each of your critical conversation blocks like JSON, Google integrations or complex data processing. It’s absolutely up to you – as a conversation designer.

To help you get some insights on what exactly went wrong, there is a system variable $_last_error. It will always contain a textual description of the last error that happened in the chatbot conversation with that specific user. You can display it to the user with a TEXT block, or send error notification to one of your bot admins (either on Messenger, with SMS or in e-mail).

Pre-defined _error skill

If there’s nothing connected to the ERROR exit, and something goes wrong when a block is executed, Activechat will trigger an _error system event. By default, it will launch the “_error” skill that is present in every chatbot template. This skill will display a generic notification to your chatbot user (with a button to restart the bot) and will send an email notification to your account email.

Please note that these email notifications are limited to one per hour. This is done to prevent your mailbox from going crazy if something is broken in the bot and there are thousands of users experiencing the error simultaneously.

Default _error skill that is triggered for unhandled errors in the chatbot
Default _error skill that is triggered for unhandled errors in the chatbot

Notice the use of $_last_error system variable. When this skill is triggered, your users will see something like this:

Default error message from the _error skill
Default error message from the _error skill

And in your mailbox, you will find an email like this:

Error notification email from Activechat
An error notification email from Activechat

Notice that it contains a reference to the skill and block that caused the error. Use this information to debug your conversation and prevent this from happening in the future.

You’re absolutely free to customize the “_error” skill to suit your conversation style, or even remove it completely. Just notice that if there’s nothing in your _error skill, and no blocks are connected to the “ERROR” exits in your conversation, then on any error your chatbot will just silently fail, leaving your end-users disappointed.

Design your conversations wisely, focus on handling errors properly and have a great bot building experience!

Was this article helpful to you? Yes 3 No 1

How can we help?