The AI Response block is used for generating responses to user input using AI. It can provide answers based on the information you have added to the Knowledge Base or from the AI’s pretrained data.

The AI uses natural language processing (NLP) to understand the user’s input and generate relevant responses.

What is the “Response Source”?

The Response Source determines where the AI will look for answers to user queries. You can choose from the following options:

  • Knowledge Base: The AI will search the data you’ve uploaded to the Knowledge Base for the relevant information and return the corresponding answer.
  • AI Model: The AI will use its pretrained data to generate a response based on the user’s query. This is ideal for a general-purpose AI that can answer a wide range of questions without limiting its responses to the data in the knowledge base.

Configurations for Knowledge Base Response Source

AI block knowledge base settings

When you select the “Knowledge Base” as the Response Source, you can configure the following settings:

  • Question: The user’s input or query that the AI will process to generate a response. You can use variables to make the question dynamic. For example, you can capture the user’s input using a Text input block and store it in a variable called user_input. Then, you can use this variable in the “Question” field to make the AI response dynamic.
  • Store response in variable: You can store the AI response in a variable to use it in other blocks.
  • Stream: When enabled, the AI response will be streamed to the user in real-time as it is generated. This provides a more interactive experience for the user.
    • When Stream is enabled, some features that require post-processing, such as “Not Found path” will be disabled.
  • Not Found path: The path to follow if the AI does not find a relevant answer in the Knowledge Base.
  • Model: The AI model to use for generating responses.
  • Language: The language in which the AI will respond to the user. If you set it to “Auto,” the AI will detect the language of the user’s input and respond in the same language.
    • If you want the AI to respond in a certain dialect or accent, you can specify it in Instructions section of the AI Configuration.
  • Temperature: The randomness of the AI’s responses. A higher temperature value will result in more diverse and creative responses, while a lower value will produce more accurate responses.

What does “Use global AI settings” mean?

When you set an option, such as the AI model, language, or temperature to “Use global AI settings”, the AI will use the settings defined in the AI Configuration menu in the sidebar. This allows you to define global settings that will be applied to all AI blocks in your bot.

Configurations for AI Model Response Source

When you set the Response Source to “AI Model”, you can configure the following settings:

  • Prompt: The message or query that the AI will use to generate a response. You can use variables to make the prompt dynamic.
  • Store response in variable: You can store the AI response in a variable to use it in other blocks.
  • Instructions: Additional instructions for the AI to follow when generating a response. For example, you can specify its personality, tone, or style, or provide specific context for the response.
  • Model: The AI model to use for generating responses.
  • Max Length: Maximum number of tokens to generate, shared between the prompt and the response. One token is roughly 4 characters.
  • Temperature: Randomness of the AI’s responses. A higher temperature value will result in more diverse and creative responses, while a lower value will produce more focused and deterministic responses.
  • Top P: Controls diversity via nucleus sampling: 0.5 means half of all likelihood-weighted options are considered.
  • Frequency Penalty: How much to penalize new tokens based on their existing frequency in the text so far. Decreases the model’s likelihood to repeat the same line verbatim.
  • Presence Penalty: How much to penalize new tokens based on whether they appear in the text so far. Increases the model’s likelihood to talk about new topics.

How to set up the AI block to respond from the knowledge base?

Here’s a high level overview of how the AI generates responses using the knowledge base:

  • The user inputs a question or query, which is saved in a variable of your choice.
  • The stored input is passed to the AI which uses natural language processing (NLP) to understand the user’s query and the context of the conversation.
  • The AI searches the knowledge base for relevant information.
  • The AI generates the response and displays it to the user.

To set up the AI block, follow these steps:

  1. Add a Text input block to the canvas. We’ll use this block to capture the user’s input and store it in a variable so it can be passed to the AI block.
Adding text input block to the builder
  1. Click on the Text block to open the editor. In the Store answer in variable field, enter a variable where the user’s input will be stored. In this example, we’ll create and use a variable called user_query.
Storing user input in a variable
  1. Next, drag and drop the AI Response block onto the canvas.
Setting up AI block for knowledge base response
  1. Connect the Text input block to the AI block by dragging the connector from the Text block to the AI block.
Connecting text input to AI block
  1. Click the AI Response block to open the editor. In the Question field, enter the variable where the user’s input is stored. In step 2, we used the user_query variable, so we’ll enter {user_query} in the Question field.
Setting up AI block for knowledge base response
  1. Set up the global AI settings by going to the AI Configuration in the sidebar. You can define settings such as the AI model, instructions, language, and business name.

  2. Lastly, set up the block connections accordingly. For example, a setup like below will allow the user to continually ask questions and receive responses from the AI.

Setting up AI block for knowledge base response