This How To 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 one without an ontology.
Steps in adding a static FAQ:
- Open the Bot and go the Bot Tasks -> Knowledge Graph section.
- Click Create to create a Knowledge Graph.
- A Knowledge Graph with the name set to the Bot Name will be created.
- Use the Add Q&A button to start entering your FAQs
- Add Question and Bot Response and Save
- Use the Add Intent button to add more Q&As.
- Once you have entered all the Q&As, Train the Knowledge Graph.
- Use the Talk to Bot 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 will 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 will 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 will pick the “debit card” tag as suggested by the platform and Save the changes.
- Similarly, add “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
We can need to add tags for each and every question for a better Bot response. 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 can be 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?
- Debit 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.
Steps in creating ontology
- Hover over the Knowledge Graph name on the left panel 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 has been added as a tag.
- This will ensure that this question will be 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 qualified 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 help line number?
- Complaints
- Where can I register my query/complaints?
- Issues
- How do I report a stolen card?
Use Case 1: We want to ensure that the intents regarding “Joint Account” should be considered only when the user asked a direct question regarding the same. Any ambiguous cases should consider the Account node and not the Joint Account node.
To address this case, we would mark the term Joint Account as Mandatory. This would help improve the bot performance, too.
Steps:
- Hover over the node, in this case Joint Account, and click on the settings icon.
- From the Settings page, under Term Usage section select the Mandatory radio button.
- Save and Train the Knowledge Collection.
- Now the questions under this node will be 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 help line 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 Organizer radio button.
- Saveand Train the Knowledge Collection.
- Now the questions under this node will be 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 suggestive match not definitive. The reason being the Bot does not understand “get” as being the same as “apply”.
Solution: Synonyms
Steps in adding synonyms:
- Hover over the “Apply” node and click settings icon.
- In the Path Level Synonyms, add “get”.
- Save and Train the Bot.
- Talk to Bot and use the same query “How to 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.
Steps in adding alternate questions:
- 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 which 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.
Steps in triggering a task:
- Before proceeding, ensure that you have a Task defined for “Check Balance”. We have a dummy dialog which displays a message.
- Add the Add Intent “How do I check my account balance?”
- Set Intent to “Task”
- From the drop-down pick the Dialog Task name – here, 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 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
Steps in adding tags:
- Edit the question “How do I access my account online?”
- For the alternate question “Does your bank support internet banking to view account details?”
- Repeat for the alternate question “Is there a mobile app that I can use to access my account?” with the tag “mobile app”
- Saveand 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 should be directing the user to report a stolen card.
Solution: Traits. Traits can be used to get additional information from user utterance and direct the user to a better solution.
Steps in adding traits:
- First we will 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 Manage Traits option.
- Use the New Trait button to Create a New Trait.
- Give a Trait Type and add Traits to it. Here we are using “Issues” as Trait Type and “lostcard” as Trait.
- Add “lost my card” as the utterance that will trigger this trait. (Do not forget to hit enter after you add the utterance).
- Save and Train the trait.
- From the more option next to the Train button, select Manage Traits option.
- Apply Trait
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.