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.
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.
Below are the prerequisites for following along with the hands-on steps in this article:
You need a trial or paid instance of Oracle Digital Assistant 19.4.1 or later. You can sign up for a free trial at cloud.oracle.com.
You need to download and extract (unzip) the resources for this hands-on exercise to your computer.
Follow these initial steps to start the service and import the bots:
Start Oracle Digital Assistant in a browser by typing https://<your cloud URL>/botsui/
into the URL field.
Click the hamburger icon (), at the upper left.
Choose Development and then Skills.
Close the menu by clicking the hamburger icon ().
Click Import Skill, and navigate to the location to which you extracted the downloaded resources for this article.
Open the starterSkills folder, select the OraMagFinance(1.2).zip file, and click Open.
Again click Import Skill, select the OraMagPasta(2.6).zip file, and click Open.
Begin working with Q&A intents by opening and running the OraMagPasta skill.
In the Skills dashboard, enter OraMag
into the filter field above the New Skill tile, as shown in Figure 1.
Figure 1: Find imported skills by typing OraMag into the filter field
Click the OraMagPasta tile to open the skill.
Click the Train menu item (), at the upper right.
In the opened dialog box, keep the default settings and click Submit.
Open the embedded conversation tester by selecting Skill Tester () from the left menu.
In the Message field, type I like to order pasta
and press the Enter key.
In the displayed cards layout, click Buy for 12.50 USD.
In the Message field, type Please add garlic, cream and oil
and press the Enter key. Notice the order confirmation.
Click the Reset link, at the top right.
In the Message field, type I like to order Macaroni pasta
and press the Enter key.
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.
Click the Reset link, at the top right.
In the Message field, type What are your opening times?
and press the Enter key.
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.
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.
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.
Click + Intent.
Set the Conversation Name field to Delivery
.
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.
Select the pencil icon (), at the right of the Answer label.
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.
Press the Enter key to save your edits.
Click the resource bundle icon (), next to the pencil icon.
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.
Click the Intents () menu item.
In the intent builder, click the qna.Delivery intent.
Click in the Enter your example utterances here field.
Type Do you deliver to out of town?
, and press the Enter key.
Select the field again, type Do you deliver pasta?
, and press the Enter key.
In the same field, type What are your delivery options?
, and press the Enter key.
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.
Click the Settings icon () in the left menu.
Set the Training Model field value to Trainer Tm
.
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.
Click the Train menu item (), at the upper right.
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.
When model training has completed, click the Skill Tester () menu item.
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.
Click the Intents () menu item to go back to the intent builder.
Expand the More button select list, and choose Import Intents.
In the opened dialog box, navigate to the CSV folder in the extracted resources for this article and select OraMagPasta-Intents.csv.
Click Open.
Notice the additional Q&A intents that got imported from the file.
Click the Train menu item ().
In the opened dialog box, keep the current settings and click Submit.
When the model training has completed, click the Skill Tester menu item.
In the Message field, type What are your opening hours?
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.
Close the conversation tester by clicking X in the tester’s header.
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.
The Q&A framework adds questions and answers separate from the intent definition and also requires changes to the dialog flow of a skill.
In the Skills dashboard, enter OraMag
in the filter field above the New Skill tile.
Select the OraMagFinance tile to open the skill.
Click the Train menu item (), at the upper right.
In the opened dialog box, keep the default settings and click Submit.
Open the embedded conversation tester by selecting the Skill Tester menu item (), at the left.
In the Message field, type Whats my balance?
In the displayed list, select savings to see the balance for savings.
Reset the conversation tester.
Type How do I change my pin?
into the Message field.
Notice how this question is not understood by the skill.
Reset the tester.
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.
Click the Q&A icon () in the left menu.
Click the +Q&A button.
In the opened panel, click + Q&A Source to upload an initial document with questions and answers.
In the Create Source dialog box, set the Language field to English and the Name field to FinanceQnA.
For File, click Select a CSV or compressed CSV file.
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.
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.
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.
Click Close.
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.
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.
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.
Click the + Components button.
In the opened dialog box, select the Language category.
In the menu on the left, select the Q&A option.
Toggle the Remove Comments option On.
Click Apply.
Edit the qna
state to look like it does in Figure 2:
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.
Click + Components, and select the User Interface category in the opened dialog box.
Select Output from the left menu, and click the Apply button.
Change the name of the state that got created to endFlow
.
Edit the endFlow
state to look like it does in Figure 3:
Figure 3: The endFlow state with changes applied
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:
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.
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 ().
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.
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.
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.
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.
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
Frank Nimphius is a Master Principal Product Manager at Oracle Corporation where he works on Oracle Digital Assistant and Health AI
Frank joined Oracle Product Management more than 20 years ago and since then worked on various Oracle products including Oracle Forms, Oracle JDeveloper, Oracle Application Development Framework (ADF) and the Mobile Application Framework (MAF) and Oracle Mobile Hub.
In his 20+ years at Oracle Frank enjoyed the many opportunities the job offered and became an author, an in-class and online-video trainer, a presenter at various international conferences, a collateral and training writer, a Java developer, as well as a product marketer and blogger.