Use an AI assistant in your chatbot

|

View as Markdown

To use an AI assistant in your chatbot, add the AI assistant element.

The process is as follows:

  1. In your chatbot, save the end user's message in an attribute.
  2. Add the AI assistant element and configure it. In the AI assistant element, pass the attribute as an input to the AI assistant.
  3. The assistant generates a response based on the input, the assistant configuration, and the documentation uploaded to the assistant.
  4. In the AI assistant element, get the response from the assistant and save it in a different attribute.
  5. Send the response to the end user.


Save end user's message in an attribute [#save-user-input-in-attribute]

To save the message, follow one of these options:

  • Use the predefined attribute lastReceivedTextMessage, which captures the last message sent by the end user.
  • Save the end user's response in a standard attribute by using the Save user response element.

The following image shows the end user's message saved in an attribute:

Save the end user's message in an attribute

Add the AI assistant element to your chatbot [#add-assistant-to-chatbot]

Use the AI assistant element to add an AI assistant to your chatbot.

The following image shows the AI assistant element in the chatbot editor:

Add AI assistant element

Guidelines [#guidelines-add-assistant]

Note the following:

  • Select only one AI assistant in the element.
  • Add only one AI assistant element to a dialog.
  • Use more than one AI assistant in your chatbot, if needed.

Configure the AI assistant element [#configure-ai-assistant-element]

Configure the AI assistant element as follows:

Configure the basic fields

  1. Select an assistant from the list.

    Configure AI assistant element
  2. In the User message field, select the attribute in which the end user's message is stored. The chatbot sends this attribute value to the AI assistant service.

Configure additional options

Set the following optional fields:

  • External content source: If you set this source, the AI assistant ignores data that is defined in its main content source, and uses the external content source instead.

  • Memory key: Use the memory key to share memory between assistants and other GenAI components that have the same key.

  • Return contexts: If you set this field to True, the assistant returns the parts of the documentation that were used to generate the response.

  • Prompt variable: Use this field if the Prompt template section in the selected AI assistant contains {prompt_var}. The chatbot passes the value from the Prompt variable field to {prompt_var}. This helps you personalize chats or give context to the AI assistant.

    Example: In the Prompt variable field, add Refer to the end user as {{name}}.

Save the assistant response

The AI assistant returns an answer to the user question in a JSON schema:

json
1{
2 "response": "Assistant's response"
3}

Extract the response and save it by using Response body attributes. To extract the response text, select the attribute in which to save the response. Then, define the JSON path.

Example: $.response.

The following image shows the response saved in an attribute:

Save the response from the AI assistant element

You can use the JSON response and the extracted value for further processing, or return the value to the end user.

Add fallback

The chatbot triggers the fallback action if the AI assistant service is not responding. You can either redirect the end user to a different dialog or transfer the conversation to an agent.

For more information, see the Add fallback documentation in Answers.



Send the response to the end user [#share-assistant-response-with-user]

To return the response from the assistant, use a Text element and add the attribute in which you saved the response.

The following image shows the response in a Text element:

Share the response from the AI assistant element with the end user
NOTEIf responses from the AI assistant 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, turn on AI disclosure in the chatbot settings. See AI transparency and disclosure.


Create conversational AI chatbots [#conversational-chatbot]

To configure a more advanced AI assistant experience, use other Infobip Generative AI tools.

Example:

After the assistant answers the end user's question, send the response in a Text element.

Share the response in a Text element

Then, in a different dialog, ask the end user for more input. Use the GenAI intent detection element to determine where to route the conversation. In the target dialog, you can define a way to route the conversation back to the AI assistant, resulting in a conversational AI experience.

Use the GenAI intent detection element


Was this page helpful?