[ad_1]
In today’s digital age, businesses are constantly looking for ways to improve customer engagement and experience. Integrating communication tools with conversational platforms is one way to achieve this. Twilio, a cloud communications platform, and Dialogflow CX, a conversational AI platform, have joined forces to offer seamless integration for businesses looking to create powerful conversational experiences. With this integration, businesses can leverage Twilio’s messaging and voice capabilities, along with Dialogflow CX’s natural language understanding and intent recognition, to create sophisticated conversational experiences that can meet a wide range of customer needs.
Prerequisites
- To start our project on Dialogflow CX, you need to create an account with billing enabled and set up an agent.
- Additionally, you’ll need a Twilio account with the purchased mobile number and available credit to make calls. For testing purposes, we recommend using textnow.com, although you are free to use any other service or to create your own mobile phone. call.
- Finally, make sure you have Ngrok installed on your system.
steps
Step 1. Give Twilio permissions to access your Dialogflow CX agent
- Before you can start the one-click integration process, there is a one-time manual step that you must complete. This step involves giving permission to the Twilio production service account to run your Dialogflow agent. After completing this step, you will be able to easily start the one-click integration.
- Sign in to your Google Cloud console
- Select the Google project in which you configured your Dialogflow CX agent
- From the left navigation, go to IAM & Admin > IAM
- Click + Grant access near the top of the page
- Under “New Principles” add virtualagent-ccai-prod@dialogflow-prod-env.iam.gserviceaccount.com as a member with the following roles:
-
- Dialogflow API Reader
- Dialogflow API client
Step 2. Connect Twilio to your Dialogflow CX agent with one-click integration
Great job on doing the prerequisite steps! You are now ready to use the one-click integration process to connect your Twilio Dialogflow CX connector to the Dialogflow CX agent of your choice. This should be a seamless process and allow you to quickly start using the integration.
- Sign in to your Google Dialogflow CX cloud console.
- In the navigation bar on the left, click the “Manage” button.
- Select “Integrations” from the drop-down menu.
- Look for the One Click Phone section and then select Twilio from the available options.
- Give your integration a new name. It can be anything you like, but make sure it’s something descriptive so you can easily identify it later.
- Select the environment and language for your Dialogflow CX agent. This is important because it determines how your agent interacts with customers.
- After entering all the required information, click the “Add” button. This will start the integration process and open the Twilio Console page where you can configure your Twilio account and connect it to your Dialogflow CX agent.
Step 3. Configuration steps in the Twilio Console
After you complete the steps in the Google Cloud Console, you will be redirected to the Twilio Console to complete the Dialogflow integration. You should see a page titled “Dialogflow CX One-Click Integration” that includes the Dialogflow CX connector with pre-populated values.
On this page, you can configure your integration settings, such as the phone number you want to use for phone interactions and other options. It’s important to review these settings carefully to make sure your integration is set up correctly and works as expected. After making the necessary changes, you can save your settings and start using the Twilio Dialogflow CX Connector right away.
To set up your Twilio Dialogflow CX Connector, you need to configure the following settings:
- Connector Friendly Name: This is the unique name you will use to identify your connector in Twilio Studio or using TwiML. Let’s say you name it “test_demo”.
- Status Call URL (Optional): This is the URL where you want Twilio to send requests for call status, activated goals, sentiment scores, and more. For this tutorial, you can connect it to Twilio Functions.
- Welcome Intent Friendly Name: This is the name of the Dialogflow CX agent welcome intent that you want to trigger when connecting to the caller agent. If you don’t have a custom welcome intent, you can use the system-generated default welcome intent called WELCOME.
- Bot Voice: This parameter specifies the text-to-speech voice used when synthesizing audio responses from the bot. You can refer to Google’s documentation for Dialogflow for a list of currently supported voices.
- Sentiment Analysis: This setting determines whether Dialogflow will perform sentiment analysis on end-user input. If it is set to ON, mood scores are transmitted in status calls. Note that availability of sentiment analysis depends on language support in Dialogflow CX.
After you have configured the connector with all the details, click Next. You will then see the “Review Information” screen asking you to review the configuration of the connector. If something is wrong, you can click “Back” to update the connector settings. If everything looks good, click “Confirm Configuration Details”.
After configuring your Twilio Dialogflow CX Connector, you will see a modal popup asking for your consent to connect your Connector to your Dialogflow CX agent. If you don’t want to continue with the setup, you can click the X in the upper right corner of the modal popup or close your browser tab.
If you want to continue, click “I agree and connect with Google” to complete the integration setup.
happy! Your Dialogflow CX integration with Twilio is now complete. You can confirm that the Connector instance is complete by checking the Dialogflow CX Connectors section in the Twilio Console.
After you complete the integration between Dialogflow CX and Twilio, Twilio automatically creates a new Studio Flow with the Connect Virtual Agent widget.
Follow these steps to set up a stream:
- Open the Twilio Console.
- Click on “Develop” and select “Studio” from the drop-down menu.
- Click on Streams and select the name of the stream you want to use.
- Set up the flow as desired using the Connect Virtual Agent Widget, which is automatically created for you as part of the integration.
Below is a screenshot of the agent connecting to Twilio.
To connect an outgoing call, you can use the Make Outgoing Call widget from the widget library in Twilio Studio. You can then connect it to the Rest API as shown in the image below:
This will allow you to make outbound calls using Twilio and connect them to your Dialogflow CX agent for natural language processing and intelligent responses.
Rest API:
Install the twilio library on your system. To install on an Ubuntu system, use this command.pip install twilio
script:
from twilio.rest import Client
# Your Account Sid and Auth Token from twilio.com/console
account_sid = <YOUR ACCOUNT SID>
auth_token = <YOUR ACCOUNT AUTH TOKEN>
# Create a Twilio client object
client = Client(account_sid, auth_token)
execution = client.studio \
.v2 \
.flows(<FLOW ID>) \
.executions \
.create(to= <TO NUMBER>, from_= <TWILIO NUMBER>)
print(execution.sid)
Now, Twilio of Dialogflow is connected using the integration we set up.
You can test it by making calls from your mobile phone to a number purchased from twilio. You will hear a voice from the Dialogflow agent.
Feel free to post your doubts/queries. We will be happy to help you. If you are looking for Chatbot development or natural language processing services then contact us or send us your inquiry at letstalk@pragnakalp.com. We will be happy to offer you our expert services.
[ad_2]
Source link