This video walks you through two powerful ways to make your chatbot dynamic. First, you will learn how to set up a webhook to send bot messages to your server and receive a response. Then you will see how inline code works to retrieve responses directly from an API. Both methods allow your chatbot to go beyond static replies and deliver real time, data driven responses to your users.
In this video we'll demonstrate how to use inline code and webhooks, both of which can trigger messages. A webhook is utilized when you want to send a bot message to your server and receive a response. Conversely, inline code primarily retrieves responses from the API.
Let's start with how to use a webhook. To do this, click on the intent you wish to trigger with the webhook. Add the training phrase, then navigate to Bot Says, enable Dynamic Message and click on the webhook. Now create a webhook. As you can see, I've already set up a webhook complete with a name and URL. To finish, click Save and then Train Bot.
For this demonstration I've used Beeceptor. It's important that your webhook has a POST method and that the response body generates an array.
Now let's test the bot. The response you see here is coming from the webhook. You can see both the request and response bodies. The format for these will be provided in the document linked in the description.
Now let's move on to using inline code. To do this, click on the intent you wish to use with the inline code. Add the training phrase, then navigate to Bot Says, enable Dynamic Message and click on inline code. Now create an inline code. I've already written a simple inline code to trigger an API and retrieve the total value. The total value is extracted from the API response and sent in the callback function.
Now let's close the bot and click Train, then Train Bot. Let's test the bot again. As you can see, the bot successfully retrieves the account value from the API via the inline code.
The documentation for both inline code and webhook usage will be linked in the description. Thank you.