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[1] 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[2] and $Knowledge.Answer[3] 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.