This is a tutorial series that's cumulative in nature. To start from the beginning, start here.

At LivePerson, we’re thrilled that advancements in Natural Language Processing (NLP) and Large Language Models (LLMs) have opened up a world of possibilities for Conversational AI solutions. The impact is truly transformative.

In this lesson, you add support for answering FAQs to the Voicebot. And you use a Large Language Model (LLM) to enrich those answers via Generative AI. The result? Smarter, warmer, and better answers. And an experience that’s more human-like.

Learn about LivePerson’s trustworthy Generative AI solution.

Step 15: Add a knowledge base

  1. Open the menu on the left side of the page, and select Automate > KnowledgeAI.
  2. Click Add knowledge base in the upper-right corner.
  3. On the AI Enabled tab of the window that appears, specify the following:
    • Knowledge base name: Enter “Pharmacy FAQs.”
    • Content source: Select “CSV.” Then upload the FAQs CSV in the Resources ZIP that you downloaded at the start of the tutorial.

    Adding a knowledge base

  4. Click Save.

Step 16: Test the article matching

  1. Click Articles in the menu at the top of the page.
  2. In the Answer Tester on the right, ensure the Enriched answers via Generative AI toggle is turned on.
  3. Enter a few queries to test the article matching:

    • What are your pharmacy hours?
    • Do you accept insurance?
    • Do you give flu shots?
  4. Click Get answers.

Testing article matching in the Answer Tester

You can ignore the warning in the UI about the default value for the Enrichment prompt. For the purpose of this tutorial, the default prompt will work just fine. In a real world scenario, you should select and use one of your own prompts as soon as possible. (You can copy one of LivePerson's if you choose.)

The Enrichment prompt is the prompt to send to the LLM service when the consumer’s query is matched to articles in the knowledge base. It instructs the LLM service on how to use the matched articles to generate an enriched answer.

Step 17: Integrate the knowledge base into the bot

  1. Navigate back to Conversation Builder.
  2. Open the Pharmacy bot, and select Integrations on the menu bar.
  3. Click Add Integration in the upper-right corner.
  4. Specify the following:

    Adding a KnowledgeAI integration

  5. Click Save.
  6. Click Dialogs on the menu bar, and open the Fallback dialog.
  7. Delete the one interaction in the dialog using the Delete option in the interaction’s menu.

    Deleting an interaction

  8. Open the interaction tool palette on the right, and add an Integration interaction to the dialog.

    Adding an integration interaction using the interaction tool palette

  9. Name the integration interaction “FAQ search,” and select the “FAQSearch” integration that you just created from the dropdown list.

    An Integration interaction with an integration selected on the interaction's face

  10. Turn on the Enriched answers via Generative AI toggle.

    The Integration interaction with the Enriched Answers via Generative AI toggle turned on

    Here again, you can ignore the warning in the UI about the default value for the Enrichment prompt. For the purpose of this tutorial, the default prompt will work just fine. In a real world scenario, you should select and use one of your own prompts as soon as possible. (You can copy one of LivePerson's if you choose.)

    Next you select a prompt for the No Article Match prompt. This is the prompt to send to the LLM service when the consumer’s query isn’t matched to any articles in the knowledge base. It instructs the LLM service on how to generate a response (using just the conversation context and the prompt).

    If you don’t select a No Article Match prompt, then if a matched article isn’t found, no call is made to the LLM service for a response. But for this tutorial, you'll select one in the next step, so you can see how this provides support for small talk.

  11. For the No Article Match prompt, copy a LivePerson template, and select to use it as this prompt:

    1. On the face of the interaction, click + Select prompt.

      The Select prompt button for selecting a No Article Match prompt

    2. In the pop-up window, click Yes, continue.
    3. Click Prompt templates.
    4. Select the "Fallback No Article Match EN - Conversation Assist" template.

      Selecting a prompt template in the Prompt Library

    5. In the read-only window that appears, review the template, and click Use template.
    6. In the editable window, change the name of the prompt to "NoArticleMatch EN - Voicebot". Click Save.

      Updating the name of the new prompt

      The KnowledgeAI interaction with prompts specified for both the Enrichment prompt and the No Article Match prompt

  12. Still in the Integration interaction, click the Custom Code icon.

    The Custom Code option accessed in the upper-right corner of the interaction

  13. Select the Post-Process Code tab.
  14. Enter the following code, and click Add Script.

    var articleText = botContext.getBotVariable("FAQSearch.article");
    var escapedText = escapeSpecialCharacters(articleText);
    botContext.printDebugMessage("Article text = " + escapedText);
    botContext.setBotVariable("articleText", escapedText, true, false);
    

    The code added to the Post-Process Code tab in the interaction

    This code takes the answer from the knowledge base, and uses the escapeSpecialCharacters function to replace certain special characters with their corresponding HTML entities. This helps to ensure that when the answer is displayed/played, the special characters are properly rendered/handled, with no unintended side effects.

    You will add the escapeSpecialCharacters function to the bot’s Global Functions soon.

    This code then saves the processed answer in a bot variable named articleText.

  15. Add a speech statement below the FAQ search integration. Name it, “FAQ search success.” For the statement, enter the following:

    {$botContext.articleText}

    And set its Next Action, so it directs the flow to the “Ask if anything else” question in the “Anything else” dialog.

    The Speech statement that plays the answer from the knowledge base search

  16. Beneath the success statement that plays the answer from the knowledge base, add a speech question to handle a FAQ search failure:

    • Name it “FAQ search fail.”
    • Enter the statement: “I’m sorry! That’s not something I can help with. Could you try again?”
    • Go into the Advanced tab in the interaction settings, and set the Elapsed time before prompt to “7000”.

      The Speech question that asks the consumer to try again

  17. Return to the Integration interaction at the top of the dialog. Add a custom rule where the condition is “API Result” matches “Success.” If the condition is true, the flow should go to the next action.

    Adding a rule that directs the flow to the next action if the API result is Success

  18. Add another custom rule named “Failure,” where the condition is “API Result” matches “Failure.” If the condition is true, the flow should go to the “FAQ search fail” interaction.

    Adding a rule that directs the flow to the FAQ Search Fail interaction if the API result is Failure

    The fully configured FAQ Search interaction

Step 18: Add a global function

Click Global Functions, and add the following code above the initConversation method.

function escapeSpecialCharacters(message) {
  var escapedMessage = message.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
  return escapedMessage;
}

Click Save.

(Learn about global functions.)

Step 19: Test the automated answers

Now let’s see the answers enriched via Generative AI in action.

  1. Return to the Dialogs page, and use Preview to ask a few intentful questions, such as:

    • What are your pharmacy hours?
    • Can I transfer my prescriptions?
    • Do you give flu shots?

    Testing enriched answers via the Preview tool

    By default, Voicebots support context switching, so you should be able to ask an FAQ anywhere in the bot flow. The bot will answer the FAQ and then return you to the previous flow.

  2. Try some small talk too:

    • Hi, how are you?
    • What’s up?

    More testing of enriched answers via the Preview tool

What's next?

Continue on to the next tutorial in the series.