Dialogflow - Knowledge Base



A knowledge base is a collection of knowledge documents that are uploaded to Dialogflow. Your knowledge documents offer material that will be useful in interactions with end users. When trying to answer to an end-user phrase, various Dialogflow features check up knowledge bases. This chapter covers how to set up and handle knowledge bases.

A knowledge Base is a collection of knowledge documents that we give to Dialogflow. The knowledge document offers information that can be useful in end-user conversations. When looking for for end-user expression replies, a few Dialogflow features use the concept of knowledge bases.

How to Create a Knowledge Base?

There are several steps for creating a knowledge base −

  • First, navigate to the Dialog Console.

  • Then select the agent.

  • Next you have to click on the knowledge option on the left side of the menu bar.

  • Then, click on Create Knowledge Base.

    Dialogflow Knowledge base
  • Enter the name of the knowledge base and then click the Save button.

    Dialogflow Knowledge base

Add the Document to the Knowledge Base

There are currently no documents in the new knowledge base which we have created in the above steps and our knowledge base name is MyKB. So, we have to include the document in the knowledge base as per our requirements.

Adding the document to the knowledge base requires several steps −

  • First, navigate to the Dialogflow console.

  • Then select the agent.

  • Next, click the Knowledge option on the left side of the menu bar.

  • Then, select the knowledge base name to which we want to add the document.

  • Select the option "Create the First One or New Document."

    Dialogflow Knowledge base
  • Then input the document's name.

  • Now pick text/html as the Mime Type.

  • Next, for the Knowledge type, we must select the option FAQ.

  • Next, select the Data Source. In the URL column, enter https://cloud.google.com/storage/docs/faq.

  • Then Enable Automatic Reload.

  • At the end you have to click the CREATE button.

    Dialogflow Knowledge base

Manage Knowledge Documents

There are three primary points on which we can manage knowledge documents −

  • Update knowledge document Content

  • List knowledge documents

  • Delete knowledge documents

Update knowledge document content

If you update the content referenced by a knowledge document, it can fail to refresh automatically. Only if you define a public URL and mark the Enable Automatic Reload option for the document will your content be automatically refreshed.

To explicitly refresh Cloud Storage or public URL document content you can use the reload method of the Document type.

To manually refresh uploaded raw content, you should use the Document type's delete and create methods to re-create the document.

List knowledge documents

You can create a list of all knowledge documents in your knowledge base. To use the API, call the List method for the Document type.

Delete knowledge documents

You can delete knowledge documents from your knowledge base. To access the API, use the delete method for the Document type. If you do not have the document ID, simply list the documents as mentioned above.

Supported content

The following categories of knowledge documents are supported −

  • FAQ: The document content includes question and answer pairs in either HTML or CSV format. Typical FAQ HTML formats are parsed properly, but odd formats may fail to parse. CSV must include questions in the first column, responses in the second, and no header. Because of the explicit format, they are always correctly parsed.

  • Extractive QA: It involves extracting unstructured text from documents and using it to answer questions.

The table below lists the supported MIME types based on Knowledge Type and Source.

Knowledge Type \ Source Uploaded file (Document.content) (NOT recommended) Uploaded file (Document.raw_content) (recommended) File from Cloud Storage (Document.contentUri) File from public URL (Document.contentUri)
FAQ text/csv text/csv text/csv text/html
Extractive QA text/plain, text/html text/plain, text/html, application/pdf text/plain, text/html, application/pdf N/A
Advertisements