Configure Google Dialogflow for the Chatbot generator

Official Content

Here we introduce the steps to use the Chatbot Generator with Dialogflow.
After the setup in Google Clouds, you need to create an Agent in DialogfLow, where GeneXus will create your chatbot for this provider (create and update the intents, entities, and the dialog itself).

The following is a summary of the steps that should be followed:

Create a project in Google Cloud

Go to this link. Select the list of projects, and create a New Project.
Then, you'll have something similar to this:

image_201861917240_1_png

Enable the "Dialogflow API" service in your project

In the project's Dashboard, go through APIs & Services -> Library

EnableDialogFlowGoogleProject

Then, in the search bar, search for Dialogflow. Select it, and click the Enable button.

DialogFlowAPIEnabled

Get the credentials for accessing the API

Now you have to get the Client ID and Client Secret for accessing the Dialogflow API - which is based on OAuth 2.0 authentication.

In the API&Services menu, select Credentials. Next, in the Credentials screen go through "OAuth consent screen" tab, where you have to enter a Product Name.

OauthConsentScreenDialogFlow

After that, still in the Credentials screen, select "Create Credentials," "OAuth client ID."

OauthClientIdDialogFlow

When it prompts for an Application type, select Other.
Finally, you'll get your Client ID and Client Secret. You'll need it in the steps that follow.

Important: make sure that you copy the credentials that you've just created. The Web application credentials do not work for this, because they require the configuration of a valid redirect URI. You'll get an error HTTP 400 invalid redirect URI if you try to use them.

image_2018619204012_1_png

image_2018619203341_1_png

Create an Agent in Dialogflow that is related to the Google Cloud project

Go to the Dialogflow web site to create a new Agent. Consider selecting the correct Project (defined in the previous step) before pressing the create Agent button. Note that you can create only one Agent per project.

CreateDialogFlowAgent

Configure the GeneXus Chabot instance for using Dialogflow

Edit the Conversational Flows instance and configure the NLP Provider property, Dialogflow Agent property, Google Cloud Project property, Client Id and Client Secret properties.

To continue, save or execute "Generate Chatbot." At this moment, GeneXus will try to synchronize our instance with the agent created in Dialogflow.

First of all, we will notice that the first time it will open a browser instance in which we will be required to log in using our Google account (since it uses OAuth 2.0).

DialogFLowAccountPermissions

The credentials will be stored in your develpment machine so you won't be asked again to authorize the app. They're stored in a file located under <Users>/<username>/AppData/Roaming/Folder/File and are used for the connection to Google DialogFlow from the IDE.

Where 

Folder = DialogflowToken$KBName$$InstanceName$Chatbot
File = Google.Apis.Auth.OAuth2.Responses.TokenResponse-user

Note:

When you do the first build, the browser will open again to ask yout to allow access to the application. This is for setting the <InstanceName>.config file connection credentials.

After starting a new session, the generation or synchronization continues as in other providers.

GeneXus is responsible for refreshing the authentication token so that it is not necessary to log in again (until the refresh token expires). It knows how to refresh the Access Token automatically.

 

Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.