Creating a Knowledge Base for the Google Dialogflow Chatbot using DITA XML content

Like
Liked

Date:

Read Time: min

A Chatbot is a computer program that simulates human conversation
through voice commands or text chats or both. Chatbot (short for chatterbot), is an
artificial intelligence (AI) feature that can be embedded and used through any major
messaging application. Chatbots helps add convenience for customers, they are
automated programs that interact with customers like a human would, and cost little to
nothing to engage with.

Suppose you have a simple DITA topic that contains pairs of questions and answers placed
as rows in a table:


</span>
 id="frequently_asked_questions">
    Frequently Asked Questions
    
        
            frame="all"rowsep="1"colsep="1"id="table_bkf_4dl_vsb"> cols="2">
                     colname="c1" colnum="1" colwidth="1*"/>
                     colname="c2" colnum="2" colwidth="1*"/>
                    
                            
                                What is Oxygen XML Editor?
                                What is Oxygen XML?
                            
                            
                                Oxygen XML Editor is a great tool.
                            
                        
                        
                            How do I learn DITA?
                            You can read the "Oxygen" user's guide, and the Oxygen XML Blog.
                        
                    

We can use the following XSLT stylesheet to extract the training data as a CSV file from
the XML content:


 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0" xmlns:oxy="abc">
     method="text"/>
     match="/">
        Question,Answer

         select="//tbody/row">
             select="entry[1]">
                
                     test="p">
                         select="p">
                             select="oxy:escapeForCSV(normalize-space(.))"/>,
                                select="oxy:escapeForCSV(normalize-space(string-join(../../entry[2]//text(), '')))"/>

                        
                    
                    
                         select="oxy:escapeForCSV(normalize-space(.))"/>,
                            select="oxy:escapeForCSV(normalize-space(string-join(../entry[2]//text(), '')))"/>

                    
                
            
        
        
     name="oxy:escapeForCSV">
         name="value"/>
         select="replace(replace($value, '"', '""'), ',', '","')"/>
    

Create a transformation scenario using these 2 files. Save the output to a CSV file, as
in the picture below:

Creating a Knowledge Base for the Google Dialogflow Chatbot using DITA XML content

After applying the transformation, the following CSV file should
appear:

What is Oxygen XML Editor?,Oxygen XML Editor is a great tool.
What is Oxygen XML?,Oxygen XML Editor is a great tool.
How do I learn DITA?,You can read the ""Oxygen"" user's guide"," and the Oxygen XML Blog.
Notice:

The structure of the CSV file contains a table with 2 columns, where the first column
represents the question and the second column the answer, separated by a comma. In
general, a line is in the form: “Question, Answer”. One limitation is that each
question can have only one answer. For the same answer to be suitable for several
questions, you can copy it in the columns corresponding to the questions.

Next, follow these steps to use the data from the CSV file in the Google
Dialogflow
chatbot:

  1. Create an account on https://dialogflow.cloud.google.com/.
  2. Create a new agent and complete the required fields:

    Creating a Knowledge Base for the Google Dialogflow Chatbot using DITA XML content

  3. In Settings, enable BETA FEATURES.

    Creating a Knowledge Base for the Google Dialogflow Chatbot using DITA XML content

  4. Go to , enter a name for this knowledge base, and click the SAVE
    button.

    Creating a Knowledge Base for the Google Dialogflow Chatbot using DITA XML content

  5. Use the CSV document for training. For this: Press Create the first
    one
    and complete the fields. Select the Update file
    from your computer
    option and select the desired file. Click the
    CREATE button.

    Creating a Knowledge Base for the Google Dialogflow Chatbot using DITA XML content

    The document will be registered in the knowledge
    base, as in the image below:

    Creating a Knowledge Base for the Google Dialogflow Chatbot using DITA XML content

  6. Convert questions and answers into intents.

    Click the View link from the image above. Check all
    questions that need to be converted to intents. Click the CONVERT
    TO INTENTS
    button.

    Creating a Knowledge Base for the Google Dialogflow Chatbot using DITA XML content

    Now, when you click on Intents, the converted questions should
    appear:

    Creating a Knowledge Base for the Google Dialogflow Chatbot using DITA XML content

  7. Do a simulation. Click , and if the demo feature is disabled, enable it.

    Creating a Knowledge Base for the Google Dialogflow Chatbot using DITA XML content

  8. Integrate the Chatbot in your HTML Content. Go to the
    Dialogflow
    Integrations page, click the Web
    Demo
    integration and you will get an
    HTML element which can be pasted in your
    HTML page. Using a WebHelp customization you can also
    integrate the Chatbot in the footer for each generated HTML page.

This was a basic way to show how a chatbot can be trained with intents and answers by
using a DITA topic to produce a comma-separated value file.

spot_img
spot_img
spot_img
spot_img

Related articles

spot_img
spot_img
spot_img