A reader asked me this question recently:
Do you think the beta knowledge base within Dialogflow is useful? Or are their better ways in to implement a FAQ bot with Dialogflow?
There are two types of FAQ chatbots you can create in Dialogflow.
1 You can use the knowledge connector feature (beta)
2 You can use regular intents
Knowledge Connector example
I recently created a knowledge connector bot and integrated it with Telegram.
This is what it looks like:
A few things to note:
- I used Telegram because of the ease of integration. You can use any channel integration and get similar results.
- There are multiple results per user query. In the screenshot above, there are 3 results
- In Dialogflow, each result is just a link to an article on my website. Telegram embellishes it by pulling in the title and featured image of the post.
It is quite straightforward to create such a bot if you are the admin of a WordPress website.
How to create a Knowledge Connector bot based on your WordPress website
These are the steps to create a knowledge connector bot in Dialogflow.
Install the Export all URLs plugin
First install export all URLs plugin.
Download the URLs in CSV format
Inside your WordPress admin, download the URLs in CSV format.
You need to do a couple of things to prepare the CSV file for importing into Dialogflow.
a) delete the third colum (categories)
b) delete the top header row as it is not required
Enable beta features
Now, inside Dialogflow, create a new agent and make sure you have enabled Beta features.
Set knowledge results preference to max
In the Knowledge section, set the knowledge results preference to max.
Create Knowledge Base
Create a new knowledge base and give it a suitable name.
I have named mine KB.
Create Knowledge Document
Inside your knowledge based, create a new knowledge document.
Upload exported CSV file
In the popup dialog, fill in the information as described in the image.
Document name: choose a suitable name. I have called mine exported_urls.
Knowledge type: FAQ
Mime type: text/csv
Data source: Upload file from computer
Now upload the CSV file that we created. Make sure the CSV file doesn't have the header row or a third column. Dialogflow expects a two column CSV file where the first column is the question and the second column is the answer.
In our case, the article title will be the question (column 1) and the article URL will be the answer (column 2).
When the upload completes, you will see that the new knowledge document has been added to the knowledge base.
Use knowledge answers in the response blocks
You will see that the new knowledge document looks quite a bit like a Dialogflow intent.
In the response blocks, use the knowledge answers. $Knowledge.Answer means the first answer from the knowledge base for a given query.
So add two more text response blocks and change the responses to $Knowledge.Answer and $Knowledge.Answer respectively, meaning we want the second and third answer for the given query.
Note: if there are fewer than 3 answers, Dialogflow will simply send whatever responses are available to the integration channel.
Integrate with Telegram
Now use the 1-click integration with Telegram and follow the integration steps from this article.
Intent based FAQ bot example
I created a similar FAQ bot (based on my website contents) using intents.
Here is what it looks like:
Notice that there is only a single response per user query.
How to create an intent based FAQ bot for your WordPress website
The steps for creating an intent based FAQ bot also starts with the Export all URLs plugin.
You need to use my online tool BotFlo to be able to do this. I explain the steps in this article.
Knowledge Connectors Pros
Now that we have something to compare it with, we can take a look at the pros and cons of the Dialogflow Knowledge Connector feature.
There are a couple of big pros with using the knowledge connector
- you can get the top N intent matches. So if you need your FAQ bot to behave a little like a search engine, the knowledge connector will help
- you can build an FAQ chatbot based on your website content with just a few clicks (at least in theory)
Knowledge Connector Cons
However, there are quite a few cons with using the knowledge connector for an FAQ bot, and you should know about them before using the feature.
You cannot add additional training phrases
You cannot add more training phrases to get better matches.
For example, suppose someone is searching for "dialogflow pass parameters between intents"
I have an article which goes over this in detail, but the keywords are not mentioned in the title anywhere.
Let us see what we get from the knowledge based FAQ bot:
And this is the answer from the intent based FAQ bot:
Neither of the answers are very relevant.
However, I can add it as a training phrase in my intent based FAQ bot intent.
Let us try the same query again with the intent based FAQ bot.
Note that in the knowledge based bot, we cannot edit anything inside the knowledge document. It is read only.
You cannot add entities
As you look at the knowledge document, you also find an important feature missing. You cannot add entities into a knowledge document.
Dialogflow used to be called API.AI initially. Suppose someone used API.AI in their search term, we can handle this by creating an entity which can handle the words dialogflow as well as API.AI.
In fact, I have seen people use all of the following when trying to type Dialogflow:
- dialogflow (correct)
- api.ai (correct)
- api ai (ok)
- dialogue flow
- dialog bot
- dialog chat
You could turn these common misspellings into an entity, and make your intent based FAQ bot more powerful. This isn't possible in the knowledge based FAQ bot.
You cannot use contexts
FAQ bots don't have a lot of need for followup intents and such.
However, sometimes they are necessary for certain answers. In those situations, the knowledge connector based bot will not help.
On the other hand, you can easily add contexts into any intent in an intent-based FAQ bot. I have seen clients use followup intents to ask if the answer was useful. And if the user said no, they would be automatically redirected to live chat.
You cannot use negative training phrases
Negative training phrases allow you to trigger the fallback intent for phrases which are very similar to an intent's training phrase but actually means something very different.
You cannot easily convert user utterance into training phrase
You might know that you can convert a user utterance into an intent training phrase with a single click in an intent based FAQ bot. This isn't possible in a knowledge based FAQ bot. A big benefit of using Dialogflow and other AI bot frameworks is that they "learn" from these user utterances and get better with more data. This benefit is lost in knowledge connector based bots.
In summary, I feel that the knowledge connector based FAQ bots have the same issue as other cool Dialogflow features such as slot filling - you can get started quickly, but you cannot maintain the bot very well in the long run.
- Dialogflow Messenger Quiz Bot
- Dialogflow Zobot: Selection Triggers the next intent
- Integrating Dialogflow with Zoho live chat
- 5 things you cannot do using the Dialogflow Messenger integration
- Dialogflow Architecture
- Dialogflow Python webhook tutorial
- Dialogflow training
- Dialogflow vs Lex vs LUIS vs Watson vs Chatfuel
- Convert your WordPress website into a Dialogflow FAQ chatbot
- Dialogflow Messenger Interactive Learning Bot