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 16: 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, select Internal Knowledge Base.
  4. For Knowledge base name, enter “Pharmacy FAQs.”
  5. For Import content from, select “CSV.” Then upload the FAQs CSV in the Resources ZIP that you downloaded at the start of the tutorial.

    Adding a knowledge base

  6. Click Save.

Step 17: Test the article matching

  1. On the Articles page, in the Answer Tester on the right, ensure the Enriched answers via Generative AI toggle is turned on.
  2. Enter a few queries to test the article matching:
  • What are your pharmacy hours?
  • Do you accept insurance?
  • Do you give flu shots?

Testing article matching in the Answer Tester

Step 18: 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. Click Settings in the upper-right corner.

    The Settings option accessed in the upper-right corner of the interaction

  11. Select the Advanced tab, and turn on the Enriched answers via Generative AI toggle. Click Save. (Learn about enriched answers via Generative AI.)
  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 19: 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 20: Test the automated answers

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

  1. 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.