This document provides a step-by-step guide for integrating Google Dialogflow with the CxPerium solution. By following these steps, you can utilize Dialogflow in the CxPerium NLP flow and enhance your chatbot’s natural language processing capabilities.
1. Logging into Google Dialogflow and Creating an Agent
- Log into Dialogflow
- Go to Dialogflow Console.
- Sign in with your Google account.
- Create an Agent
- If logging in for the first time, click the “Create Agent” button in the left menu.
- Enter a name for your agent. In this example, we will use “DemoAgent.”
- Select the default language for your agent. In our example, we choose “Turkish.”
- Click the “Create” button to create the agent.
- Access Agent Settings
- After creating the agent, click the “Settings” button next to it to open the settings page.
- When an agent is created in Dialogflow, a Google Cloud project is automatically generated. You can view this project under the “Google Project” section.
- Google Cloud Project Settings
- Click the link next to “Project ID.”
- In the Google Cloud interface, navigate to “Project Info” and click “Go to project settings.”
2. Creating a Service Account
- Access the Service Accounts Menu
- In the Google Cloud interface, use the left menu to navigate to “Service Accounts.”
- Click the “+Create Service Account” button.
- Enter Service Account Information
- Fill in the required details and ensure “Owner” is selected as the role.
- Click “Done” to complete the Service Account creation process.
- Generate a Key
- After creating the service account, click on its link.
- In the opened screen, go to the “Keys” tab.
- Click “Add Key” > “Create New Key.”
- Ensure “JSON” format is selected.
- A JSON file will be downloaded. Keep this file in a secure location.
3. CxPerium and Project Integration
- Integrate with CxPerium
- In your CxPerium account, navigate to Assistant > Configuration.
- Click the edit button next to the “DialogFlowConfig” field.
- Fill in the following details:
- CredentialsFilePath: Enter the name of the downloaded JSON file (e.g.,
demoagent-xxxxx.json
). - ProjectId: The
project_id
field from the downloaded JSON file. - IsEnable: Set to
True
.
- CredentialsFilePath: Enter the name of the downloaded JSON file (e.g.,
- Project Configuration
- Place the downloaded JSON file in the root directory of your project.
- Set the file property “Copy to Output Directory” to “Copy Always” and build the project.
4. Testing and Validation
- Create an intent in Dialogflow and add a text response.
- Run your project and send the training phrase associated with the intent via WhatsApp to your sandbox number.
- If configured correctly, you should see the expected response.
5. Matching Intent with Dialog
- Mapping Intent to Project Dialog
- In the Intent settings, navigate to the “Responses” block and click “Add Responses.”
- Select “Custom Payload.”
- Enter the mapping details in the Custom Payload field. Example
{
“intent”: “QSoft.CxPerium.Assistant.Dialogs.DialogFlowDemoDialog”
}
This maps the intent to the DialogFlowDemoDialog class in your project.
Defining the Dialog Class
- The DialogFlowDemoDialog class should be defined as follows:
using QSoft.CxPerium.Dialogs.WhatsApp;
namespace QSoft.CxPerium.Assistant.Dialogs
{
public class DialogFlowDemoDialog : BaseWhatsAppDialog, IWhatsAppDialog
{
public void RunDialog()
{
this.Messages.SendMessage(“This dialog is mapped from DialogFlow”);
}
}
}
Capturing Parameters
Parameters returned from Dialogflow can be accessed using the Parameters object in the class:
using QSoft.CxPerium.Dialogs.WhatsApp;
namespace QSoft.CxPerium.Assistant.Dialogs
{
public class DialogFlowDemoDialog : BaseWhatsAppDialog, IWhatsAppDialog
{
public void RunDialog()
{
var country = this.Parameters[“country”];
this.Messages.SendMessage($”Country parameter: {country}”);
}
}
}
After completing these steps, you will be ready to utilize the advanced features of CxPerium and Dialogflow integration.