This article helps to quickly build and understand the working of a Knowledge Graph for your bot. It shows how to convert an FAQ into ontology, add tags, use terms, add alternate questions, synonyms, tags, and traits.
For the implementation details, refer here.
Throughout this example we will be dealing with the following FAQs related to a banking bot:
- How do I apply for a debit card?
- How do I apply for a checkbook?
- How do I open a joint account?
- Can I add a joint account holder?
Static FAQ
Let us start by creating a static FAQ without an ontology.
To add a static FAQ, follow the below steps:
- Open the bot.
- Select the Build tab from the top menu
- On the left pane, click Conversational Skills > Knowledge Graph.
- Click Create to create a Knowledge Graph.
- A Knowledge Graph with the name set to the Bot Name is created.
- Click Add Intent to start entering your FAQs.
- Select Intent type as FAQ
- Add Question and Bot Response; then click Save.
- Click Add Intent on the top-right to add more Q&As.
- After you enter all the Q&As, click Train to train the Knowledge Graph.
- Click Talk to Bot at the bottom-right to check the bot response for the added Q&As.
Tags
- Issue: Try the utterance how do I apply for a credit card?
We will get did you mean dialog with reference to a question pertaining to Debit Card, which is not appropriate in this scenario. Ideally, we should see an I don’t know response as you get for a totally unrelated query regarding weather.
Solution
To overcome the above situation, we can add tags to each question. Tags help filter the FAQs based upon the presence of some key phrases in the user utterance.
Steps in adding Tags:
- Hover over the Question to find the edit icon.
- Click the edit icon to add a tag to the question.
- In the add tag text box, you can find some suggestions by the platform based on the phrases present in the question. You can pick one from the list or type your own custom tag.
- For this use case, we can pick the debit card tag as suggested by the platform and Save the changes.
- Similarly, add a checkbook for the How to apply for checkbook question.
- Train the bot.
- Talk to the Bot, use the same utterance how do I apply for a credit card?
Ontology
For a better bot response, you must add tags for every question. But this solution is not feasible in case we have a big list of FAQs. Also, more than one question can have a tag(s) in common.
Solution: Ontology. Based on crucial words and frequently occurring words/phrases, FAQs are organized into groups and subgroups.
Example of Ontology: Continuing with the Banking bot FAQ example, we can organize the questions thus:
- Apply
- Debit Card
- How do I apply for a debit card?
- Checkbook
- How do I apply for a credit card?
- Joint account
- How do I open a Joint account?
- Can I add a joint account holder?
Each group can be a node in the ontology. You can have multiple levels of the nodes forming a hierarchical structure. Moving the relevant FAQs (intents) to the nodes will associate that FAQ with the corresponding node name set as a tag.
To create an ontology, follow the below steps:
- Hover over the Knowledge Graph name on the left pane and click + icon to Add Child Node.
- Add the Nodes as Apply and Joint Account.
- To add subgroups, hover over the node and use the corresponding + icon to add child nodes.
- Select the questions pertaining to Joint Account and drag and drop them to the Joint Account node.
- Repeat the process for questions related to Apply, Debit Card, and Checkbook nodes.
- You will notice the path gets updated accordingly.
- Edit a question and see that the node name is added as a tag.
- This ensures that this question is qualified for a user utterance containing the term/node name. Note that the tags you added earlier are retained and you can delete them, whereas the node names cannot be deleted.
- Train the Knowledge Graph and Talk to Bot.
- There should not be any changes in the bot responses.
Term Usage
By default, the node names or terms are used in evaluating the path and coming up with a set of qualifying questions. You can tighten or relax this rule by either making the term mandatory in the utterance or marking the term/node as organizer respectively.
Before proceeding, let us add a few more nodes questions to our Knowledge Collection:
- Account
- How do I open an account?
- How do I access my account?
- How do I check my account balance?
- How do I access my account online?
- Contact
- Who do I contact in case of an issue?
- What is your helpline number?
- Complaints
- Where can I register my query/complaints?
- Issues
- How do I report a stolen card?
Use Case 1: You want to ensure that the intents regarding Joint Account must be considered only when the user asked a direct question regarding the same. Any ambiguous cases must consider the Account node and not the Joint Account node.
To address this case, we mark the term Joint Account as Mandatory. This helps improve the bot’s performance.
Steps:
- Hover over the node, in this case, Joint Account, and click on the settings icon.
- From the Settings section, select the Mandatory option from the dropdown next to the term name.
- Save and Train the Knowledge Collection.
- Now the questions under this node are considered only if the user utterance has the node name, Joint Account in this case.
Use Case 2: Consider the following FAQs.
- Contact
- Who do I contact in case of an issue?
- What is your helpline number?
- Complaints
- Where can I register my query/complaints?
- Issues
- How do I report a stolen card?
Though they do not have any phrases or terms in common, they are related to Customer Care. For ease of understanding, we can put them under a node by the same name and mark it as Organizer node, ensuring that the intents get qualified without the need to have the term phrase in the user utterance.
Steps:
- Create a node Customer Care.
- Drag and drop the above three nodes to this new node.
- Hover over the node, in this case, Customer Care, and click on the settings icon.
- From the Settings page, select the Organizer option.
- Save and Train the Knowledge Collection.
- Now the questions under this node are considered even if the user utterance does not include the node name.
Synonyms
Use Case: Try How do I get a debit card? you will get a suggestive match not definitive. The reason being the bot does not understand get as being the same as apply.
Solution: Synonyms
To add synonyms, follow the below steps:
- Hover over the Apply node and click the settings icon.
- In the Path Level Synonyms, add get.
- Save and Train the Bot.
- Talk to Bot and use the same query How do I get a debit card?
- Try How do I get a checkbook and you will see that the synonym works here also. This is because we added the synonym at path level and it is applicable to all nodes and questions under that path/node.
- Similarly, we can define Knowledge Graph Synonym if it is applicable to the entire knowledge graph.
Alternate Questions
Some questions have multiple ways the user can approach them.
- Is there a way to see my account details from my laptop?
- Is there a mobile app that I can use to access my account?
- Does your bank support internet banking to view account details?
All these questions pertain to one intent: How do I access my account online?. But instead of adding all these Q&As as intents and repeat the response and the settings, if any, you can add these questions as alternate questions.
To add alternate questions, follow the below steps:
- Hover over the question, in this case, How do I access my account online? and click the edit icon.
- In the Add alternate question enter the question.
- Add all the three queries mentioned above.
- Save, Train, and Talk to the Bot.
- Entering any of the above three questions will yield the same response as the question How do I access my account online?
Tasks Execution
Consider the query How do I check my account balance?. If the bot has a task that can give the balance, we can direct the user to the same, instead of asking the user to use the utterance to trigger the task.
To trigger a task, follow the below steps:
- Before proceeding, ensure that you have a task defined for Check Balance. Let us consider a dummy dialog that displays a message.
- Add the Add Intent How do I check my account balance?
- Set Intent to Task.
- From the drop-down list select the Dialog Task name Check Balance.
- Save and Train the Knowledge Graph.
- Talk to bot with the utterance How do I check my account balance? will trigger the Check Balance task.
Tags in Ontology
Use Case: Does your bank give a passbook to view account details? You will get Did you mean How do I access my account online?.
The reason being the alternate question for online account access: Does your bank support internet banking to view account details? is a very close match to the above query. You can avoid such situations by adding a tag internet banking and marking it as mandatory to the alternate question Does your bank support internet banking to view account details?.
Solution: Custom Tags
To add tags, follow the below steps:
- Edit the question How do I access my account online?
- For the alternate question Does your bank support internet banking to view account details?
- Add the tag internet-banking.
- Click the tag to open the Tag Settings dialog and set Tag Usage to Mandatory.
- Click Done.
- Repeat for the alternate question Is there a mobile app that I can use to access my account? with the tag mobile app.
- Save and Train the bot.
- Now Talk to the Bot and see the response.
Traits
Use Case: I lost my card, how do I apply for another debit card?
You will get the response with How do I apply for a debit card?.
While this is a valid response it is not the right one. Ideally, since the user said I lost my card bot must direct the user to report a stolen card.
Solution: Traits. Traits are used to get additional information from user utterance and direct the user to a better solution.
To add traits, follow the below steps:
- First, add this question as an alternate question to How do I report a stolen card?.
- Save and Train the bot.
- Talk to bot and ask the same question. You will get the same response.
- Now let us see how to add Trait.
- Define Trait:
- From the more option next to the Train button, select the Manage Traits option.
- Click New Trait to create a New Trait.
- Give a Trait Type and add Traits to it. Here, let us consider Issues as Trait Type and lostcard as Trait.
- Add lost my card as the utterance that triggers this trait. (Do not forget to hit enter after you add the utterance).
- Save and Train the trait.
- Apply Trait
- From the ontology, go to the Issues node Settings page.
- Add lostcard as Trait (pick from the drop-down list).
- Save and Train the Knowledge Graph.
- Talk to the Bot and try the same question. Now you will get the expected response.
In this document you have seen various settings for building and managing Knowledge Graph. For details regarding the implementation and working of Knowledge Graph, refer to this document.