Skip to content

Tutorial: Use Dialogflow NLP for Conversations

In order to process natural language entered by the user a NLP/NLU provider needs to be added.

For this guide we will use Dialogflow. They offer a free service.

https://www.dialogflow.com

We want to allow the user to ask for the location of the swimming pool and answer with useful information.

  • sign up for an account and log into Dialogflow's console
  • click on "create new agent"

Fill out infos as seen on screenshot below:

  • click "create"
  • select "Entities" from left list

  • click "create entity"

Fill out:

"Entity name" : location

In first row enter: pool and as synonym enter: swimming pool

  • click "save"
  • select "intents" from left menu
  • click "create intent"

Fill out:

"Intent name": where

  • click on "add training phrases"

Add the following training phrases:

Where is the pool?

Where can I find the pool?

I want to go to the pool?

What's the location of the pool?

  • click "save"

In the upper right corner you can test your training. Type "Where can one find the pool?" You should see this response:

That's what an NLP does. It extracts intention and the object of the intention (in Dialogflow's terms "entity" ) from the user's text input.

For our demo we stop here and open Dialogflow's API:

  • click the preferences wheel

In Google project section click on your Service Account:

Look up the same email address in the table displayed on next page:

  • click on the three dots on right side in this row
  • choose "Create key"
  • choose "JSON" and click "create"

A json file with all your credentials is downloaded.

Open configuration page in DialogShift's member area:

Within the framework attribute add the following structure:

"nlpConfig": {
            "provider": "dialogflowV2",
            "credentials": { paste from google json file here }
        }

(don't forget to add a comma , to the end of the previously last line)

Copy and paste the contents of your downloaded JSON file into credentials

Connect conversational element with the intent to find the location of the pool

In DialogShift's CMS create new element:

{
    "elementCode": "location-pool",
    "elementType": "text",
    "txt": {
        "en": "The pool can be found on the roof-top.",
        "de": "Ipsum lorem"
    },
    "image": "https://c1.staticflickr.com/5/4025/4626080855_23daa24b74_b.jpg",
    "intent": [
        {
            "intentCode": "where",
            "parameterCode": "pool"
        }
    ]
}

We used the same intent and parameter we just created in Dialogflow.

Try out your bot

Type "Where in God's name can I find the swimming pool?" or lazily "where pool" or simply "pool" and voila :)

Remark:

The setup of NLP with Google's Dialogflow is not trivial, but from now on you can add entities and train intents quite efficiently using Dialogflow's frontend.

Good advice is to add all entities in a first step and let them be auto-detected during the addition of training sentences.