Skip to contentSkip to navigationSkip to topbar
On this page

Dialogflow CX Onboarding Guide


Twilio's Dialogflow CX Connector provides native telephony integration with Google Dialogflow CX. With this integration, Twilio offers rich conversational AI experiences to customer applications. A common use case for this would be enterprises with medium to large sized contact centers.

This guide explains the integration process between your Twilio application and your Google Dialogflow CX virtual agent.

(information)

Info

Google is rebranding Dialogflow CX as Conversational Agents. Until that rebranding concludes, this guide continues to use Dialogflow or Dialogflow CX. Consider these equivalent terms.


Prerequisites

prerequisites page anchor

Before starting the integration, complete these prerequisites.

Set up your Google Dialogflow CX agent

set-up-your-google-dialogflow-cx-agent page anchor

To start using Dialogflow CX in Google Cloud, consult Google's Dialogflow CX setup documentation(link takes you to an external page).

Grant Twilio permission to access your Dialogflow CX agent

grant-twilio-permission-to-access-your-dialogflow-cx-agent page anchor

Before setting up one-click integration, Google Cloud requires you to grant access to Twilio's service account. To run your Dialogflow agent, grant Twilio's production service account permission to use Google Cloud.

  1. Log in to your Google Cloud console(link takes you to an external page).
  2. Select the Google Project in which you want to set up your Dialogflow CX Agent.
    To find the project, use the dropdown menu to the right of the Google Cloud logo.
  3. Verify that you have turned on the Resource Manager API(link takes you to an external page).
    If you need to turn on this API, confirm that you selected your desired project, click Next, then click Enable.
  4. Verify that your Google Cloud administrator has granted you the resourcemanager.projects.setIamPolicy permission for your project.
  5. Click the menu button at the top left of the page.
  6. Navigate to IAM & Admin > IAM(link takes you to an external page) from the left navigation.
  7. Click the Allow tab, then click the View by Principals tab.
  8. Click +Grant Access.
  9. In the New Principals box, add virtualagent-ccai-prod@dialogflow-prod-env.iam.gserviceaccount.com.
  10. Under Assign roles, click the Role combo box and search for Dialogflow API Reader.
  11. Click Dialogflow API Reader.
  12. Click + Add another role.
  13. Click the second Role combo box and search for Dialogflow API Client.
  14. Click Dialogflow API Client.
  15. Click Save.

When successful, a box appears stating Policy updated.

Log in to the Twilio Console

log-in-to-the-twilio-console page anchor

Before performing the one-click integration with Google Dialogflow, verify that you have logged into the Twilio console with the appropriate account.

  1. Choose which account or sub-account to integrate with your Dialogflow CX agent.
  2. Log in to the Twilio Console(link takes you to an external page) with that account.

Connect Twilio to your Dialogflow CX Agent with the one-click integration

connect-twilio-to-your-dialogflow-cx-agent-with-the-one-click-integration page anchor

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.

Configure Dialogflow CX for integration

configure-dialogflow-cx-for-integration page anchor
  1. Log in to your Google Dialogflow CX cloud console(link takes you to an external page).
  2. Choose your project from the Select Project modal.
  3. Click Enable API if prompted. This may take a few seconds.
  4. Create or choose an agent(link takes you to an external page).
  5. Click the Manage tab on the left toolbar.
  6. Scroll to Integrations then click Integrations.
  7. Scroll to One-click telephony .
    Twilio under the One-click telephony integrations in the Dialogflow CX agent Manage console.
  8. Click Connect under Twilio. A pop-up modal appears.
  9. Type the name of your integration in the Create a new integration box.
  10. Select the Environment and Language for your Dialogflow CX agent.
    To choose your environment and language, build your own agent. Dialogflow CX pre-built agents use English only.
  11. Click Add. This starts the integration process and launches the Twilio Console.

If any of these steps return an error, consult Google's troubleshooting guide(link takes you to an external page).

Configure Twilio for integration

configure-twilio-for-integration page anchor
(warning)

Warning

Make sure you have granted Twilio access to Google Dialogflow CX. If you haven't, the Twilio console redirects you back to Google with an authentication error.

After you complete the Google Cloud Console steps, the Twilio Console opens to finish the Dialogflow integration. The Dialogflow CX one-click integration page displays with some pre-populated values.

Dialogflow CX Connector page in Twilio Console.
  1. To complete the Connector Configuration form, provide the following values:

    Field namePurposeSuggestion for this tutorial
    Connector Friendly NameUnique name of the Connector. Use this name to identify the connector in Twilio Studio or using TwiML.Dialogflow_CX_Test1
    Status Callback URL (optional)Endpoint URL where Twilio should send requests on call status, intents triggered, sentiment scores, agent-caller text, etc.Twilio Functions
    Welcome Intent Friendly NameName of the Dialogflow CX agent welcome intent to trigger when connecting the caller to the agent.System generated default welcome intent(link takes you to an external page) called WELCOME
    Bot VoiceText-To-Speech voice the bot uses for audio responses. Twilio supports all of Google's list of voices(link takes you to an external page), but this dropdown only includes a subset. To use an unlisted language, use the Twilio <VirtualAgent> widget.Default
    Sentiment AnalysisWhen toggled On, Dialogflow performs sentiment analysis on the end user input and status callbacks relay sentiment scores. Sentiment analysis availability depends on the language support in Dialogflow CX. Consult Google documentation for their list of languages that support sentiment analysis(link takes you to an external page).On
  2. Click Next. The Review and Confirm page displays.

  3. Review the Connector configuration.

    1. If the displayed configuration needs changes, click Previous to update the connector setting.
    2. If the displayed configuration appears correct, click Confirm Configuration Details.
    Dialogflow CX connector confirmation window.
  4. The Agree and Connect to DialogFlow pop-up modal appears. To connect your Twilio Connector to your Dialogflow CX agent, you need to give your consent.

    • To abandon the setup, click the X at the top right corner of the modal pop-up or close your browser tab.
    • To finish the integration setup, click Agree and connect to Google .
      Dialogflow CX Connector consent dialogue.

This completes your Dialogflow CX integration. The Google Cloud console displays with the completed integration listed in the Twilio Integration modal.

To create another integration, click Add.

To find this integration in the Twilio console, go to Marketplace > Installed(link takes you to an external page) in the left side navigation.


Develop your application with the Dialogflow CX agent integration

develop-your-application-with-the-dialogflow-cx-agent-integration page anchor

With the Dialogflow CX integration with Twilio complete, 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.

Connect Virtual Agent Widget and Twilio Studio

connect-virtual-agent-widget-and-twilio-studio page anchor

When you complete the integration, Twilio creates a new Studio Flow with a Connect Virtual Agent Widget in it.

Connect Virtual Agent Widget (for Dialogflow CX).

You can find this new Flow in your Studio Flows dashboard(link takes you to an external page). It has the name that you provided for the Connector Friendly Name field when configuring the Connector.

The Connect Virtual Agent widget includes the settings you provided during the Connector setup. You can customize the Widget further. This could include passing additional parameters from Twilio to the Dialogflow agent.

To learn more about the available parameters, consult the Connect Virtual Agent Widget documentation.

To control what happens before and after the Twilio call, add other Widgets to the Studio Flow.

For example: If a call with Dialogflow CX agent ends with a Live Agent Handoff transition, you might add a Connect Call To Widget. This connects the caller to a live agent's phone.

Configure a Twilio number to connect to your Virtual Agent Studio Flow

configure-a-twilio-number-to-connect-to-your-virtual-agent-studio-flow page anchor

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(link takes you to an external page) 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(link takes you to an external page).)

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.

Configure a Studio Flow to connect to a Voice 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!

<VirtualAgent> TwiML noun

virtualagent-twiml-noun page anchor

You can also integrate your Dialogflow CX agent using the TwiML <VirtualAgent> noun.

(information)

Info

New to using TwiML? Consult the TwiML overview and learn how it handles Twilio Voice calls.

To generate TwiML, use one of Twilio's helper libraries.

(information)

Example 1: Connect a call to Dialogflow CX agent

Connect a Programmable Voice call to a Dialogflow CX agentLink to code sample: Connect a Programmable Voice call to a Dialogflow CX agent
1
const VoiceResponse = require('twilio').twiml.VoiceResponse;
2
3
const response = new VoiceResponse();
4
const connect = response.connect({
5
action: 'https://myactionurl.com/twiml'
6
});
7
connect.virtualAgent({
8
connectorName: 'project',
9
statusCallback: 'https://mycallbackurl.com'
10
});
11
12
console.log(response.toString());

Output

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>

To learn how to use this TwiML noun, consult the <VirtualAgent> documentation.


Support for Dialogflow CX features

support-for-dialogflow-cx-features page anchor

By default, Dialogflow CX integration includes the following GenAI features. These features leverage GenAI to build workflows, provide answers, create LLMs using your data, and respond in native languages. Twilio supports these features at an additional cost. You incur this cost only after you configure one or more of these features for your agent.

Reduce agent creation time with these playbooks. You need only provide natural language instructions and structured data to an LLM. It then generates agent behavior and responses for you. These differ from flows which use LLMs to figure out intent. Flows grant you more control over the agent's behavior and answers.

To learn more, consult Google's documentation on Generative playbooks(link takes you to an external page).

Have GenAI respond when Twilio doesn't recognize a caller's answers or intent. If a caller has a question that doesn't match any training phrases, Twilio can create a response using Dialogflow CX.

To learn more, consult Google's documentation on Generative fallback(link takes you to an external page).

Create responses and agent behavior runtime through the combination of Google LLMs and your prompts. By querying an LLM using a Generator, your agent can create a response in real time.

To learn more, consult Google's documentation on Generators(link takes you to an external page).

Configure retrieval-augmented generation (RAG) of your own data. As part of a Generative Playbook, you can link to an LLM of your own data. Any queries then use that data to craft a response.

To learn more, consult Google's documentation on Data store agents(link takes you to an external page).

Language-specific data generation

language-specific-data-generation page anchor

Use the training data and intents of your default language to generate training phrases in another language.

To learn more, consult Google's documentation on generating language-specific data(link takes you to an external page).

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 triggers the welcome intent. For example: the agent could say "Hello" to the caller before they start speaking.

You can use and customize the Dialogflow CX agent's default welcome intent(link takes you to an external page). 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(link takes you to an external page) in your agent's setting in the Google Cloud console.

Pause and resume a conversation session

pause-and-resume-a-conversation-session page anchor

You can pause and resume a Dialogflow CX session(link takes you to an external page). While keeping the session context intact, Dialogflow and Twilio can pass the call back and forth. When Twilio passes the call to Dialogflow, the caller won't need to repeat themselves or start over.

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 time-to-live (TTL) window.

End the conversation with the virtual agent

end-the-conversation-with-the-virtual-agent page anchor

In Dialogflow CX console

in-dialogflow-cx-console page anchor

To tell the virtual agent to end the conversation after it responds with a particular response, set the transition target for an intent to End. To learn more, consult Google's docs(link takes you to an external page).

When an intent matches the "end of the conversation" intent, the virtual agent ends the conversation. The Connect Virtual Agent Studio Widget moves the call into the Completed transition state.

When an intent matches the "end of the conversation" intent, the virtual agent ends the conversation. Twilio creates a request to your action URL. Before sending the request, it sets the VirtualAgentStatus field in the request to completed. To execute the next TwiML in your application, use either the action parameter or the next TwiML step <Connect> verb.

Support all transition states in status callbacks

support-all-transition-states-in-status-callbacks page anchor

If you configure status callback, Twilio can pass one or more parameters at any virtual agent transition state. Status callbacks can pass parameters in requests to your application URL. These parameters include, but aren't limited to, the following:

  • call status
  • intents triggered
  • sentiment scores
  • agent-caller text

With support for all transition states, you can write custom code against the parameter values for your own contact center application.

Support all transition states in action callbacks

support-all-transition-states-in-action-callbacks page anchor

Twilio can pass multiple parameters at any virtual agent transition state. Status callbacks can pass the following parameters in requests to your application URL.

  • last intent triggered
  • last sentiment score at last matched intent

With support for all transition states, you can write custom code against the parameter values for your own contact center application.

Custom prompt voice support

custom-prompt-voice-support page anchor

Twilio supports creating prompts and responses using your own voice talent. Record and upload the samples to Google Cloud. Using your own voice talent comes at an additional cost.

You can turn on barge-in within Dialogflow CX agents. This allows callers to interrupt the virtual agent at any time. For example: You turned on "barge-in". A caller starts speaking in the middle of the agent's response. Dialogflow stops sending audio to the caller and processes the caller's next input.

To learn how to turn on the barge-in feature, consult Google's docs(link takes you to an external page).

An end user can also press numbers on their keypad. This sends dual-tone multi-frequency (DTMF) signaling through their telephone keypad. You can configure DTMF(link takes you to an external page) for a parameter in your Google Dialogflow CX console. Once turned on, your customer can use their telephone keypad to provide parameter values for an agent using a telephony integration(link takes you to an external page).


We appreciate hearing from you! Contact your Twilio Account Manager or our Sales Team(link takes you to an external page). We're looking for feedback on the following features:

  • 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