Using Buttons in a Chatbot Flow to Trigger Knowledge Base


In this tutorial, you will learn how to use buttons in a chatbot flow such that the button's title text passes through as values for the next block to be triggered. We will achieve this by assigning the button's text as a value corresponding to its title and a key that corresponds to the `lastUserText` attribute. This attribute is then used to trigger a knowledge base lookup using the "Ask Knowledge Base" action in the subsequent block.

1. Set Up Your Chatbot Flows

Ensure you have uploaded a Knowledge Base (URLs; text files; Sitemap) in the Chatbots section >> Knowledge Base: Manage Your Contents.
Design the initial block where the user will interact with buttons. Each button will represent a query or option that will trigger a specific response. You can include these buttons in your Welcome block where you can offer some FAQ examples.

2. Capture Button Text and Assign to lastUserText

Make sure that each button is connected to a block first by choosing the button type: go to block >> choose the respective block. Then click on the ‘Attributes’ section below and insert a) the ‘lastUserText’ as the Key and b) the button's title as the Value. This way the chatbot captures the button's text and assigns it to the `lastUserText` attribute.

3. Configure the Knowledge Base Lookup Block

Create a new block that will handle the knowledge base lookup based on the `lastUserText` value. Use the "Ask Knowledge Base" action to query the knowledge base. Then add the text reply with the classic ‘kb_reply’ that will allow the bot to stamp the answer.

4. Test the Chatbot Flow

Test the complete flow by interacting with the buttons and ensuring the appropriate knowledge base lookup and response is triggered.


By following this tutorial, you have successfully created a chatbot flow where button interactions trigger specific blocks based on the button's title text. This text is passed through using the `lastUserText` attribute and is utilized to query a knowledge base, providing users with relevant information based on their selections. This approach enhances user interaction by providing dynamic and contextually relevant responses.

Do not hesitate to get in touch and share your feedback with us at 🧡