Skip to content

Dialogflow node

Guidone edited this page Nov 13, 2018 · 11 revisions

Dialogflow.com is a chatbot / AI platform that allows to easily train a bot in order to detect the user intent and extract relevant data.

For a complete tutorial about Dialogflow.com give a look here. The Dialogflow.com node sends the text of the incoming message to the Dialogflow.com servers, then:

  • if no intent is detected, then the incoming message is redirected to the second output
  • if an intent is detected, then it's stored in the context variable topic (or a different variable) and a key/value hash of all relevant information extracted is sent to the first output along with other informations.

Dialogflow.com is able to create a full featured chatbot, nevertheless it can be used just for the NLP capabilities and to detetect/classify user's sentences.

For example, create a Drinks entity with these values

martini rosso
mojito
moscow mule
old fashion

Then create an intent want-drink and train with these phrases

I want a martini rosso
May I have a martini
Can I have a moscow mule
May I have a mojito

and verify that the words "martini rosso", "martini", "moscow mule" and "mojito" are already marked with the entity Drinks, if not, it's possible to mark portions of the sentences with the appropriate entity. Then prepare a flow like this

Dialogflow

If the user says "I want a martini", the topic will be switched to "want-drink" and the output will be

{
  payload: {
    intent: 'want-drink',
    answer: 'I am the answer',
    variables: { 
      Drinks: 'martini rosso'
    }
}

Generally after a Dialogflow.com node it's useful a Rules node to test the topic variable and redirect the flow based on user's intent.

If Dialogflow is configured to provide an answer (payload.answer') then is possible to connect a Message node` directly to the first output to send the message back to the user.

With Dialogflow.com it's possible to define some answers for intents, if one of these is available it will be included in the payload.

To configure the connection for Dialogflow.com follow this steps:

  1. Open the agent configuration (the cog in the left column) and switch to "V2 API" and click "Save" Step 1
  2. Grab the Project ID and add a service account for the Google Cloud Platform (click on the "+"), wait until the Service Account appears and grab it Step 2
  3. Click on the Service Account, you will be redirected to the Google Cloud Platform service account, click on the three dots of the last Service Account and generate a key Step 3
  4. Copy and paste the downloaded .JSON file in "Private Key" field in the Dialogflow.com connection in Node-RED Step 4

Telegram Facebook Slack Smooch

Clone this wiki locally