Using Buttons in an AI Workflow to Trigger the Knowledge Base
Use buttons to trigger Knowledge Base queries in Tiledesk flows.

In this tutorial, you will learn how to use buttons in an AI 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 AI Agent Flows
Ensure you have uploaded a Knowledge Base (URLs, text files, Sitemap) in the Knowledge Base section. 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 AI Agent 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 agent to stamp the answer.

4. Test the AI Agent Flow
Test the complete flow by interacting with the buttons and ensuring the appropriate knowledge base lookup and response is triggered.
Summary
By following this tutorial, you have successfully created an AI Agent 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 [email protected] 🧡
Last updated