Conversation summaries
The Artificial Intelligence conversation summarization API allows you to summarize the contents of speaker-tagged audio transcript by extracting what is determined to be the most relevant parts of the conversation. The API provides two types of summaries:
- Abstractive. The summary generated is a unique construction that attempts to convey the meaning of the text. This is ideal for generating an abstract of the specified text.
- Extractive. The summary generated is a sequence of excerpts of the most relevant sentences. This is ideal for creating a list of highlights from a block of text.
The API also allows developers to optionally specify the start and end times, as well as a speaker ID in order to generate a summary from a portion of a larger previously diarized transcription, or to contrain the summary to a specific time period. '
Generating a summary from a block of text??
Request parameters
Parameter | Type | Description |
---|---|---|
summaryType |
String | Permitted values: Extractive (default), AbstractiveLong , AbstractiveShort , All . Specify All to compute both extractive and abstractive type of summaries. |
utterances |
List[utterances-Data] | List of speakerId, start, end and text object. |
utterances-Data
Parameter | Type | Description |
---|---|---|
text |
String | Text blob for summary. |
speakerId |
String | Speaker id for the text blob. Optional. Used in an abstractive summary to reference in the output. |
start |
Number | start time of the segment. Optional. |
end |
Number | start time of the segment. Optional. |
Sample code
The following example code shows how to provide the utterances input to the API and get the summaries.
Follow the instructions on the quick start section to setup and run your server code before running the sample code below.
Running the code
- Edit the variables in ALL CAPS with your app and user credentials before running the code.
- You can only run on your production account, this means that you have to use app credentials for production.
const fs = require ('fs')
const RC = require('@ringcentral/sdk').SDK
// Instantiate the SDK and get the platform instance
var rcsdk = new RC({
server: 'https://platform.ringcentral.com',
clientId: 'RC_APP_CLIENT_ID',
clientSecret: 'RC_APP_CLIENT_SECRET'
});
var platform = rcsdk.platform();
/* Authenticate a user using a personal JWT token */
platform.on(platform.events.loginSuccess, () => {
NGROK = "NGROK-TUNNEL-ADDRESS"
WEBHOOK_URL = NGROK + "/webhook";
conversation_summary()
})
platform.on(platform.events.loginError, function(e){
console.log("Unable to authenticate to platform. Check credentials.", e.message)
process.exit(1)
});
/*
* Summarize the conversations
*/
async function conversation_summary() {
try {
let bodyParams = {
summaryType: "All",
utterances: [
{
"end": 8.96,
"speakerId": "0",
"start": 3.72,
"text": "Good evening, thank you for calling electronics or this is Rachel. How may I assist you?"
},
{
"end": 14.280000000000001,
"speakerId": "1",
"start": 8.96,
"text": "Hi, Rachel. I would like to know how to use this car. Bluetooth headset I recently purchased from your store."
},
{
"end": 21.36,
"speakerId": "0",
"start": 14.280000000000001,
"text": "Sure, ma'am, I can help you out with that, but before anything else, I have your name so that I can address you properly."
},
{
"end": 23.58,
"speakerId": "1",
"start": 21.36,
"text": "Yes, this is Meredith Blake."
},
{
"end": 29.72,
"speakerId": "0",
"start": 23.9,
"text": "Okay, thank you for that, Mrs. Plague, what exactly do you want done with your headset?"
},
{
"end": 31.939999999999998,
"speakerId": "1",
"start": 29.72,
"text": "I want to know how to use it."
},
{
"end": 39.08,
"speakerId": "0",
"start": 31.939999999999998,
"text": "Okay, ma'am, I may get your headsets, modal name and number as well as that of your phone."
},
{
"end": 45.18,
"speakerId": "1",
"start": 39.08,
"text": "I bought a Plantronics Mark 2m165, and I use an iphone for S."
},
{
"end": 51.4,
"speakerId": "0",
"start": 45.34,
"text": "Okay, ma'am, so have you tried fairly pairing it with your headset with your phone?"
},
{
"end": 52.74,
"speakerId": "1",
"start": 51.4,
"text": "Yes, I have."
},
{
"end": 60.24,
"speakerId": "0",
"start": 53.22,
"text": "Okay, first, I need you to unpair your device with your phone."
},
{
"end": 61.42,
"speakerId": "1",
"start": 60.24,
"text": "I am, okay?"
},
{
"end": 63.1,
"speakerId": "0",
"start": 61.62,
"text": "Yes, ma'am."
},
{
"end": 65.46,
"speakerId": "1",
"start": 63.42,
"text": "OK, done."
},
{
"end": 72.64,
"speakerId": "0",
"start": 65.74,
"text": "Now, please switch off your phone, then turn it on again after around 5 s."
},
{
"end": 74.34,
"speakerId": "1",
"start": 72.64,
"text": "Switch it off and on."
},
{
"end": 75.78,
"speakerId": "0",
"start": 74.46,
"text": "Yes, please."
},
{
"end": 77.78,
"speakerId": "1",
"start": 75.98,
"text": "Done now what?"
},
{
"end": 80.74,
"speakerId": "0",
"start": 77.82,
"text": "Okay, please parry it with your phone."
},
{
"end": 84.26,
"speakerId": "1",
"start": 81.74,
"text": "Okay, now what."
},
{
"end": 88.19999999999999,
"speakerId": "0",
"start": 84.7,
"text": "Ma'am, is your headset working now? That's."
},
{
"end": 95.12,
"speakerId": "1",
"start": 88.19999999999999,
"text": "Just it I want to know how it works. I already told you that I have paired the device with my phone, but I am not sure if you get what I mean. I."
},
{
"end": 101.7,
"speakerId": "0",
"start": 95.12,
"text": "Well, yes, ma'am, I understand where you are coming from, that is why I am trying to help you, okay?"
},
{
"end": 107.7,
"speakerId": "1",
"start": 102.22,
"text": "Well, we have already done that. I only ask a simple question. Why can't you seem to get that?"
},
{
"end": 114.2,
"speakerId": "0",
"start": 108.14,
"text": "Yes, ma'am, I understand where you are coming from. That is why I am trying to help."
},
{
"end": 123.8,
"speakerId": "1",
"start": 114.2,
"text": "You know what, no 1 I do not think you do. We have been at this for over 30 min going around in circles. I would like to speak to your supervisor. I obviously will not get any help from you."
}
]
}
let endpoint = `/ai/text/v1/async/summarize?webhook=${WEBHOOK_URL}`
let resp = await platform.post(endpoint, bodyParams);
let jsonObj = await resp.json();
if (resp.status == 202) {
console.log("Job ID: " + jsonObj.jobId);
console.log("Ready to receive response at: " + WEBHOOK_URL);
}
} catch (e) {
console.log("Unable to call the summarize API." + e.message);
}
}
from ringcentral import SDK
import os,sys,urllib.parse,json
NGROK_ADDRESS = "NGROK-TUNNEL-ADDRESS"
WEBHOOK_URL = NGROK_ADDRESS + "/webhook";
#
# Summarize the conversations
#
def conversation_summary():
try:
bodyParams = {
'summaryType': "All",
'utterances': [
{
"end": 8.96,
"speakerId": "0",
"start": 3.72,
"text": "Good evening, thank you for calling electronics or this is Rachel. How may I assist you?"
},
{
"end": 14.280000000000001,
"speakerId": "1",
"start": 8.96,
"text": "Hi, Rachel. I would like to know how to use this car. Bluetooth headset I recently purchased from your store."
},
{
"end": 21.36,
"speakerId": "0",
"start": 14.280000000000001,
"text": "Sure, ma'am, I can help you out with that, but before anything else, I have your name so that I can address you properly."
},
{
"end": 23.58,
"speakerId": "1",
"start": 21.36,
"text": "Yes, this is Meredith Blake."
},
{
"end": 29.72,
"speakerId": "0",
"start": 23.9,
"text": "Okay, thank you for that, Mrs. Plague, what exactly do you want done with your headset?"
},
{
"end": 31.939999999999998,
"speakerId": "1",
"start": 29.72,
"text": "I want to know how to use it."
},
{
"end": 39.08,
"speakerId": "0",
"start": 31.939999999999998,
"text": "Okay, ma'am, I may get your headsets, modal name and number as well as that of your phone."
},
{
"end": 45.18,
"speakerId": "1",
"start": 39.08,
"text": "I bought a Plantronics Mark 2m165, and I use an iphone for S."
},
{
"end": 51.4,
"speakerId": "0",
"start": 45.34,
"text": "Okay, ma'am, so have you tried fairly pairing it with your headset with your phone?"
},
{
"end": 52.74,
"speakerId": "1",
"start": 51.4,
"text": "Yes, I have."
},
{
"end": 60.24,
"speakerId": "0",
"start": 53.22,
"text": "Okay, first, I need you to unpair your device with your phone."
},
{
"end": 61.42,
"speakerId": "1",
"start": 60.24,
"text": "I am, okay?"
},
{
"end": 63.1,
"speakerId": "0",
"start": 61.62,
"text": "Yes, ma'am."
},
{
"end": 65.46,
"speakerId": "1",
"start": 63.42,
"text": "OK, done."
},
{
"end": 72.64,
"speakerId": "0",
"start": 65.74,
"text": "Now, please switch off your phone, then turn it on again after around 5 s."
},
{
"end": 74.34,
"speakerId": "1",
"start": 72.64,
"text": "Switch it off and on."
},
{
"end": 75.78,
"speakerId": "0",
"start": 74.46,
"text": "Yes, please."
},
{
"end": 77.78,
"speakerId": "1",
"start": 75.98,
"text": "Done now what?"
},
{
"end": 80.74,
"speakerId": "0",
"start": 77.82,
"text": "Okay, please parry it with your phone."
},
{
"end": 84.26,
"speakerId": "1",
"start": 81.74,
"text": "Okay, now what."
},
{
"end": 88.19999999999999,
"speakerId": "0",
"start": 84.7,
"text": "Ma'am, is your headset working now? That's."
},
{
"end": 95.12,
"speakerId": "1",
"start": 88.19999999999999,
"text": "Just it I want to know how it works. I already told you that I have paired the device with my phone, but I am not sure if you get what I mean. I."
},
{
"end": 101.7,
"speakerId": "0",
"start": 95.12,
"text": "Well, yes, ma'am, I understand where you are coming from, that is why I am trying to help you, okay?"
},
{
"end": 107.7,
"speakerId": "1",
"start": 102.22,
"text": "Well, we have already done that. I only ask a simple question. Why can't you seem to get that?"
},
{
"end": 114.2,
"speakerId": "0",
"start": 108.14,
"text": "Yes, ma'am, I understand where you are coming from. That is why I am trying to help."
},
{
"end": 123.8,
"speakerId": "1",
"start": 114.2,
"text": "You know what, no 1 I do not think you do. We have been at this for over 30 min going around in circles. I would like to speak to your supervisor. I obviously will not get any help from you."
}
]}
endpoint = f'/ai/text/v1/async/summarize?webhook={urllib.parse.quote(WEBHOOK_URL)}'
resp = platform.post(endpoint, bodyParams)
jsonObj = resp.json()
if resp.response().status_code == 202:
print(f'Job ID: {resp.json().jobId}');
print(f'Ready to receive response at: {WEBHOOK_URL}');
else:
print(f'An error occurred posting the request.');
except Exception as e:
print ("Unable to call the summarize API. " + str(e))
# Authenticate a user using a personal JWT token
def login():
try:
platform.login( jwt= "RC_USER_JWT" )
conversation_summary()
except Exception as e:
print ("Unable to authenticate to platform. Check credentials. " + str(e))
# Instantiate the SDK and get the platform instance
rcsdk = SDK("RC_APP_CLIENT_ID", "RC_APP_CLIENT_SECRET", "https://platform.ringcentral.com")
platform = rcsdk.platform()
login()
<?php
require('vendor/autoload.php');
// Instantiate the SDK and get the platform instance
$rcsdk = new RingCentral\SDK\SDK( 'RC_APP_CLIENT_ID', 'RC_APP_CLIENT_SECRET', 'https://platform.ringcentral.com' );
$platform = $rcsdk->platform();
/* Authenticate a user using a personal JWT token */
$platform->login(["jwt" => 'RC_USER_JWT']);
$NGROK_ADDRESS = "NGROK-TUNNEL-ADDRESS";
$WEBHOOK_URL = $NGROK_ADDRESS . "/webhook";
conversation_summary();
/*
* Summarize the conversations
*/
function conversation_summary()
{
global $platform, $WEBHOOK_URL;
try {
$bodyParams = array (
'summaryType' => "All",
'utterances' => array (
array (
"end" => 8.96,
"speakerId" => "0",
"start" => 3.72,
"text" => "Good evening, thank you for calling electronics or this is Rachel. How may I assist you?"
),array (
"end" => 14.280000000000001,
"speakerId" => "1",
"start" => 8.96,
"text" => "Hi, Rachel. I would like to know how to use this car. Bluetooth headset I recently purchased from your store."
),array (
"end" => 21.36,
"speakerId" => "0",
"start" => 14.280000000000001,
"text" => "Sure, ma'am, I can help you out with that, but before anything else, I have your name so that I can address you properly."
),array (
"end" => 23.58,
"speakerId" => "1",
"start" => 21.36,
"text" => "Yes, this is Meredith Blake."
),array (
"end" => 29.72,
"speakerId" => "0",
"start" => 23.9,
"text" => "Okay, thank you for that, Mrs. Plague, what exactly do you want done with your headset?"
),array (
"end" => 31.939999999999998,
"speakerId" => "1",
"start" => 29.72,
"text" => "I want to know how to use it."
),array (
"end" => 39.08,
"speakerId" => "0",
"start" => 31.939999999999998,
"text" => "Okay, ma'am, I may get your headsets, modal name and number as well as that of your phone."
),array (
"end" => 45.18,
"speakerId" => "1",
"start" => 39.08,
"text" => "I bought a Plantronics Mark 2m165, and I use an iphone for S."
),array (
"end" => 51.4,
"speakerId" => "0",
"start" => 45.34,
"text" => "Okay, ma'am, so have you tried fairly pairing it with your headset with your phone?"
),array (
"end" => 52.74,
"speakerId" => "1",
"start" => 51.4,
"text" => "Yes, I have."
),array (
"end" => 60.24,
"speakerId" => "0",
"start" => 53.22,
"text" => "Okay, first, I need you to unpair your device with your phone."
),array (
"end" => 61.42,
"speakerId" => "1",
"start" => 60.24,
"text" => "I am, okay?"
),array (
"end" => 63.1,
"speakerId" => "0",
"start" => 61.62,
"text" => "Yes, ma'am."
),array (
"end" => 65.46,
"speakerId" => "1",
"start" => 63.42,
"text" => "OK, done."
),array (
"end" => 72.64,
"speakerId" => "0",
"start" => 65.74,
"text" => "Now, please switch off your phone, then turn it on again after around 5 s."
),array (
"end" => 74.34,
"speakerId" => "1",
"start" => 72.64,
"text" => "Switch it off and on."
),array (
"end" => 75.78,
"speakerId" => "0",
"start" => 74.46,
"text" => "Yes, please."
),array (
"end" => 77.78,
"speakerId" => "1",
"start" => 75.98,
"text" => "Done now what?"
),array (
"end" => 80.74,
"speakerId" => "0",
"start" => 77.82,
"text" => "Okay, please parry it with your phone."
),array (
"end" => 84.26,
"speakerId" => "1",
"start" => 81.74,
"text" => "Okay, now what."
),array (
"end" => 88.19999999999999,
"speakerId" => "0",
"start" => 84.7,
"text" => "Ma'am, is your headset working now? That's."
),array (
"end" => 95.12,
"speakerId" => "1",
"start" => 88.19999999999999,
"text" => "Just it I want to know how it works. I already told you that I have paired the device with my phone, but I am not sure if you get what I mean. I."
),array (
"end" => 101.7,
"speakerId" => "0",
"start" => 95.12,
"text" => "Well, yes, ma'am, I understand where you are coming from, that is why I am trying to help you, okay?"
),array (
"end" => 107.7,
"speakerId" => "1",
"start" => 102.22,
"text" => "Well, we have already done that. I only ask a simple question. Why can't you seem to get that?"
),array (
"end" => 114.2,
"speakerId" => "0",
"start" => 108.14,
"text" => "Yes, ma'am, I understand where you are coming from. That is why I am trying to help."
),array (
"end" => 123.8,
"speakerId" => "1",
"start" => 114.2,
"text" => "You know what, no 1 I do not think you do. We have been at this for over 30 min going around in circles. I would like to speak to your supervisor. I obviously will not get any help from you."
)
)
);
$endpoint = "/ai/text/v1/async/summarize?webhook=" . urlencode($WEBHOOK_URL);
$resp = $platform->post($endpoint, $bodyParams);
$jsonObj = $resp->json();
if ($resp->response()->getStatusCode() == 202) {
print_r ("Job ID: " . $jsonObj->jobId . PHP_EOL);
print_r("Ready to receive response at: " . $WEBHOOK_URL . PHP_EOL);
}
}catch (\RingCentral\SDK\Http\ApiException $e) {
// Getting error messages using PHP native interface
print_r ('HTTP Error: ' . $e->getMessage() . PHP_EOL);
// Another way to get message, but keep in mind, that there could be no response if request has failed completely
print_r ('Unable to call the summarize API. ' . $e->apiResponse->response()->error() . PHP_EOL);
}
}
?>
require 'ringcentral'
NGROK_ADDRESS = "NGROK-TUNNEL-ADDRESS"
WEBHOOK_URL = NGROK_ADDRESS + "/webhook";
#
# Summarize the conversations
#
def conversation_summary()
bodyParams = {
'summaryType': "All",
'utterances': [
{
"end": 8.96,
"speakerId": "0",
"start": 3.72,
"text": "Good evening, thank you for calling electronics or this is Rachel. How may I assist you?"
},
{
"end": 14.280000000000001,
"speakerId": "1",
"start": 8.96,
"text": "Hi, Rachel. I would like to know how to use this car. Bluetooth headset I recently purchased from your store."
},
{
"end": 21.36,
"speakerId": "0",
"start": 14.280000000000001,
"text": "Sure, ma'am, I can help you out with that, but before anything else, I have your name so that I can address you properly."
},
{
"end": 23.58,
"speakerId": "1",
"start": 21.36,
"text": "Yes, this is Meredith Blake."
},
{
"end": 29.72,
"speakerId": "0",
"start": 23.9,
"text": "Okay, thank you for that, Mrs. Plague, what exactly do you want done with your headset?"
},
{
"end": 31.939999999999998,
"speakerId": "1",
"start": 29.72,
"text": "I want to know how to use it."
},
{
"end": 39.08,
"speakerId": "0",
"start": 31.939999999999998,
"text": "Okay, ma'am, I may get your headsets, modal name and number as well as that of your phone."
},
{
"end": 45.18,
"speakerId": "1",
"start": 39.08,
"text": "I bought a Plantronics Mark 2m165, and I use an iphone for S."
},
{
"end": 51.4,
"speakerId": "0",
"start": 45.34,
"text": "Okay, ma'am, so have you tried fairly pairing it with your headset with your phone?"
},
{
"end": 52.74,
"speakerId": "1",
"start": 51.4,
"text": "Yes, I have."
},
{
"end": 60.24,
"speakerId": "0",
"start": 53.22,
"text": "Okay, first, I need you to unpair your device with your phone."
},
{
"end": 61.42,
"speakerId": "1",
"start": 60.24,
"text": "I am, okay?"
},
{
"end": 63.1,
"speakerId": "0",
"start": 61.62,
"text": "Yes, ma'am."
},
{
"end": 65.46,
"speakerId": "1",
"start": 63.42,
"text": "OK, done."
},
{
"end": 72.64,
"speakerId": "0",
"start": 65.74,
"text": "Now, please switch off your phone, then turn it on again after around 5 s."
},
{
"end": 74.34,
"speakerId": "1",
"start": 72.64,
"text": "Switch it off and on."
},
{
"end": 75.78,
"speakerId": "0",
"start": 74.46,
"text": "Yes, please."
},
{
"end": 77.78,
"speakerId": "1",
"start": 75.98,
"text": "Done now what?"
},
{
"end": 80.74,
"speakerId": "0",
"start": 77.82,
"text": "Okay, please parry it with your phone."
},
{
"end": 84.26,
"speakerId": "1",
"start": 81.74,
"text": "Okay, now what."
},
{
"end": 88.19999999999999,
"speakerId": "0",
"start": 84.7,
"text": "Ma'am, is your headset working now? That's."
},
{
"end": 95.12,
"speakerId": "1",
"start": 88.19999999999999,
"text": "Just it I want to know how it works. I already told you that I have paired the device with my phone, but I am not sure if you get what I mean. I."
},
{
"end": 101.7,
"speakerId": "0",
"start": 95.12,
"text": "Well, yes, ma'am, I understand where you are coming from, that is why I am trying to help you, okay?"
},
{
"end": 107.7,
"speakerId": "1",
"start": 102.22,
"text": "Well, we have already done that. I only ask a simple question. Why can't you seem to get that?"
},
{
"end": 114.2,
"speakerId": "0",
"start": 108.14,
"text": "Yes, ma'am, I understand where you are coming from. That is why I am trying to help."
},
{
"end": 123.8,
"speakerId": "1",
"start": 114.2,
"text": "You know what, no 1 I do not think you do. We have been at this for over 30 min going around in circles. I would like to speak to your supervisor. I obviously will not get any help from you."
}
]}
queryParams = {
'webhook': WEBHOOK_URL
}
endpoint = "/ai/text/v1/async/summarize"
begin
resp = $platform.post(endpoint, payload: bodyParams, params: queryParams)
body = resp.body
if resp.status == 202
puts('Job ID: ' + body['jobId']);
puts ('Ready to receive response at: ' + WEBHOOK_URL);
else
puts ('An error occurred posting the request.')
end
rescue StandardError => e
puts ("Unable to call the summarize API. " + e.to_s)
end
end
# Authenticate a user using a personal JWT token
def login()
begin
$platform.authorize( jwt: "RC_USER_JWT" )
conversation_summary()
rescue StandardError => e
puts ("Unable to authenticate to platform. Check credentials. " + e.to_s)
end
end
# Instantiate the SDK and get the platform instance
$platform = RingCentral.new( "RC_APP_CLIENT_ID", "RC_APP_CLIENT_SECRET", "https://platform.ringcentral.com" )
login()
using System;
using System.IO;
using System.Threading.Tasks;
using System.Collections.Generic;
using RingCentral;
using Newtonsoft.Json;
namespace SummarizeConversation {
class Program {
static RestClient restClient;
static string NGROK_ADDRESS = "NGROK-TUNNEL-ADDRESS";
static string WEBHOOK_URL = NGROK_ADDRESS + "/webhook";
static async Task Main(string[] args){
try
{
// Instantiate the SDK
restClient = new RestClient("RC_APP_CLIENT_ID", "RC_APP_CLIENT_SECRET", "https://platform.ringcentral.com");
// Authenticate a user using a personal JWT token
await restClient.Authorize("RC_USER_JWT");
await conversation_summary();
}
catch (Exception ex)
{
Console.WriteLine("Unable to authenticate to platform. Check credentials. " + ex.Message);
}
}
/*
* Summarize the conversations
*/
static private async Task conversation_summary()
{
try
{
string utterancesJson = "[{'end':8.96,'speakerId':'0','start':3.72,'text':'Good evening, thank you for calling electronics or this is Rachel. How may I assist you?'},{'end':14.280000000000001,'speakerId':'1','start':8.96,'text':'Hi, Rachel. I would like to know how to use this car. Bluetooth headset I recently purchased from your store.'},{'end':21.36,'speakerId':'0','start':14.280000000000001,'text':'Sure, ma\\'am, I can help you out with that, but before anything else, I have your name so that I can address you properly.'},{'end':23.58,'speakerId':'1','start':21.36,'text':'Yes, this is Meredith Blake.'},{'end':29.72,'speakerId':'0','start':23.9,'text':'Okay, thank you for that, Mrs. Plague, what exactly do you want done with your headset?'},{'end':31.939999999999998,'speakerId':'1','start':29.72,'text':'I want to know how to use it.'},{'end':39.08,'speakerId':'0','start':31.939999999999998,'text':'Okay, ma\\'am, I may get your headsets, modal name and number as well as that of your phone.'},{'end':45.18,'speakerId':'1','start':39.08,'text':'I bought a Plantronics Mark 2m165, and I use an iphone for S.'},{'end':51.4,'speakerId':'0','start':45.34,'text':'Okay, ma\\'am, so have you tried fairly pairing it with your headset with your phone?'},{'end':52.74,'speakerId':'1','start':51.4,'text':'Yes, I have.'},{'end':60.24,'speakerId':'0','start':53.22,'text':'Okay, first, I need you to unpair your device with your phone.'},{'end':61.42,'speakerId':'1','start':60.24,'text':'I am, okay?'},{'end':63.1,'speakerId':'0','start':61.62,'text':'Yes, ma\\'am.'},{'end':65.46,'speakerId':'1','start':63.42,'text':'OK, done.'},{'end':72.64,'speakerId':'0','start':65.74,'text':'Now, please switch off your phone, then turn it on again after around 5 s.'},{'end':74.34,'speakerId':'1','start':72.64,'text':'Switch it off and on.'},{'end':75.78,'speakerId':'0','start':74.46,'text':'Yes, please.'},{'end':77.78,'speakerId':'1','start':75.98,'text':'Done now what?'},{'end':80.74,'speakerId':'0','start':77.82,'text':'Okay, please parry it with your phone.'},{'end':84.26,'speakerId':'1','start':81.74,'text':'Okay, now what.'},{'end':88.19999999999999,'speakerId':'0','start':84.7,'text':'Ma\\'am, is your headset working now? That\\'s.'},{'end':95.12,'speakerId':'1','start':88.19999999999999,'text':'Just it I want to know how it works. I already told you that I have paired the device with my phone, but I am not sure if you get what I mean. I.'},{'end':101.7,'speakerId':'0','start':95.12,'text':'Well, yes, ma\\'am, I understand where you are coming from, that is why I am trying to help you, okay?'},{'end':107.7,'speakerId':'1','start':102.22,'text':'Well, we have already done that. I only ask a simple question. Why can\\'t you seem to get that?'},{'end':114.2,'speakerId':'0','start':108.14,'text':'Yes, ma\\'am, I understand where you are coming from. That is why I am trying to help.'},{'end':123.8,'speakerId':'1','start':114.2,'text':'You know what, no 1 I do not think you do. We have been at this for over 30 min going around in circles. I would like to speak to your supervisor. I obviously will not get any help from you.'}]";
var utt = JsonConvert.DeserializeObject<dynamic>(utterancesJson);
var utterances = new List<SummaryUnit>();
foreach (var u in utt)
{
var unit = new SummaryUnit();
unit.end = (decimal) u.end;
unit.start = (decimal) u.start;
unit.speakerId = u.speakerId;
unit.text = u.text;
utterances.Add(unit);
}
var bodyParams = new SummaryInput();
bodyParams.summaryType = "All";
bodyParams.utterances = utterances.ToArray();
var callbackAddress = Environment.GetEnvironmentVariable("NGROK_URL") + "/webhook";
var queryParams = new CaiSummarizeParameters() { webhook = callbackAddress };
var resp = await restClient.Ai().Text().V1().Async().Summarize().Post(bodyParams, queryParams);
Console.WriteLine("Job ID: " + resp.jobId);
Console.WriteLine("Ready to receive response at: " + callbackAddress);
}
catch (Exception ex)
{
Console.WriteLine("Unable to call punctuate API. " + ex.Message);
}
}
}
}
package SummarizeConversation;
import java.io.IOException;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.ringcentral.*;
import com.ringcentral.definitions.*;
public class SummarizeConversation {
static String NGROK_ADDRESS = "NGROK-TUNNEL-ADDRESS";
static String WEBHOOK_URL = NGROK_ADDRESS + "/webhook";
static RestClient restClient;
public static void main(String[] args) {
var obj = new SummarizeConversation();
try {
// Instantiate the SDK
restClient = new RestClient("RC_APP_CLIENT_ID", "RC_APP_CLIENT_SECRET", "https://platform.ringcentral.com");
// Authenticate a user using a personal JWT token
restClient.authorize("RC_USER_JWT");
obj.conversation_summary();
} catch (RestException e) {
System.out.println(e.getMessage());
} catch (IOException e) {
e.printStackTrace();
}
}
/*
* Summarize the conversations
*/
static private void conversation_summary() throws RestException, IOException {
try {
ArrayList<SummaryUnit> utterances = new ArrayList<>();
String utterancesStr = "{'utterances':[{'end':8.96,'speakerId':'0','start':3.72,'text':'Good evening, thank you for calling electronics or this is Rachel. How may I assist you?'},{'end':14.280000000000001,'speakerId':'1','start':8.96,'text':'Hi, Rachel. I would like to know how to use this car. Bluetooth headset I recently purchased from your store.'},{'end':21.36,'speakerId':'0','start':14.280000000000001,'text':'Sure, ma\\'am, I can help you out with that, but before anything else, I have your name so that I can address you properly.'},{'end':23.58,'speakerId':'1','start':21.36,'text':'Yes, this is Meredith Blake.'},{'end':29.72,'speakerId':'0','start':23.9,'text':'Okay, thank you for that, Mrs. Plague, what exactly do you want done with your headset?'},{'end':31.939999999999998,'speakerId':'1','start':29.72,'text':'I want to know how to use it.'},{'end':39.08,'speakerId':'0','start':31.939999999999998,'text':'Okay, ma\\'am, I may get your headsets, modal name and number as well as that of your phone.'},{'end':45.18,'speakerId':'1','start':39.08,'text':'I bought a Plantronics Mark 2m165, and I use an iphone for S.'},{'end':51.4,'speakerId':'0','start':45.34,'text':'Okay, ma\\'am, so have you tried fairly pairing it with your headset with your phone?'},{'end':52.74,'speakerId':'1','start':51.4,'text':'Yes, I have.'},{'end':60.24,'speakerId':'0','start':53.22,'text':'Okay, first, I need you to unpair your device with your phone.'},{'end':61.42,'speakerId':'1','start':60.24,'text':'I am, okay?'},{'end':63.1,'speakerId':'0','start':61.62,'text':'Yes, ma\\'am.'},{'end':65.46,'speakerId':'1','start':63.42,'text':'OK, done.'},{'end':72.64,'speakerId':'0','start':65.74,'text':'Now, please switch off your phone, then turn it on again after around 5 s.'},{'end':74.34,'speakerId':'1','start':72.64,'text':'Switch it off and on.'},{'end':75.78,'speakerId':'0','start':74.46,'text':'Yes, please.'},{'end':77.78,'speakerId':'1','start':75.98,'text':'Done now what?'},{'end':80.74,'speakerId':'0','start':77.82,'text':'Okay, please parry it with your phone.'},{'end':84.26,'speakerId':'1','start':81.74,'text':'Okay, now what.'},{'end':88.19999999999999,'speakerId':'0','start':84.7,'text':'Ma\\'am, is your headset working now? That\\'s.'},{'end':95.12,'speakerId':'1','start':88.19999999999999,'text':'Just it I want to know how it works. I already told you that I have paired the device with my phone, but I am not sure if you get what I mean. I.'},{'end':101.7,'speakerId':'0','start':95.12,'text':'Well, yes, ma\\'am, I understand where you are coming from, that is why I am trying to help you, okay?'},{'end':107.7,'speakerId':'1','start':102.22,'text':'Well, we have already done that. I only ask a simple question. Why can\\'t you seem to get that?'},{'end':114.2,'speakerId':'0','start':108.14,'text':'Yes, ma\\'am, I understand where you are coming from. That is why I am trying to help.'},{'end':123.8,'speakerId':'1','start':114.2,'text':'You know what, no 1 I do not think you do. We have been at this for over 30 min going around in circles. I would like to speak to your supervisor. I obviously will not get any help from you.'}]}";
JSONObject jsonObject = new JSONObject(utterancesStr);
JSONArray utterancesArray = jsonObject.getJSONArray("utterances");
for (int i = 0, size = utterancesArray.length(); i < size; i++) {
JSONObject u = utterancesArray.getJSONObject(i);
var unit = new SummaryUnit();
unit.end = u.getDouble("end");
unit.start = u.getDouble("start");
unit.speakerId = u.getString("speakerId");
unit.text = u.getString("text");
utterances.add(unit);
}
var bodyParams = new SummaryInput();
bodyParams.summaryType = "All";
bodyParams.utterances = utterances.toArray(new SummaryUnit[utterances.size()]);
var callbackAddress = System.getenv("WEBHOOK_URL") + "/webhook";
var queryParams = new CaiSummarizeParameters().webhook(callbackAddress);
var resp = restClient.ai().text().v1().async().summarize().post(bodyParams, queryParams);
System.out.println("Job ID: " + resp.jobId);
System.out.println("Ready to receive response at: " + callbackAddress);
} catch (RestException ex) {
System.out.println("Unable to call the summarize API. " + ex.getMessage());
}
}
}
Sample response
{
"status": "Success",
"response": {
"summaries": [
{
"name": "Extractive",
"values": [
{
"value": "Commonly referred to as a “self-service” solution, a knowledge base.
Lets your customers find answers to their support questions without
having to speak to a person on your team and taking up their precious
time.",
"start": 0.12,
"end": 1.12,
"speakerId": "",
"confidence": 0.5238
},
{
"value": "A knowledge base can include any variety of resources that help
customers get the most from a product or service, including howto
guides, video tutorials, Faqs, white papers, case studies and even
user forums.",
"start": 0.12,
"end": 1.12,
"speakerId": "",
"confidence": 0.5143
}
]
}
]
}
}
Summaries Object
Parameter | Type | Description |
---|---|---|
summaries |
List[Summary-Output-Unit] | Summary-Output Unit object defined below |
Summary-Output Unit
Parameter | Type | Description |
---|---|---|
name |
Enum | Options: Extractive , AbstractiveLong , AbstractiveShort |
values |
List[Summary-Timings-Unit] | Summary-Output Unit object defined below |
Summary-Timings Unit
Parameter | Type | Description |
---|---|---|
start |
Number | Start time of the summary segment in seconds. |
end |
Number | End time of the summary segment in seconds. |
value |
String | Text of the summary segment. |
confidence |
Number | confidence score for the summary segment |