- Prerequisites
- Step 1 — Enable the Dialogflow CX API in GCP
- Step 2 — Create a service account and download the JSON key
- Step 3 — Note your Dialogflow CX agent details
- Step 4 — Connect in Baat
- Step 5 — Test the connection
- How Baat routes messages to Dialogflow CX
- Routing: which messages go to Dialogflow?
- Troubleshooting
- Disconnecting the integration
This guide walks you through connecting a Google Dialogflow CX agent to your Baat workspace. Once connected, every incoming WhatsApp message is forwarded to your Dialogflow CX agent for intent detection and response generation — no separate webhook wiring required on your end.
Prerequisites #
- A Google Cloud project with the Dialogflow CX API enabled
- A Dialogflow CX agent already created in that project (see below if you haven’t created one yet)
- A GCP service account with the
Dialogflow API Clientrole and a downloaded JSON key - Your agent’s Project ID, Agent ID, and Region handy
Step 1 — Enable the Dialogflow CX API in GCP #
- Open the Google Cloud Console and select your project.
- Go to APIs & Services → Library.
- Search for Dialogflow API and click Enable.
Step 2 — Create a service account and download the JSON key #
- In GCP Console go to IAM & Admin → Service Accounts.
- Click Create Service Account. Give it a descriptive name such as
baat-dialogflow. - On the “Grant access” step, assign the role Dialogflow API Client (
roles/dialogflow.client). This is the minimum role needed — it allows session creation anddetectIntentcalls but nothing destructive. - Click Done.
- Find the new service account in the list, click its name, then go to the Keys tab.
- Click Add Key → Create new key → JSON. A
.jsonfile downloads to your computer.
Step 3 — Note your Dialogflow CX agent details #
You need three values from the Dialogflow CX console:
| Value | Where to find it | Example |
|---|---|---|
| Project ID | GCP Console → top of the page next to the project name, or in the JSON key file as "project_id" |
my-company-prod |
| Agent ID | Dialogflow CX console → select your agent → Agent Settings → the UUID in the page URL or under “Agent ID” | a1b2c3d4-e5f6-... |
| Region | Shown when you created the agent (e.g. us-central1, asia-south1). Also visible in the agent URL: dialogflow.cloud.google.com/#/.../asia-south1/... |
us-central1 |
asia-south1 (Mumbai) when creating the Dialogflow CX agent. This keeps round-trip latency under ~80 ms versus 200–300 ms for us-central1. The region cannot be changed after the agent is created.
Step 4 — Connect in Baat #
- In your Baat dashboard, go to Settings → Integrations → Dialogflow CX.
- Fill in the following fields:
- GCP Project ID — the project that owns the agent
- Agent ID — the UUID of your Dialogflow CX agent
- Region — must match the region the agent was created in
- Service Account JSON — paste the full contents of the JSON key file you downloaded in Step 2
- Click Connect.
Baat validates the credentials by making a test detectIntent call. If the credentials are valid and the agent is reachable you will see a green Connected status. If validation fails, a descriptive error is shown (see Troubleshooting below).
Step 5 — Test the connection #
Send a WhatsApp message to your connected number from a test phone. Watch the Baat Shared Inbox — the incoming message should appear, and within a second or two the Dialogflow CX response should be delivered back to the test phone.
You can also use the Test button on the Integrations page. Enter any text and Baat will call detectIntent and show you the raw response from Dialogflow CX.
How Baat routes messages to Dialogflow CX #
Once connected, the flow for every inbound WhatsApp message is:
- WhatsApp delivers the message to Baat via the Cloud API webhook.
- Baat calls the Dialogflow CX
detectIntentREST API using the credentials you provided. - The session ID sent to Dialogflow is derived from the customer’s WhatsApp phone number — so each customer gets a persistent Dialogflow session, and context carries across messages.
- Dialogflow CX returns fulfillment messages (text, custom payload, or a mix).
- Baat delivers the responses to WhatsApp in order.
Text responses from Dialogflow are sent as plain WhatsApp text messages. To send interactive messages (buttons, lists, Flows), use a Custom Payload response in Dialogflow CX with the
BAAT_WAC_APIwrapper — see Sending Interactive WhatsApp Messages from Dialogflow CX.
Routing: which messages go to Dialogflow? #
By default, all messages on your WhatsApp number are forwarded to Dialogflow CX once the integration is active. You can optionally configure routing rules in Baat to send only certain conversations to Dialogflow (for example, exclude conversations that are already assigned to a human agent). See Settings → Integrations → Dialogflow CX → Routing for options.
Troubleshooting #
| Error / symptom | Likely cause | Fix |
|---|---|---|
| Invalid credentials on Connect | Service account JSON is malformed, or the account has been deleted | Re-download the JSON key from GCP and paste the fresh copy |
| Permission denied on Connect | Service account is missing the Dialogflow API Client role |
In GCP IAM, add roles/dialogflow.client to the service account |
| Agent not found | Project ID, Agent ID, or Region does not match the agent in GCP | Open Dialogflow CX console, copy all three values again carefully — the Agent ID is a UUID, not the display name |
| Messages arrive in Baat but no reply is sent | Dialogflow CX agent has no matched intent for the test input, or the default welcome intent is not enabled | Open the Dialogflow CX console, go to Test Agent, send the same message, and check what intent (if any) fires. Add a Default Fallback intent with a response if missing. |
| Dialogflow replies but WhatsApp shows nothing | Custom payload JSON is malformed | Check the Baat activity log for the conversation. If the payload failed validation you will see an error alongside the attempted response. Validate your JSON against the interactive messages article. |
| High latency (>2 s responses) | Agent region is us-central1 but users are in India |
Unfortunately region cannot be changed on an existing agent — create a new agent in asia-south1 and migrate your intents via the Dialogflow CX export/import feature |
Disconnecting the integration #
Go to Settings → Integrations → Dialogflow CX and click Disconnect. Baat immediately stops forwarding messages to Dialogflow. Existing conversations in the inbox are unaffected. You can reconnect at any time by filling in the credentials again.