Did you know you can capture real-time action items from conversations with customers, automatically push these items to a customer database, and never have to worry about missing another important task or feverishly scribble customer notes?
We will show you how to connect the Symbl voice API to Twilio Media Streams to access real-time raw audio and easily generate actionable insights and tasks from these audio streams. Take this workflow automation one step further—connect the Salesforce Opportunities dashboard to Twilio Flex to automatically send these valuable insights and tasks to the Salesforce CRM platform.
This blog post will guide you step-by-step through the workflow
Requirements
Before we can get started, you’ll need to make sure to have:
To start, you’ll need to configure Twilio Media Streams and a Symbl Websocket server. If you haven’t already done so, refer to this blog post first to set up your environment.
Getting Started
At this point, you should be able to stream audio through your Websocket server into Twilio Flex and generate insights.
In order to take those generated insights and push them to your Salesforce dashboard in real-time, we will start by updating the `index.js` file in your Websocket server.
const WebSocket = require("ws");
const express = require("express");
const app = express();
const server = require("http").createServer(app);
const ws = new WebSocket.Server({
server
});
const WebSocketClient = require("websocket").client;
const wsc = new WebSocketClient();
const request = require('request');
let connection = undefined;
let client_connection = undefined;
let opportunity_id = undefined;
// Handle Web Socket Failures
ws.on('connectFailed', (e) => {
console.error('Connection Failed.', e);
});
// Handle Web Socket Connection
ws.on("connection", (conn) => {
connection = conn;
connection.on('close', () => {
console.log('WebSocket closed.')
});
connection.on('error', (erdr) => {
console.log('WebSocket error.', err)
});
connection.on('message', (data) => {
const msg = JSON.parse(data);
if (data.type === 'utf8') {
const {
utf8Data
} = data;
}
switch (msg.event) {
case 'connected':
console.log(`A new call has connected.`);
break;
case "start":
console.log(`Starting Media Stream ${msg.streamSid}`);
request.post({
'auth': {
'bearer': ''
},
method: 'POST',
url: 'https:///services/data/v39.0/sobjects/Opportunity',
body: { // Configure the payload as per your needs
"Name": "Prospective Meeting with Magpie",
"CloseDate": "2020-04-12",
"StageName": "Prospecting"
},
json: true
}, (err, response, body) => {
opportunity_id = body.id;
});
break;......
}
}
In the code sample above, we are modifying the connection start
block with a POST
request that creates a new opportunity in your Salesforce dashboard with the provided json
payload. You can configure this payload as needed.
- Once the request is successful, we want to save the
opportunity id
in a variable so that we can use it to push action items next. (Note: To get your Salesforce Authentication Token, refer to this guide.) - Next, when action items are detected, we want to capture those insights and add them to our Salesforce dashboard under the opportunity we created.
Next, when action items are detected, we want to capture those insights and add them to our Salesforce dashboard under the opportunity we created.
To do this, we will modify the client_connection.on('message')
handler.
{
......wsc.on("connect", (conn) => {
client_connection = conn;......
if (data.type === 'utf8') {
const {
utf8Data
} = data;
data = JSON.parse(utf8Data) console.log(data, "typeIS: " + data.type);
if (data.type == "action_insights") {
request.post({
'auth': {
'bearer': ''
},
method: 'POST',
url: 'https:///services/data/v39.0/sobjects/Task',
body: {
"Subject": data.title,
"Status": "Not Started",
"WhatId": opportunity_id,
"Priority": "high",
"Description": data.description
},
json: true
}, (err, response, body) => {
console.log('request', body);
});
}
}
});
And that’s it! With this integration, your Salesforce dashboard should now have opportunities dynamically created from yours calls and all action items generated will be logged as tasks within the opportunity. If we head over to Salesforce, we can see an opportunity was created: Perspective Meeting with Magpie
If we dive into that opportunity, we can see that the action items that were generated by Symbl have been logged as tasks in the opportunity, automatically.
You can use other Salesforce APIs with Symbl to customize how your action items and topics are displayed on your opportunity dashboard. For example, you can add call logs like in the image above and show the Topics that were generated from your sales call directly in the Description
field. Read about the different Salesforce APIs.
Test out the integration
To test out the integration, navigate to the Twilio Flex tab and click on Launch Flex: On your flex dashboard, locate your Twilio phone number and call that number from your cellular device. When you accept the call from Flex, the audio will be streamed through Symbl’s WebSocket API and based on how you’ve configured your API calls for Salesforce, those insights will be logged in your dashboard. Open up your Salesforce dashboard and you’ll see the opportunity being created and insights logging in the opportunity in real-time. Check out our API docs if you want to customize this integration further using the APIs that Symbl provides.
Wrapping up
Congratulations! You can now harness the power of Symbl to empower your sales team to focus on having a great conversation experience with customers and be free of any distracting activities while on the call. Sign up to start building! Need additional help? You can refer to our API Docs for more information and view our sample projects on Github.