Setting Up and Enhancing Twilio Flex with Conversation Intelligence for Your Business

Businesses depend on sales and quality assurance teams to deliver seamless experiences to their customers. Some of them have thousands of conversations between customers and sales agents each day. As you can imagine, it becomes impossible to derive revenue-focused insights from this data manually.

Enter conversation intelligence. It leverages AI-based algorithms to analyze calls and textual conversations between customers and sales agents to provide meaningful insights to your business.

Actions can be taken on real-time data to accelerate solutions and improve customer satisfaction. Calls may be streamed to advertising and data analytics platforms to provide insights in real time. This data is useful in marketing, revenue, sales, and e-commerce as well. It helps you to understand the intent, decisions, questions, and grievances of the customer. By gaining these meaningful insights to better understand and predict customer behavior, you can improve buying experiences and ultimately drive more revenue for the business.

In this article, you’ll learn more about conversation intelligence and its use cases. Then, you’ll learn how to integrate Symbl.ai with Twilio Flex to gain more insight from your contact center.

Conversation Intelligence

The concept of conversation intelligence describes the business insights that companies derive from conversations between their sales agents and customers. Understanding them can help businesses to identify loopholes and fix them.

Conversations may happen in a variety of formats—voice calls, text messaging, video calls, or email. Thus, many businesses instruct their representatives to write meeting summaries after conversations. This is a manual process that can be tedious and time-consuming. It may be feasible for one to twenty calls; however, when calls exceed thousands, it’s not possible to manually remember and note so much information with accuracy. A lot of information gets missed.

Currently, the efforts and success of revenue-generating teams are measured by the number of calls made by the representatives, the answering rate, stage of the deal, deals made and canceled, and revenue projection and generation.

Conversation intelligence ensures that all calls are analyzed digitally. This provides insights to the decision-makers, using various natural language processing approaches like sentiment analysis, intent recognition, and named entity recognition. This enables the sales teams to function more effectively by better understanding customer needs.

Machine integrations allow conversation data to be sent to advertising platforms or customer experience analysis platforms in a more streamlined fashion. Based on the findings, business leaders are able to understand their users better and improve customer experience.

In conversational AI, speech-to-text converters transcribe human speech into text, which allows businesses to identify patterns and to better understand customer intent, important topics, questions asked, and more.

Conversation Intelligence Use Cases

There are a variety of valuable use cases for conversation intelligence data. Let’s explore a few:

  • Marketing: conversational intelligence enables marketing teams to gain visibility into conversations regarding purchases and digital marketing campaigns. This lets the team identify what approaches are leading to purchases and more revenue.
  • E-commerce: e-commerce teams leverage conversation AI to gain visibility into digital e-commerce. With conversation intelligence, e-commerce teams can create a feedback loop that will improve conversion and increase sales velocity.
  • Customer Experience: through conversation intelligence, brands can gain visibility into all aspects of the customer experience, including the interactions that happen throughout the buying process. This allows them to identify areas of friction and drive top-line growth.
  • Sales: using conversation intelligence, sales team members can monitor and improve their agents’ performance. This helps them make better decisions and provides feedback that’s more effective.

As a sales coach, it can be very challenging to listen to and follow calls while delivering coaching recommendations. This process is inefficient and doesn’t scale. With the help of conversation intelligence, sales coaches can improve their effectiveness by focusing on the weak behaviors that they can fix. Furthermore, sales leaders can monitor all the customer interactions that happened during sales calls to more easily identify winning conversations and new customer trends.

The use of conversation intelligence software by B2C brands can help almost any team improve the customer experience and drive revenue growth. This technology can help identify and address the various needs of the customers, and it can also help improve the contact center operations.

Natural language processing is used to extract data from speech. AI is also used to organize and take action on that data. Thus, with conversation intelligence, sales reps can focus on selling instead of taking notes. It allows them to listen to each call and identify their own gaps and opportunities, and it also helps them improve their performance.

Implementing Conversation Intelligence for Your Business with Twilio Flex

Now that you have a working understanding of the benefits of conversation intelligence, let’s get into the details of setting it up with Twilio Flex. If you want to arrange automated calls from your company to customers, or to create a customer service digital answering system, Twilio is a great tool. Their web service APIs allow software developers to make and receive phone calls, send and receive text messages, and conduct other communication operations programmatically.

Start by creating a new Twilio account:

Twilio gives new users fifteen dollars to get started with for free. Purchase a phone number with voice calling availability from your country.

You will be able to view your Twilio dashboard, including analytics for call frequency and errors and warnings:

Next, let’s create an inbound call from your Twilio number to any valid mobile number. First, get your Twilio account SID and API token, as displayed on your Twilio dashboard:

Then, install the Twilio helper library. Enter the following code on your terminal:

python3 -m pip install twilio

Create a file called create_call.py. You’re going to create a client object and the call. The URL contains TwiML by default; TwiML is code that tells Twilio what to do once the receiver picks up the call. In the to parameter, enter your personal mobile number where you want to receive the call. In the from parameter, enter your Twilio mobile number.

Install the dotenv Python library for accessing the environment variables from an .env file:

	import os
	from twilio.rest import Client

	from dotenv import load_dotenv
	load_dotenv('.env')
	account_sid = os.environ['TWILIO_ACCOUNT_SID']
	auth_token = os.environ['TWILIO_AUTH_TOKEN']
	client = Client(account_sid, auth_token)
	call = client.calls.create(
		url='http://demo.twilio.com/docs/voice.xml',
		to='YOUR PERSONAL PHONE NUMBER',
		from_='YOUR TWILIO PHONE NUMBER')

Then, create an .env file and add the values of the environment variables:

TWILIO_ACCOUNT_SID=
TWILIO_AUTH_TOKEN=

You can also enter the SID and token strings directly to the variables in create_call.py.

Execute the file with python3 create_call.py. A few seconds later, you will receive a call from your Twilio number to your personal phone number. If so, you have successfully made a call from Twilio to your personal phone.

Now, let’s assume you have an online store called Sofia Store, and you want to create a service for processing complaints. You will now create a Python program to make a call from your number to your Twilio number and process the conversation.

To process a call, you can create a recording and store the call SID in a file. You can do this for multiple calls, but here, you will do it for a single call. You will print out the call SID after the call is created.

When you create a call from your Twilio number to your mobile number, you can pass several parameters, including TwiML, to specify what will be said on the call. In the record function, you will create a voice response to greet the customer and also ask the customer to talk about the product and the problems they are facing, including any questions they may have about the product.

The record function returns TwiML, which will prompt the customer to start speaking about the product. The parameter record = True is for recording.

def record():
response = VoiceResponse()
response.say('Hello, you have reached Sofia customer care. Let us know about any issues with our products. This call will be recorded. Please leave your message after the beep.')
response.record()
response.hangup()
return str(response)

The call recording is uploaded to Twilio. Two recordings are made, one for the complete call and the other for the customer’s response only. Here, you will be analyzing the customer’s response audio. Create a file called start_call.py and add the following code:

from twilio.rest import Client
from twilio.twiml.voice_response import VoiceResponse

def record():
response = VoiceResponse()
response.say('Hello, you have reached Sofia customer care. Let us know about any issues with our products. This call will be recorded. Please leave your message after the beep.')
response.record()
response.hangup()
return str(response)

account_sid = os.environ['TWILIO_ACCOUNT_SID']
auth_token = os.environ['TWILIO_AUTH_TOKEN']
client = Client(account_sid, auth_token)

call = client.calls.create(
record=True,
twiml=record(),
to='YOUR PHONE NUMBER',
from_='YOUR TWILIO NUMBER'
)

print(call.sid)

You will receive a call from your Twilio number on your mobile phone. You can talk about your grievances associated with the product you received from Sofia Store and ask questions, too. Then, you can view the recording logs here.

Symbl.ai

Now that your recording has been logged, let’s incorporate Symbl.ai to expand your options with conversation intelligence. Symbl.ai can be used to elevate call center functionality in a variety of ways:

  • Generating Transcriptions: speech-to-text capabilities translate speech from a live audio feed into text for each of the meeting’s speakers.
  • Follow-ups: this is a type of action item that refers to following up on a request or a task, such as sending an email, making a phone call, booking an appointment, or setting up a meeting.
  • Insights from a Conversation: talk-to-listen ratios, sentence level, and topic-based sentiments can be monitored to create actionable insights. The most relevant discussion topics from the chat are developed based on the overall breadth of the discourse.
  • Named Entity Recognition: allows users to identify and build entities with real-time data. You can uncover insights about calls from certain locations, names of people, and more.
  • Questions: refers to an explicit question or request for information that arises during a conversation. Whether or not these details are addressed, Symbol.ai identifies and logs questions throughout the conversation.
  • Trackers: allow you to keep track of the occurrence of specific terms or phrases in a chat so that you can observe emerging trends and assess the nature of interactions. Using a tracker, you can set keywords or phrases, and Symbl.ai will return messages that contain those phrases or are contextually relevant.
  • Speaker Analytics: this feature allows you to determine the speaker ratio, talk time, silence, tempo, and overlap in a conversation.

Now, let’s get back to our conversational AI solution for Sofia Store. Once the call is done, the recordings will be uploaded to Twilio. You can now pass the recording to Symbl.ai Async API to derive insights.

First, install the Symbl Python library:

	python3 -m pip install symbl

Create a new account on Symbl.ai. Then, copy your Symbl app ID and secret. You will need these credentials to create the conversation object with the Async API.

Then create a file called get_insights.py and add the following code:

import symbl
import requests
from requests.auth import HTTPBasicAuth

def get_recording_sid(account_sid_,auth_token_,call_sid_):
url = f"https://api.twilio.com/2010-04-01/Accounts/{account_sid_}"+ f'/Calls/{call_sid_}/Recordings.json'
result = requests.get(url,auth = HTTPBasicAuth(account_sid_, auth_token_))
recordings = result.json()
recording_sid = recordings['recordings'][0]['sid']
return recording_sid

account_sid = os.environ['TWILIO_ACCOUNT_SID']
auth_token = os.environ['TWILIO_AUTH_TOKEN']

call_sid = "REPLACE CALL SID HERE"
recording_sid = get_recording_sid(account_sid, auth_token, call_sid)
print(f"Recording Sid: {recording_sid}")

recording_endpoint = 'https://api.twilio.com/2010-04-01/Accounts/' + f'{account_sid}/Recordings/{recording_sid}.wav'

request_body = {
'url': recording_endpoint,
'name': 'Get Insights from Conversation',
}

conversation_object = symbl.Audio.process_url(payload = request_body,
credentials={'app_id': "ENTER_APP_ID", 'app_secret': "ENTER_APP_SECRET"})

print("Conversation messages")
print(conversation_object.get_messages())
print("--------------------------------------------------")
print()

print("Conversation topics")
print(conversation_object.get_topics())
print("--------------------------------------------------")
print()

print("Conversation follow ups")
print(conversation_object.get_follow_ups())
print("--------------------------------------------------")
print()

print("Conversation action items")
print(conversation_object.get_action_items())
print("--------------------------------------------------")
print()

print("Conversation questions")
print(conversation_object.get_questions())
print("--------------------------------------------------")
print()

print("Conversation members")
print(conversation_object.get_members())
print("--------------------------------------------------")
print()

Above, the get_recording_sid function takes the Twilio account sid, auth-token, and call sid and returns the recording sid. The recording_endpoint is created from the recording sid. We passed the recording URL while creating a new conversation object. Next, we printed out the call insights:

  • Transcripts: conversation_object.get_messages()
  • Conversation topics: conversation_object.get_topics()
  • Follow Ups: conversation_object.get_follow_ups()
  • Questions: conversation_object.get_questions()
  • Action items: conversation_object.get_action_items()

Execute start_call.py with python3 start_call.py. You will receive a call on your number (the to number). I tested the Symbl API with the text below to demonstrate the different functionalities. You can say anything you like.

>“I recently purchased a Google Home Mini from your site Sofia. I ordered it on May 17th, and it arrived on June 23rd, two weeks after the mentioned delivery date. It came in a package which was not waterproof. Do you not send electronic items in waterproof packaging? I opened the package, and it seemed to have been tampered with. The internal packaging was destroyed. Instead of having a Google Home Mini, it actually had an Amazon Alexa. Can you let me know why I have been sent the wrong product? The website has this number for customer service, and I am reaching out for an immediate refund. How many days will it take to process the refund? I am infuriated by this service. Please schedule a call with your representative at 12:30 pm. Please mail me the confirmation of this action.”

Once you hang up after the call, copy the call id and paste it into the get_insights.py file. Execute the file with python3 get_insights.py. You can also pass the caller ID as an argument to get_insights.py.

I passed the call id for the call I completed using the start_call.py file. The output images below show you the different functionalities of Symbl.ai, such as getting transcription, topics, questions, sentiments, and more:

In the above outputs, you can see that the transcription of the call has been printed. The action items have been identified correctly—that is, scheduling a call and asking someone to mail the confirmation to schedule the call. The questions have also been identified successfully.

Using PSTN, you can detect answering machines in real-time in the call. Using the transcript_response argument, you can verify whether there is a transcript coming from an answering machine. For instance, if the transcript states, “You have reached Soumi; please leave a message after the beep,” it can detect the line “please leave a message after the beep” and infer that the call has reached an answering machine. These calls can be terminated immediately, saving resources and making it easier for sales leaders to filter calls.

You can also generate a meeting report and have it mailed to your inbox. Create a file called pstn.py and enter the code below. Then create a Zoom meeting. Replace the meeting ID and password in the code, and add your Zoom number and the email ID where you want to receive the report.

import symbl

phoneNumber = "Phone number to connect to the conference call"
meetingId = "YOUR ZOOM MEETING ID" #Your meeting ID.
password = "YOUR ZOOM MEETING PASSCODE" #Your meeting passcode.(must be only digits)
emailId = "ENTER YOUR MAIL ID" #Your registered email ID on the conference tool.
print("dmtf",",,{}#,,{}#".format(meetingId, password))
connection_object = symbl.Telephony.start_pstn(
	credentials={"app_id": "INSERT APP ID", "app_secret": "INSERT APP SECRET"},
	phone_number= phoneNumber,
	dtmf = ",,{}#,,{}#".format(meetingId, password),
	actions = [
	{
		"invokeOn": "stop",
		"name": "sendSummaryEmail",
		"parameters": {
			"emails": [
			emailId
			],
		},
	},
	]
	)
	connection_object.subscribe({
		'transcript_response': lambda response: print('printing the first response ' + str(response)),
		'insight_response': lambda response: print('printing the first response ' + str(response))
	}
	)
	print(connection_object)

Execute the file with python3 ptsn.py.The report link will be mailed to you. It should look something like this:

Conclusion

In this article, you learned how to integrate the Twilio API with the Symbl.aiPython SDK to get transcribed text, topics, members, questions, follow-ups, and action items. You also sent an intelligent analysis of your conversation to your email.

In most businesses, analyzing calls is typically based on random sampling. However, this can never provide one hundred percent coverage, and it can sometimes be misleading due to over-reliance on insights from random samples. With conversation intelligence software, sales coaches and QA staff members can monitor all of the customer conversations without listening to a single call. You can identify call quality benchmarks by looking at the agents that are meeting them and those who are not. It can also be used to pinpoint and evaluate the best performers.

Sales leaders often struggle to identify winning and losing behaviors in their agents. With the help of conversation intelligence, they can now surface these winning and losing conversations and easily show agents how they can improve their sales performance.

A conversation intelligence platform can help you save money and time in your customer contact center. It can also help you catch sales mistakes quickly. Thus, using conversation AI solutions like Symbl.ai can lead to faster revenue growth and improved customer satisfaction. Sign up for free and get started today.

About Soumi Bardhan

Soumi loves working computer vision and AI development, and enjoys writing technical articles on medium. She has been part of Google Season of Docs twice and loves open source!

Twitter: @MsBardhan