Configure

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

  • 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 Dialogflow agent

The first thing to do is to create an account with Dialogflow. Dialogflow is built on the Google Cloud Platform, which 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 up to Dialogflow here: https://dialogflow.com.

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.

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, find the Google Project associated with the agent, and click on the Service Account link. This will open up a list of Service Accounts for your Dialogflow Agent / Google Project.
  3. Find the service corresponding Service Account (there might only be one) and from the Actions menu, click Create key.
  4. Create a JSON key. This should download a file to your computer
  5. In CiviCRM, in the Dialogflow > Settings page, paste the contents of the file into the Private key field.

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, 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.