Create an Agent (Natural Language Understanding Models) at Dialogflow.
There is already a Default Welcome Intent, but a new intent can be created.
Intents are used to categorize the user's interactions and they have training phrases that are examples of what a user might say to the agent (possible utterances). By saving the training phrases in the Intent, the model is automatically trained.
Go to the Google Cloud Platform's dashboard and select your project to view a list of the APIs being used under your account under APIs overview.
Select the API – Dialogflow API, in this case – for which you pretend to create the authentication credentials.
In the Sidebar, click on Credentials.
You will be redirected to the credentials dashboard.
In that screen click on the Create Credentials dropdown
Select Service account key.
Fill the basic information in the Service account details and in the Grant this service account access to project steps, and choose JSON as the key type from the dropdown list in the last step.
When you click on Create a JSON file will be generated
Import this JSON file as a resource to Service Studio in the application where the connector will be used and change the Deploy Action option to Deploy to target directory.
The path for this file will be used when calling the connector for the AuthFilePath parameter of the connector.
This connector has a server action called DetectIntent. This action processes a natural language query and returns structured, actionable data as a result. For instance, it may receive an utterance sent by the user and will return a data structure as the Response. This data structure has two attributes: ResponseId and QueryResult.
To call the DetectIntent action in your application you must fill its five input parameters:
ProjectId - The project identifier of the agent created in the Dialogflow console.
SessionId - The name of the session the query is sent to. It's up to the API caller to choose an appropriate session ID. It can be a random number or some type of user identifier (preferably hashed). The length of the session ID must not exceed 36 characters. If the text sent to the agent needs context from a previous query, use the same SessionId.
QueryText - The UTF-8 encoded natural language text to be processed. Text length must not exceed 256 characters.
LanguageCode - The language of this conversational query. Note that queries in the same session do not necessarily need to specify the same language.
AuthFilePath - The path for the JSON file downloaded from the Google Cloud Console with the authentication credentials. The JSON file must be added to the application as a resource with the 'Deploy Action' option set as 'Deploy to Target Directory'. The path for this file must be sent in the following format:'/Espace_Name/File_Name.json'
The webhook service is where you will create your logic to handle the answers to the messages sent by your application users that are redirected to the webhook service from the Dialogflow Connector. It is an exposed POST REST API with an action called ‘Intent’. Inside that action you must call the ‘DetectIntent’ action from the connector and create your own logic to answer to the detected intent.
The URL from the exposed REST method must be provided in the Dialogflow console under the Fulfillment section, as it is shown below: