Use generative answers in basic voice agents

When you create a basic voice agent, it automatically supports adding knowledge for generative answers. The voice-enabled agent formats text-to-speech (TTS) output based on generative answers. Learn more in Tools, knowledge, MCP, and API.

Inform users that responses are AI generated

When you incorporate generative answers into your voice-enabled agent, inform your users of the following points:

  • AI is used to generate responses.

  • Users can consult the references your agent uses to generate responses.

  • Users must verify the accuracy of the generated responses themselves.

Learn more in FAQ for generative answers and FAQ for voice optimization.

The following sample messages are returned to users when you incorporate generative answers messages in a voice-enabled agent.

Type of message Description Example
AI disclaimer Message to inform the user that AI might be used, and that the user should verify the information in the message. "Please note that some responses are generated by AI and might require verification for accuracy.
Latency message Message to inform the user to hold while information is retrieved. "Please hold while I gather information. <break time="5000ms"/>"
The latency message loops, so timeouts should be adjusted.
Apology message Message to apologize to the user if no answer was found. "I'm sorry, I don't have the knowledge to answer at this time."
Hear references Message to inform the user that they can hear a list of the references used by the AI. "This response was used by AI and might be incorrect. To hear the references that were consulted, please press 9. To return to the main menu, press star."
Barge-in message Message to inform the user that they can skip listening to references. "The following references were consulted. Press star at any time to return to the main menu."

Setup generative answers in your basic voice agent

  1. Configure your agent to support voice capabilities.

  2. Provide your agent with at least one knowledge source.

  3. Optionally, configure content moderation.

  4. Test your responses. The received answers should be concise, follow the same language as the input query, and be free of incorrect information. By default, the responses don't include citations and sources.

Access citations and sources from responses

By default, the system automatically removes citations and sources from responses. However, you can retrieve the citations and sources by using the Conversational boosting system topic.

Update the Conversational boosting system topic

  1. Select your agent and select the Topics page.

  2. Select the Conversational boosting system topic.

  3. Select the Create generative answers node, select the three dots () of the node, and then select Properties.

  4. Select Advanced and set Save LLM response to Complete (recommended), and Save bot response to the Answer Topic.Answer variable.

  5. Assign the Answer.Speech.Citations table variable to a global variable, such as GenAnsVoiceRef.

  6. Add a Message node that instructs the caller how to hear the citations. For example, "This response was generated by AI and might be incorrect. To hear the references, please press 9. To return to the main menu, press *."

    1. Optionally, update the knowledge sources, content moderation, and other properties of the generative answers node.

    2. Optionally, configure a latency message for generative answers, or reference a publicly accessible audio file with speech synthesis markup language (SSML) to be played to cover the latency.

Return the citation

Create a topic with one or more of the following nodes to capture and return citations that the agent references.

  1. On the Trigger node, replace the default topic trigger with DTMF global command received, and set the DTMF Key property to 9.

  2. Use Message nodes to inform users that the agent either used a reference or couldn't use a reference to generate a response. For example:

  • "The following reference was consulted. Press * at any point to return to the main menu."

  • "No specific references were used to generate the previous answer."

  1. Use Condition nodes to branch the dialog based on the user's responses. In the left branch, these conditions are met when the user asks a question that utilizes a reference.
  • Use the left branch of the conditions when the first condition sets the global variable set in the previous steps. For example, Global.GenAnsVoiceRef. Set the variable to has value. This branch is also followed by another Message node. Insert a Reference.Name variable, followed by "consulted at," and add another variable, Reference.Url.

  • Use the right branch of the conditions when the user's questions aren't answered or a reference isn't used to return a response. A Message node follows, with a message such as, "No specific references were used to generate the previous answer."

  1. Under the left branch of the condition node, add a Set a variable value node. Set the first variable to Create Variable name and set it to NumReferences. Set the To value to a formula: Count Rows(Global.GenAnsVoiceRef). Set the Type to number, and set Reference to Topic.NumReferences.

  2. Set Items to loop over to the Global.GenAnsVoiceRef variable in a Loop through a list node. Set the Loop value variable to record type and give it the name, "Reference."

  3. Set a Go to another topic node to Main Menu.

  4. Add an End current topic node to complete the topic.

Sample topic YAML to output citations

The following YAML code demonstrates how to create a topic that outputs citations. To speed up the creation of the topic, copy and paste the YAML code into a new topic. To use the YAML code, complete the following steps:

Note

The YAML code relies on assigning the Answer.Speech.Citations table variable to a global variable named GenAnsVoiceRef.

  1. Select your agent and select the Topics page.

  2. Select Add a topic and select From blank.

  3. Open the code editor, and paste the YAML over the existing YAML.

    kind: AdaptiveDialog
    beginDialog:
      kind: OnDtmfKeyPress
      id: main
      dtmfKey: Num9
      actions:
        - kind: ConditionGroup
          id: conditionGroup_Im7G18
          conditions:
            - id: conditionItem_a2ax5d
              condition: =!IsEmpty(Global.GenAnsVoiceRef)
              actions:
                - kind: SetVariable
                  id: setVariable_dgK3w7
                  variable: Topic.NumReferences
                  value: =CountRows(Global.GenAnsVoiceRef)
    
                - kind: ConditionGroup
                  id: conditionGroup_YRrOBv
                  conditions:
                    - id: conditionItem_hD1dXt
                      condition: =Topic.NumReferences = 1
                      actions:
                        - kind: SendActivity
                          id: sendActivity_42mrfG
                          activity:
                            speak:
                              - The following reference was consulted. Press * at any point to return to the main menu.
    
                  elseActions:
                    - kind: SendActivity
                      id: sendActivity_zyZNYz
                      activity:
                        speak:
                          - The following references were consulted. Press * at any point to return to the main menu.
    
                - kind: Foreach
                  id: foreach_oWbdVm
                  items: =Global.GenAnsVoiceRef
                  value: init:Topic.Reference
                  index: init:Topic.LoopIndex1
                  actions:
                    - kind: SendActivity
                      id: sendActivity_CAqLKs
                      activity:
                        speak:
                          - "{Topic.Reference.Name} consulted at {Topic.Reference.Url}"
    
          elseActions:
            - kind: SendActivity
              id: sendActivity_XHfqKK
              activity:
                speak:
                  - No specific references were used to generate the previous answer.
    
        - kind: BeginDialog
          id: zkSWAP
          dialog: crc82_sophieGenAnswers.topic.Untitled
    
        - kind: EndDialog
          id: MXYSAQ
    
  4. Close the code editor and save the topic.