Skip to content

Configure

Before creating intents, you'll need to do a bit of configuration of the extension. In summary, you'll need to:

  • Create a Google Cloud account
  • Create a Dialogflow agent
  • Connect CiviCRM to Dialogflow
  • Add a webhook to your Dialogflow agent so it can talk to CiviCRM
  • Integrate one or more chat services (WhatsApp, Facebook, Twilio, SMS etc.)

Create a Google Cloud account

Dialogflow is built on the Google Cloud Platform, so you'll need an account to get started.

Sign up at Google Cloud

Note that you will need to enter your credit card details in order to create an account.

Create a Dialogflow agent

The first thing to do is to create an account with Dialogflow. Google currently offers two editions: Dialogflow ES (essentials) and Dialogflow CX. We are using Dialogflow ES here.

Note

The Google Cloud Platform can be a bit difficult to navigate. We've tried to make this initial configuration as simple as possible but if anything is unclear, please create an issue and we'll improve the documentation.

Sign in to the Dialogflow console.

Then create a new agent in your account. The name of your agent isn't important. Naming it after your organisation is probably a good idea.

Your Dialogflow agent has a one to one relationship with a Google Cloud Project of the same name.

Note

Find more details in the Dialogflow documentation.

Connect CiviCRM to Dialogflow

You need to connect CiviCRM to Dialogflow so it can to talk to your agent.

To do this, you will download a JSON file containing the private key of the Service Account linked to your Dialogflow agent and add it to CiviCRM.

  1. In Dialogflow, find your agent and click on the Settings cog.
  2. In the General tab, click on the Google Project associated with the agent.
  3. From the Google Project go to IAM & Admin > Service Account. This will open up a list of Service Accounts for your Dialogflow Agent / Google Project.
  4. Find the service corresponding Service Account (there might only be one) and from the Actions menu, click Manage keys.
  5. Create a JSON key. This should download a file to your computer.
  6. In CiviCRM, in the Dialogflow > Settings page, paste the contents of the file into the Private key field.

If there are no Service Accounts listed, you will need to create one. Follow the steps in the Quickstart: Setup guide. Set the Service account name to "Dialogflow integration" or similar. Create and download a key as above.

Add a CiviCRM webhook to your Dialogflow agent

A webhook is a publicly accessible URL that Dialogflow deliver messages to when it wants CiviCRM to fulfil a request from a user. You need to add your webhook URL to Dialogflow so it knows where to send its fulfilment requests.

Because the URL is publicly accessible, you also need to add a secret to Dialogflow that will be sent along with all requests so we know that they are coming from Dialogflow.

Add the webhook URL

  1. In CiviCRM, in the Dialogflow > Settings find and copy the Webhook URL.
  2. In the Dialogflow dashboard for your agent, click on Fulfilment and enable the Webhook.
  3. Enter the Webhook URL in the URL field

Add the webhook key

  1. Below the URL field, you should see a Headers section. Add a Header Key called 'Dialogflow-Webhook-Key'
  2. Back in CiviCRM's Dialogflow > Settings page, find and copy the Webhook key.
  3. Paste the webhook key into the Header Value field.

Integrate conversation services

Dialogflow provides out of the box integrations with a number of third party conversation services like Facebook Messenger, Slack, Skype, WhatsApp (via Twilio) and so on.

The details of how to connect to each of the specific services is outside of the scope of this documentation, but they are all broadly similar. You typically sign up for a developer account with the conversation service, and connect it to Dialogflow by copying and pasting credentials between the accounts. The Dialogflow interface should guide you here.

In the Dialogflow dashboard for your agent, click on Integrations, select the service you want to integrate with, and follow the on screen instructions.

More details in the Dialogflow documentation.