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 +Add near the top of the page
- Under "New Principals", add email@example.com as a member with the following roles:
- Dialogflow API Reader
- Dialogflow API Client
- Click Save
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.
- Log in to your Google Dialogflow CX cloud console and click Manage on the left navigation bar
- Select Integrations from the Manage menu
- Under the One-click Telephony options, select Twilio
- In the modal pop-up, give your integration a new name, select the Environment and Language for your Dialogflow CX agent, and click Add. This will start the integration process and launch the Twilio Console page.
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:
- Connector Friendly Name: the unique name of the Connector. You will use this name to identify the connector in Twilio Studio or using TwiML.
- Give the Connector a friendly name, say, “Dialogflow_CX_Test1”
- Status Callback URL (optional): the URL to your endpoint where you want Twilio to send requests on call status, intents triggered, sentiment scores, agent-caller text, etc.
- For the purpose of this tutorial, we can link it to Twilio Functions
- Welcome Intent Friendly Name: set this parameter if you want the bot to start the conversation with the caller with a greeting.
- If you do not have a custom welcome intent, you can use the system generated default welcome intent called WELCOME. This default intent can be edited as desired within the Dialogflow CX agent configuration.
- Bot Voice: indicates the Text-To-Speech voice to use when synthesizing audio responses from the bot. Check out Google’s documentation on the list of voices currently supported for Dialogflow.
- Sentiment Analysis: when set to ON, Dialogflow will perform sentiment analysis on the end user input and sentiment scores will be relayed in the status callbacks.
- Sentiment analysis availability depends on the language support in Dialogflow CX. See a list of languages with supported sentiment analysis here.
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.
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:
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.
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
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
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! Please reach out to your Twilio Account Manager or contact our Sales Team. We’re looking for feedback on:
- Developer experience
- Level of configurability
- Status callbacks
- Ease of transferring control of the call back to Twilio (to execute the next TwiML)
- Regional implications
- Applicable use cases