Twilio's Dialogflow CX Connector is a native telephony integration with Google Dialogflow CX aimed at enterprises with medium to large sized contact centers. Through this integration, Twilio enables customer applications with rich conversational AI experiences.
This guide walks through the process of integrating your Twilio application with your Google Dialogflow CX virtual agent.
These prerequisite steps are required prior to starting the one-click integration:
Check out Google's Dialogflow CX setup documentation on how to start using Dialogflow in Google Cloud.
This one-time manual step is required prior to initiating one-click integration. You will need to provide Twilio's production service account permission to run your Dialogflow agent:
Log in to your Google Cloud console
Select the Google Project in which you configured your Dialogflow CX Agent
Navigate to IAM & Admin > IAM from the left navigation
Click +Grant Access near the top of the page
Under "New Principals", add virtualagent-ccai-prod@dialogflow-prod-env.iam.gserviceaccount.com as a member with the following roles:
Click Save
Before performing the one-click integration with Google Dialogflow, you should be signed into the Twilio Console and logged into the account or sub-account you wish to use with your Dialogflow CX agent integration.
Once you have completed the prerequisite steps, you are ready to use the one-click integration to connect your Twilio Dialogflow CX Connector to your desired Dialogflow CX agent.
Make sure you have granted Twilio access to Google Dialogflow CX. If you have not, you will be redirected back to Google with an authentication error.
After you have completed the steps above in the Google Cloud Console, you'll be taken to the Twilio Console to finish the Dialogflow integration. You will see the Dialogflow CX one-click integration page that has the Dialogflow CX Connector with some pre-populated values:
Complete the Connector configuration by providing the following values:
Once you have configured the Connector with all the details, click Next.
You will then see a "Review Information" screen prompting you to review the Connector configuration. If something is incorrect, you can click on Previous to update the connector setting. If the configuration looks correct, click on Confirm Configuration Details.
You will see a modal pop-up asking for your consent to connect your Twilio Connector to your Dialogflow CX agent.
You can abandon the set-up by clicking on X at the top right corner of the modal pop-up or closing your browser tab.
Click on Agree and connect to Google to finish the integration setup.
Your Dialogflow CX integration is now complete! You can see the completed Connector instance under the Dialogflow CX Connectors in the Twilio Console.
Once you've completed the Dialogflow CX integration with Twilio, you can send a Twilio call to your Dialogflow CX agent in two ways: using the Twilio Studio Connect Virtual Agent Widget, or TwiML <VirtualAgent> noun.
When you complete the integration, Twilio automatically creates a new Studio Flow with a Connect Virtual Agent Widget in it.
You can find this new Flow in your Studio Flows dashboard. It will have the name that you provided for the "Connector Friendly Name" field when configuring the Connector.
The Connect Virtual Agent Widget will be pre-configured with the settings you provided during the Connector setup. You can add additional customizations to the Widget, such as passing in additional parameters that you would like to pass from Twilio to the Dialogflow agent.
See the Connect Virtual Agent Widget documentation to learn more about the available parameters.
You can add other Widgets to the Studio Flow to control what happens before and after the Twilio call. For example, if a call with Dialogflow CX agent ends with a Live Agent Handoff transition, you could add a Connect Call To Widget to connect the caller to a live agent's phone.
Once you're happy with your Flow and you've published all changes, you can connect it to a Twilio Number so people can start interacting with it.
Navigate to the Active Numbers section of the Twilio Console and click on the number you'd like to connect to the Flow. (If you do not have any phone numbers, you can purchase one from the Console.)
After clicking on the number, you will see its configuration menu where you can connect the number to your Studio Flow.
To configure this number to trigger your Studio Flow from an Incoming Call, scroll down to the Voice & Fax section of the configuration menu. Under Configure With, select the dropdown option "Webhook, TwiML Bin, Function, Studio Flow, Proxy Service". Then, under A Call Comes In, select the dropdown option "Studio Flow". You'll see another dropdown menu appear where you can select the Studio Flow you'd like to connect to when a call comes in to this number.
Choose the Flow you'd like to connect the number to, and then press Save to save these changes. Your Flow is now connected to your Twilio number!
You can also use the integration to your Dialogflow CX agent programmatically with the TwiML <VirtualAgent> noun.
New to using TwiML? Check out this overview of what TwiML is and how to use it to handle Twilio Voice calls.
You can use one of Twilio's helper libraries to generate TwiML. Below is an example of code you to connect a call to your Dialogflow CX agent using TwiML:
1const VoiceResponse = require('twilio').twiml.VoiceResponse;23const response = new VoiceResponse();4const connect = response.connect({5action: 'https://myactionurl.com/twiml'6});7connect.virtualAgent({8connectorName: 'project',9statusCallback: 'https://mycallbackurl.com'10});1112console.log(response.toString());
1<?xml version="1.0" encoding="UTF-8"?>2<Response>3<Connect action="https://myactionurl.com/twiml" >4<VirtualAgent connectorName="project" statusCallback="https://mycallbackurl.com"/>5</Connect>6</Response>
See the <VirtualAgent> documentation for more information about how to use this TwiML noun.
When you configure the Dialogflow CX Connector within Twilio, you can specify a welcome intent. When Twilio connects a call to your Dialogflow CX agent, this welcome intent will trigger (for example, saying "Hello" to the caller before they start speaking). You can use the Dialogflow CX agent's default welcome intent called "WELCOME" and configure it in your Dialogflow CX Connector. You can edit this default welcome intent within Dialogflow.
You can pass custom parameters to the Dialogflow CX agent either within the Connect Virtual Agent Studio Widget or from the <VirtualAgent> TwiML noun. You can also configure parameters in your agent's setting in the Google Cloud console.
A Dialogflow CX session can be paused and resumed, allowing you to seamlessly pass a call back and forth between Dialogflow and Twilio while keeping the session context intact. As a result, the caller doesn't need to repeat themselves or start from the beginning when the call is passed back to Dialogflow.
You can use pause and resume a session either within the Connect Virtual Agent Studio Widget or from the <VirtualAgent> TwiML noun. A session can be paused and resumed anytime within its 30 minute TTL (time-to-live) window.
In your Dialogflow CX console, you can set the transition target for an intent to "End" to indicate that the conversation with the agent should end after a particular virtual agent response. For more information, check out the Google docs.
If you are using TwiML and the virtual agent ends the conversation because an intent matches the "end of the conversation" intent indicating the call completed successfully, the VirtualAgentStatus field in the request to your action URL is set to completed
. This will execute the next TwiML in your application by using the action parameter, or the next TwiML step <Connect>
verb.
If you are using Connect Virtual Agent Studio Widget and the virtual agent ends the conversation because an intent matches the "end of the conversation" intent, the Completed transition state is triggered.
If the virtual agent was not able to fulfill the call, Dialogflow CX now allows you to escalate it to a live human agent. Twilio's support for status callbacks allows us to pass requests containing information on call status, intents triggered, sentiment scores, agent-caller text, and more to your application URL, which would enable you to write custom code against it and build a live agent hand-off experience in your own contact center application.
For more details on how to enable the live agent handoff inside the agent fulfillment within your Dialogflow CX console, check out Google docs.
If you are using TwiML and the Dialogflow CX agent returns a live agent handoff response indicating the call needs to be escalated to a human agent,the VirtualAgentStatus field in the request to your action URL is set to live-agent-handoff
.
If you are using Connect Virtual Agent Studio widget and the Dialogflow CX agent returns a live agent handoff response indicating the call needs to be escalated to a human agent, the Live Agent Handoff transition state is triggered..
You can enable Barge-in within Dialogflow CX agents, which allows callers to interrupt the virtual agent anytime. If barge-in is enabled and a caller starts speaking in the middle of the agent's response, Dialogflow will stop sending audio to the caller and process the caller's next input.
For more details on how to turn on the barge-in feature, check out these Google docs.
In addition to speech input, an end user can provide a DTMF (Dual-tone multi-frequency signaling) input through their telephone keypad. You can configure DTMF for a parameter in your Google Dialogflow CX console. Once enabled, your customer can use their telephone keypad to provide parameter values for an agent using a telephony integration.
We are looking forward to hearing from you! Reach out to your Twilio Account Manager or contact our Sales Team. We're looking for feedback on: