Use a knowledge agent in a chatbot

|

View as Markdown

Add a knowledge agent to your chatbot using the Connect to AI agent element or the Agent connector element in the chatbot editor.

The agent handles end user questions by retrieving answers from connected knowledge sources.



Before you begin

Before you add the element, complete the following:



How it works

The chatbot and the knowledge agent handle each question as follows:

  1. The chatbot captures the end user's message in an attribute.
  2. The element passes the message to the knowledge agent.
  3. The knowledge agent generates a response based on the message, agent configuration, and connected knowledge sources.
  4. The chatbot receives the response and sends it to the end user.


Save the end user's message

Before the element can process a question, the chatbot must capture the end user's message in an attribute. Use one of the following options:

  • Use the predefined attribute lastReceivedTextMessage, which captures the last message that the end user sent.
  • Use the Save user response element to save the message in a standard attribute.


Add the Connect to AI agent element [#add-connect-to-ai-agent-element]

In the Build side panel, go to Infobip apps. Drag and drop the Connect to AI agent element to a dialog in your chatbot. You can select only one knowledge agent per element, but you can add multiple Connect to AI agent elements across dialogs.

The Connect to AI agent element has two tabs: Request and Response. Add the next elements to the SUCCESS and FAILURE branches so that the chatbot continues.

The following image shows the Connect to AI agent element in a chatbot:

Connect to AI agent element in the chatbot editor

Request tab [#request-tab-connect-to-ai-agent-element]

In the Request tab, under Define your request, complete the following fields:

FieldDescription
AI agentSelect the knowledge agent from the list.
VersionSelect the agent version to use.
User messageEnter the end user's message or insert the attribute that contains it. To insert a placeholder, select {}. The chatbot passes this value to the knowledge agent.
Agent context (optional)Enter additional context to pass to the agent. To insert a placeholder, select {}.

Response tab [#response-tab-connect-to-ai-agent-element]

In the Response tab, under Define your response, complete the following fields for each value that you want to save. To save more values, select Add output.

FieldDescription
Response fieldSelect the value to save: Response, HTTP Code, or Custom response body expression. For Custom response body expression, enter a JSONPath or JSONata expression in Response expression. Use $.content to extract the response from the agent.
Target attribute / variableSelect the attribute that stores the value.


Add the Agent connector element [#add-the-agent-connector-element]

Add the Agent connector element to a dialog in your chatbot. You can select only one knowledge agent per element, but you can add multiple Agent connector elements across dialogs.

The Agent connector element has three tabs: Request, Response, and Fallback.


Request tab [#request-tab-add-the-agent-connector-element]

In the Request tab, complete the following fields:

FieldDescription
AI agentSelect the knowledge agent from the list.
VersionSelect the agent version to use.
User messageDefine a value or select an attribute that contains the end user's message. The chatbot passes this value to the knowledge agent.
Agent context (optional)Select an attribute to pass as additional context to the agent. To create an attribute, see Create an attribute.

Create an attribute [#create-an-attribute-request-tab]

To create an attribute for the agent context, complete the following steps:

  1. In Agent context, select Create new attribute.
  2. Enter a Name for the attribute.
  3. Keep Type as JSON.
  4. (Optional) Enter a Default value.
  5. Select the Scope:
    • Chatbot: The attribute value persists across all dialogs in the chatbot.
    • Dialog: The attribute value resets when the conversation moves to a different dialog.
  6. (Optional) Select Available to agents to make the attribute visible to live agents in Inbox.
  7. (Optional) Select Sensitive data to hide the attribute value in Chatbots and Inbox.
  8. Select Save.

Response tab [#response-tab-add-the-agent-connector-element]

In the Response tab, complete the following fields:

FieldDescription
Response code (optional)Select an attribute to save the HTTP response code.
Response body attributesExtract values from the response body. Select Show response code JSON schema to view the response structure. Then, select Add attribute to map a JSON path to an attribute. Use $.content to extract the response from the agent.
TimeoutSet the maximum time to wait for a response before the fallback triggers. The minimum value is 1 second and the maximum value is 60 seconds.

Fallback tab [#fallback-tab-add-the-agent-connector-element]

In the Fallback tab, complete the following fields:

FieldDescription
Fallback actionSelect the action to take when the fallback triggers. Go to dialog routes the end user to a different dialog. Connect to agent transfers the conversation to a live agent in Inbox.
DialogIf you selected Go to dialog, select the dialog to route to.
Fallback message (optional)Enter a message to send to the end user when the fallback triggers.
Link previewEnable to show a preview for links in the fallback message.
Use also for API failuresEnable to apply the fallback for API failures in addition to timeout failures.


Send the response to the end user

Use a Text element and add the attribute where you saved the knowledge agent response. This is the attribute that you mapped to $.content in the Response tab. The Text element sends the saved response to the end user.

With the Agent connector element, the chatbot follows the action in the Fallback tab if the knowledge agent does not respond within the timeout.

NOTEIf responses from the knowledge agent go directly to end users, tell them that they are interacting with AI at or before the first AI response. To show the disclosure automatically, enable AI disclosure message in the agent configuration. If AI disclosure is also on in the chatbot settings, the chatbot setting takes priority. See When to disclose.


Create a conversational experience

To create a more advanced conversational flow, route the conversation back to the knowledge agent after each response:

  1. After the knowledge agent responds, send the response in a Text element.
  2. In a follow-up dialog, capture the end user's next message.
  3. Use the GenAI Intent Detection element to determine where to route the conversation.
  4. Route the conversation back to the dialog with the Connect to AI agent or Agent connector element. This creates a continuous, conversational experience.


Test the chatbot [#test-knowledge-agent-chatbot]

Test the chatbot in the simulator before you activate it. Complete the following steps:

  1. In the chatbot, go to the Test tab > Simulator tab, and select Start simulation.
  2. Send a question that the connected knowledge sources can answer.
  3. Check that the chatbot sends the response of the knowledge agent.
  4. If the response is not what you expect, update the knowledge sources or the agent configuration, then restart the simulation.






Was this page helpful?