Subscribe

Share

Application Development

Yes, I’ve Got a Question

Integrate frequently asked questions with Q&A intents and Q&A framework in Oracle Digital Assistant.

By Frank Nimphius

December 23, 2019

Creating a bot to provide answers to frequently asked questions (FAQs) is a popular first chatbot project. The expectation is that the chatbot will reduce the number of calls needing to be handled by a human and that it will increase the number of service requests that can be processed within a given time.

Chatbots that answer questions certainly live up to that expectation, but they are not very engaging and certainly could do more. Imagine the following conversation for a pasta-ordering bot:

“Do you deliver pastas?”
“Sure, we do.”
“Great, I’d like to order pasta then.”

Building a bot that answers frequently asked questions benefits an organization, but the benefits increase if the bots also handle follow-up actions such as taking orders. Here’s another example:

“When does my cable network subscription expire?”
“Your subscription expires on Monday, February 3, 2020.”
“Do you offer a discount for early subscription renewals?”
“We offer a 7% discount for renewals signed 3 months before the end of a contract.”
“Great. I’d like to renew my subscription.”

The frequently asked question in the example above—the second question—refers to the general conditions for receiving a discount when renewing a subscription. The other two user interactions are user-specific tasks that require back-end service access.

The example also demonstrates that frequently asked questions provide the most value if they are integrated into a chatbot that also knows how to handle follow-up actions and can query back-end systems for user-specific information.

Q&A in Oracle Digital Assistant

As of version 19.4.1, Oracle Digital Assistant provides two options for implementing frequently asked questions in Oracle Digital Assistant skills: Q&A intents and Q&A framework.

Q&A intents. These intents are created and treated as regular user intents and get resolved by the same natural-language-processing (NLP) model. Whereas regular intents initiate a user conversation defined in the skill dialog flow, Q&A intents return a predefined bot response message. Q&A intent messages are read from resource bundles, so organizations stay in control of the wording and the tone even for foreign languages. A typical use case for Q&A intents works with quick and short questions that should resolve to a single answer given with a high degree of certainty.

Q&A framework. This framework processes user messages in parallel with the NLP intent model, using elastic search to resolve answers to questions. To train the Q&A framework, developers upload comma-separated-value (CSV) documents that contain answers as well as one or more questions for each answer. Use cases for the Q&A framework include verbose questions that may sometimes have different answers and FAQs that need to consider a context.

For example, the following question to a bank bot may return different answers, depending on the membership of the bank’s customer: “Can I have a second card for my wife?”

The answer for a gold card member could be

“Gold card holders can receive a second card for a family member. The spending limit of this card is $1,000 per day and $5,000 per month, but the limit can be changed on request.”

Whereas the answer for regular card members could be

“Regular credit cards cannot be shared. To share credit card accounts, a gold card membership is needed.”

This use case can be easily implemented with the Q&A framework, because a skill’s dialog flow is involved, but this result is harder to achieve with Q&A intents.

The two Q&A implementations are not mutually exclusive and thus can be used in combination within a single skill. For the sake of clarity, the hands-on instructions in this article use different skills for each Q&A approach.

Getting Ready

Below are the prerequisites for following along with the hands-on steps in this article:

Follow these initial steps to start the service and import the bots:

  1. Start Oracle Digital Assistant in a browser by typing https://<your cloud URL>/botsui/ into the URL field.

  2. Click the hamburger icon (), at the upper left.

  3. Choose Development and then Skills.

  4. Close the menu by clicking the hamburger icon ().

  5. Click Import Skill, and navigate to the location to which you extracted the downloaded resources for this article.

  6. Open the starterSkills folder, select the OraMagFinance(1.2).zip file, and click Open.

  7. Again click Import Skill, select the OraMagPasta(2.6).zip file, and click Open.

Exploring Q&A Intents

Begin working with Q&A intents by opening and running the OraMagPasta skill.

  1. In the Skills dashboard, enter OraMag into the filter field above the New Skill tile, as shown in Figure 1.

    Find imported skills by typing OraMag into the filter field

    Figure 1: Find imported skills by typing OraMag into the filter field

  2. Click the OraMagPasta tile to open the skill.

  3. Click the Train menu item (), at the upper right.

  4. In the opened dialog box, keep the default settings and click Submit.

  5. Open the embedded conversation tester by selecting Skill Tester () from the left menu.

  6. In the Message field, type I like to order pasta and press the Enter key.

  7. In the displayed cards layout, click Buy for 12.50 USD.

  8. In the Message field, type Please add garlic, cream and oil and press the Enter key. Notice the order confirmation.

  9. Click the Reset link, at the top right.

  10. In the Message field, type I like to order Macaroni pasta and press the Enter key.

  11. When prompted for the extras, type No extras please and press the Enter key. Again, notice the order confirmation.

What you just did: After training the skill with the Trainer HT model, you successfully tested the pasta order intent. With the second order, you showed that entity extraction also worked, by including Macaroni in the initial message.

  1. Click the Reset link, at the top right.

  2. In the Message field, type What are your opening times? and press the Enter key.

  3. Notice that the bot does not understand the question. But don’t give up yet. Type Do you deliver pasta?, and press the Enter key.

  4. Unfortunately, again, the bot doesn’t seem to understand the question. Click the Reset link, and click X in the header to close the tester window.

Note: The skill does not understand simple questions and instead tries to resolve such questions to a conversation. In the following steps, you will add Q&A intents that enable users to ask questions.

  1. Ensure that the Intents () menu item is selected. If it is not, click the Intents item ().

Notice the three existing intents. Each of these intents starts a conversation defined in the skill’s dialog flow.

  1. Click + Intent.

  2. Set the Conversation Name field to Delivery.

  3. Set the Name field to qna.Delivery.

    Note: The qna. prefix for Q&A intents is not a requirement. Using a prefix for Q&A names, however, helps visually distinguish Q&A intents from regular intents.

  4. Select the pencil icon (), at the right of the Answer label.

  5. In the Answer field, type

    We deliver our pasta. 
    We also offer deliveries outside 
    the city within a radius of 10 miles. 
    Deliveries outside the city will incur 
    an additional $3 for pasta purchases of 
    less than $30. They’re free for orders 
    of $31 and above.
    
  6. Press the Enter key to save your edits.

  7. Click the resource bundle icon (), next to the pencil icon.

  8. Click the Q&A tab.

    Notice that the answer you provided is saved as a resource string for the default language (English). Because they use resource bundles, your Q&A intents can be translated for use in multilanguage skills.

  9. Click the Intents () menu item.

  10. In the intent builder, click the qna.Delivery intent.

  11. Click in the Enter your example utterances here field.

  12. Type Do you deliver to out of town?, and press the Enter key.

  13. Select the field again, type Do you deliver pasta?, and press the Enter key.

  14. In the same field, type What are your delivery options?, and press the Enter key.

  15. Come up with two more sample questions about delivery terms and conditions, and add them—one by one—to the Enter your example utterances here field. At the end, you should have five utterances defined.

  16. Click the Settings icon () in the left menu.

  17. Set the Training Model field value to Trainer Tm.

  18. Toggle Optimize for Q&A intents on.

    Note: For Q&A intents, you must use Trainer Tm and enable the Optimize for Answer Intents option. Trainer Tm is a machine learning algorithm that requires more utterances to be defined for regular intents than Trainer Ht does. Keep this in mind when adding Q&A intents to your custom skills.

  19. Click the Train menu item (), at the upper right.

  20. In the opened dialog box, keep the current settings and click Submit.

    Note: Using Trainer Tm with the Optimize for Answer Intents option means that training will take longer.

  21. When model training has completed, click the Skill Tester () menu item.

  22. In the Message field, type What about delivery? and press the Enter key. You should see the answer you provided in step 21 as the bot response.

    Note: When using Q&A intents in Oracle Digital Assistant skills, you don’t need to define a state in the dialog flow for the answer to be shown to the user.

  23. Click the Intents () menu item to go back to the intent builder.

  24. Expand the More button select list, and choose Import Intents.

  25. In the opened dialog box, navigate to the CSV folder in the extracted resources for this article and select OraMagPasta-Intents.csv.

  26. Click Open.

    Notice the additional Q&A intents that got imported from the file.

  27. Click the Train menu item ().

  28. In the opened dialog box, keep the current settings and click Submit.

  29. When the model training has completed, click the Skill Tester menu item.

  30. In the Message field, type What are your opening hours?

  31. When you get an answer, type Where can I park my car?

    A correct answer should be displayed from the set of imported Q&A intents.

  32. Close the conversation tester by clicking X in the tester’s header.

  33. Exit the OraMagPasta skill, and return to the Skills dashboard by clicking the arrow icon on the left in the skill header ().

What you just did: In this part of the hands-on exercise, you improved the pasta skill by adding Q&A intents. You created a Q&A intent manually and imported others from a comma-separated-value list file. You used the Trainer Tm machine learning model along with a setting to enable optimization for Q&A intents.

Q&A intents provide a single answer to a question. The intents are evaluated with the same algorithm used for regular intents that would start a bot conversation. For bot designers, Q&A intents are easy to build and train, but they cannot apply rules that, for example, would give regular intents precedence over Q&A intents under a specific condition.

Exploring the Q&A Framework

The Q&A framework adds questions and answers separate from the intent definition and also requires changes to the dialog flow of a skill.

  1. In the Skills dashboard, enter OraMag in the filter field above the New Skill tile.

  2. Select the OraMagFinance tile to open the skill.

  3. Click the Train menu item (), at the upper right.

  4. In the opened dialog box, keep the default settings and click Submit.

  5. Open the embedded conversation tester by selecting the Skill Tester menu item (), at the left.

  6. In the Message field, type Whats my balance?

  7. In the displayed list, select savings to see the balance for savings.

  8. Reset the conversation tester.

  9. Type How do I change my pin? into the Message field.

    Notice how this question is not understood by the skill.

  10. Reset the tester.

  11. Close the conversation tester by clicking X in the tester’s header.

Note: The OraMagFinance skill does not handle user questions related to banking yet. In the next steps, you will create a Q&A source that the skill uses when a user message does not match one of the two regular intents.

  1. Click the Q&A icon () in the left menu.

  2. Click the +Q&A button.

  3. In the opened panel, click + Q&A Source to upload an initial document with questions and answers.

  4. In the Create Source dialog box, set the Language field to English and the Name field to FinanceQnA.

  5. For File, click Select a CSV or compressed CSV file.

  6. In the opened dialog box, navigate to the folder containing the downloaded resources for this article, open the CSV folder, and select the OraMagFinance-FinancialQnA-allqna.csv file. Click Open.

  7. Ensure that Enabled is toggled on, and click Create.

    Wait a few seconds for the Q&A document to load. The loading is indicated by green “loading …” text next to the FinanceQnA name.

  8. Click the View All Q&A button, at the top right.

    Notice the questions and the answers (one or many questions for a single answer). You can use this panel to add your own questions and answers by clicking Add Question or to export an existing Q&A source. For now, don’t create additional questions. Optionally, you can do this later.

  9. Click Close.

  10. Click the Train menu item (), at the upper right, and keep the current settings but notice that Q&A is highlighted in the opened dialog box. This indicates that a Q&A source got detected that needs to be trained.

  11. Click Submit, and wait for the model to finish training.

    Note: The Q&A framework uses elastic search to find matching answers to a question. As you will see later, this search could lead to multiple answers’ being displayed by the bot for the user to browse through and select from. This choice of answers is one differentiator between the Q&A framework and the Q&A intents, covered in the first part of this article.

  12. To use the Q&A framework in a skill, you need to add a component to the skill’s dialog flow and add the use of the Q&A framework to the System.Intent component. To do this, open the dialog flow builder by clicking the Flows () icon in the left menu.

  13. Click the + Components button.

  14. In the opened dialog box, select the Language category.

  15. In the menu on the left, select the Q&A option.

  16. Toggle the Remove Comments option On.

  17. Click Apply.

  18. Edit the qna state to look like it does in Figure 2:

    qna state with changed transitions property

    Figure 2: qna state with changed transitions property

    Note: The System.QnA component provides many properties that enable you to change the component behavior and layout. All properties are listed and explained in the QnA – advanced settings component template, which you can access by clicking + Components and then the language category.

  19. Click + Components, and select the User Interface category in the opened dialog box.

  20. Select Output from the left menu, and click the Apply button.

  21. Change the name of the state that got created to endFlow.

  22. Edit the endFlow state to look like it does in Figure 3:

    The endFlow state with changes applied

    Figure 3: The endFlow state with changes applied

  23. Next navigate to the System.Intent component in line 14 of the dialog flow builder. Add the component properties and values highlighted in Figure 4:

    System.Intent component with Q&A properties

    Figure 4: System.Intent component with Q&A properties

What you just did: In this part of the hands-on exercise, you integrated a Q&A framework into the dialog flow, using the System.QnA component. You then changed the System.Intent component to route user messages to the Q&A framework and not the intent engine only. If a question and an intent get resolved, a dialog box will be displayed where users can choose what to do. The prompt for this dialog box is defined by the optionsPrompt property. Setting qnaSkipIfIntentFound to True would suppress the dialog box and consider the Q&A framework only if no intent gets resolved for a user message.

  1. Because the recent changes altered only the dialog flow of the skill, there is no need for you to retrain the model. Open Skill Tester by clicking the icon ().

  2. In the Message field, type How do I change my pin?. The skill should respond with a direct answer, because only one question matches the message.

  3. Next type Do you have a mobile app? into the Message field. This question finds multiple matches, and therefore the System.QnA component shows a card layout where the user can browse questions and answers.

  4. Select an answer.

One important characteristic of the Q&A framework is that the System.QnA component can display a single question and answer as well as a choice of questions and answers for a user message. Using the configuration settings of the Q&A framework as well as the properties of the System.QnA and System.Intent components, skill developers can customize the Q&A search and routing. Finally, note that because the Q&A framework requires dialog flow changes, it is more complex to set up than Q&A intents.

Conclusion

This article provided you with a side-by-side comparison of the two options in Oracle Digital Assistant for adding questions and answers to a skill conversation. As a rule of thumb, the more you want questions and answers to behave like FAQs on the web, the more likely you are to choose the Q&A framework. If you always want a single answer to a question, then Q&A intents is what you would choose.

Next Steps

TRY Oracle Mobile Cloud Enterprise and Oracle Intelligent Bots.

LEARN more about
Oracle Digital Assistant.
The Q&A framework.
Q&A intents.

DOWNLOAD the bot for this article.

Illustration by Wes Rowell