Salesforce Voice - Dev - Guide
Salesforce Voice - Dev - Guide
Implementation Guide
Version 61.0, Summer ’24
names and marks. Other marks appearing herein may be trademarks of their respective owners.
CONTENTS
Chapter 1: Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1
Service Cloud Voice Implementation Guide
SEE ALSO:
Service Cloud Voice Learning Map
Salesforce Help: Service Cloud Voice
Trailhead: Service Cloud Voice
2
CHAPTER 2 Examples of Common Use Cases
In this chapter ... Salesforce and Amazon Web Services provide examples to help you get started using Service Cloud
Voice. These examples illustrate how to implement common use cases such as SMS transfers, linking
• Pass Data from the calls to cases, and voicemail setup. The examples are foundational, so you can build upon them to
Interactive Voice support your company’s business processes.
Response (IVR)
System Your business processes might be a bit different than those reflected in the examples. In many cases,
you can modify an example to achieve your desired result. For instance, an example that shows how to
• Set Up Call
automatically link a call record to a case record can be modified to link to a lead record or other type of
Transcription
record.
• Link New or Existing
Case to Voice Call Each example indicates the ease of implementation and estimated time to implement. They assume a
Record familiarity with basic Salesforce admin skills.
• Give Customers the Amazon Connect’s solutions team also offers implementation examples for Service Cloud Voice. These
Option to Transfer to examples demonstrate how to complete tasks like letting customers leave voicemails for agents. We’ve
SMS in the Interactive introduced a selection of them in Examples from Amazon Connect. For a full list, see the Amazon Connect
Voice Response (IVR) Campground for Service Cloud Voice in GitHub. Salesforce does not maintain the examples provided
• Enable the Option to by Amazon Connect.
Request a Callback
• CTR Sync with
Amazon Connect
• Enable Voice Call
Transfers Using
Omni-Channel Flows
and Amazon
Connect
• Refresh a Sandbox
• Enable Voicemail
Support
• Set the Voice Call
Record Type
• Disable Call
Recording
• Enable the Voice
Extension Page in
Lightning App Builder
• Examples from
Amazon Connect
3
Examples of Common Use Cases Pass Data from the Interactive Voice Response (IVR) System
Prerequisites
If your contact center was created before the Spring ’21 release, download the Sample SCV Inbound Flow contact flow from the Service
Cloud Voice repo on Github. Import it into Amazon Connect if it’s not already imported. Be sure to update the Invoke AWS Lambda
function block so that it correctly points to the Lambda function in your Amazon Connect instance. If your contact center was created
after the Spring ’21 release, this contact flow is already installed into Amazon Connect.
To implement this use case, you need either the AWS root user or AWS administrator credentials.
4
Examples of Common Use Cases Pass Data from the Interactive Voice Response (IVR) System
5
Examples of Common Use Cases Set Up Call Transcription
6
Examples of Common Use Cases Transcribe Calls with Amazon Transcribe
SEE ALSO:
kvsConsumerTrigger Lambda Function
Amazon Connect Flows
Salesforce Help: Update Your Contact Center
Prerequisites
To implement this use case, you need either the AWS root user or AWS administrator credentials.
7
Examples of Common Use Cases Transcribe Calls with Amazon Transcribe
• To process speech more accurately, set up your custom vocabulary in Amazon Transcribe. This feature is useful for domain-specific
terminology.
• To mask or remove words that you don’t want to appear in the transcription, set up vocabulary filtering in Amazon Transcribe.
Be sure to record the name of the custom vocabulary and the name of the filter for the next step.
To verify that you’ve selected the correct block, check that it ends with the string kvsConsumerTrigger.
8
Examples of Common Use Cases Transcribe Calls with Amazon Transcribe
2. If you have a custom vocabulary, add a vocabularyName parameter to this block with the name of your custom vocabulary
that you created earlier.
3. If you have vocabulary filtering in place, add a vocabularyFilterName parameter to this block with the name of your
vocabulary filter that you created earlier. Also, add a vocabularyFilterMethod parameter with one of the following values:
mask or remove. mask replaces the term with asterisks. remove removes the term from the transcript. If no
vocabularyFilterMethod parameter is provided, the behavior defaults to mask.
9
Examples of Common Use Cases Transcribe Calls with Amazon Transcribe
4. Save the block and contact flow, and then publish your contact flow.
SEE ALSO:
Amazon Transcribe: Custom vocabularies
Amazon Transcribe: Vocabulary filtering
10
Examples of Common Use Cases Transcribe Longer Calls with Contact Lens
11
Examples of Common Use Cases Transcribe Longer Calls with Contact Lens
1. From the AWS Management Console, select Amazon Connect > Analytics tools.
2. Verify that Enable Contact Lens is enabled (selected).
3. Click Save.
Prerequisites
To run through this example, update your contact center to the latest version. To get the latest version of these contact flows, see Update
Your Contact Center. If you don’t update your contact center, you can have older versions of the contact flows with different names.
Prerequisites
To run through this example, update your contact center to the latest version. To get the latest version of these contact flows, see Update
Your Contact Center. If you don’t update your contact center, you can have older versions of the contact flows with different names.
12
Examples of Common Use Cases Transcribe Longer Calls with Contact Lens
Older versions of the sample contact flows use transcription with Amazon Transcribe. To use transcription with Contact Lens instead,
remove the Invoke AWS Lambda function block that contains the kvsConsumerTrigger Lambda function and replace it with this recording
block with the option enabled.
Tip: To learn how to set the Contact Lens options, view the settings for this block in the latest, packaged contact flows, which are
available in GitHub.
SEE ALSO:
kvsConsumerTrigger Lambda Function
Amazon Connect Flows
Salesforce Help: Update Your Contact Center
Amazon Documentation: Contact Lens for Amazon Connect
In this example, we show you how to add a custom vocabulary with Contact Lens.
Prerequisites
To run through this example, create your custom vocabulary file first. To learn how to create a file, review the text and links on the screen
when asked to upload the file.
13
Examples of Common Use Cases Transcribe Longer Calls with Contact Lens
14
Examples of Common Use Cases Transcribe Longer Calls with Contact Lens
15
Examples of Common Use Cases Link New or Existing Case to Voice Call Record
SEE ALSO:
Amazon Documentation: Create a Custom Vocabulary Using a Table
One of the advantages of Service Cloud Voice is that a Voice Call record is created to track every interaction. By capturing caller inputs
from the IVR on the Voice Call record, you can use Salesforce automation tools, such as Process Builder, Flow, or APEX, to automatically
create or link Salesforce records and display them to the agent for caller context. You can also report on caller selections.
In this example, we show you how to:
• Import a sample contact flow into Amazon Connect that updates two custom fields in Salesforce.
• Add a Salesforce flow that takes action in Salesforce based on contact flow values passed to the custom fields.
The first custom field is called IVRType. We use this field to store the calls IVR Type or selection (for example: Press 1 for a new case,
Press 2 for an existing case). The second custom field, IVRInput, is used to store a customer input such as case subject or case number.
The Salesforce flow creates a new case or finds an existing case and links it to the voice call record to add context for the agent.
You can modify this example to support your business processes. For example, create or find a lead instead of a case.
16
Examples of Common Use Cases Link New or Existing Case to Voice Call Record
Prerequisites
To run through this example:
• You must be an AWS admin with the ability to import contact flows. To learn more, see Import/export contact flows in the Amazon
Connect Administrator Guide.
• You must be a Salesforce admin with the ability to install packages. To learn more, see Install a package in Salesforce Help.
17
Examples of Common Use Cases Link New or Existing Case to Voice Call Record
3. Click Activate. When active, the flow makes the following changes.
• When IVRType = ExistingCase, the flow finds the case that matches the case number entered in the IVR and links it
to the Voice Call record.
• For any other IVRType value, a new case is created and linked to the Voice Call record.
4. (Optional) Modify the flow to add more paths by adding conditions and actions to the Decision Element.
18
Examples of Common Use Cases Link New or Existing Case to Voice Call Record
1. Download the “SCVCB - RouteToAgent” contact flow from our GitHub repo.
Note: From GitHub, right-click the Raw button to download or save the linked file. After downloading, you must remove the
.txt extension (so that there is no file extension) before attempting to upload it to Amazon Connect. Alternatively, clone
our GitHub repository to download all examples at once. This contact flow resides in the
Recipes/LinkCasetoVoiceCall folder.
Note: To learn what this function does, see InvokeTelephonyIntegrationApiFunction Lambda Function on page 123.
8. In the second “Invoke AWS Lambda function” block (item 2 in screenshot), click the block to open the options and replace the
function with your xxxx-kvsConsumerTrigger Lambda function. Click Save.
Note: To learn what this function does, see kvsConsumerTrigger Lambda Function on page 137.
9. In the “Set working queue” block (item 3 in screenshot), click the block to open the options and replace the queue with your queue
(for example, “BasicQueue”).
10. Click Publish to save and publish the flow.
19
Examples of Common Use Cases Link New or Existing Case to Voice Call Record
In this contact flow, we map contact attributes to custom fields on the Voice Call record by using the naming convention
“sfdc-{DeveloperName}”. We use the developer name for the custom field in Salesforce, including the “__c” suffix used for all custom
fields. When the InvokeTelephonyIntegrationApiFunction Lambda function creates a Voice Call record, it looks for all contact attributes
with this format and maps them to the appropriate Salesforce field.
1. Download the “SCVCB - New or Existing Case” contact flow from our GitHub repo.
Note: From GitHub, right-click the Raw button to download or save the linked file. After downloading, you must remove the
.txt extension (so that there is no file extension) before attempting to upload it to Amazon Connect. Alternatively, clone
our GitHub repository to download all examples at once. This contact flow resides in the
Recipes/LinkCasetoVoiceCall folder.
20
Examples of Common Use Cases Give Customers the Option to Transfer to SMS in the
Interactive Voice Response (IVR)
4. Click Save.
5. In Salesforce, log in to Omni-Channel so you are ready to accept calls.
6. Dial the number and test the new contact flow.
7. Accept the call in Omni-Channel:
a. If you selected New Case, you see that a new case has been created and linked to the Voice record in the Related Record field.
b. If you selected Existing Case, you see the case linked to the Voice record in the Related Record field.
Note: This example assumes a four-digit case number. If your case numbers use a different number of digits, modify the example.
1. In the “SCVCB - New Or Existing Case” contact flow, open the “Store customer contact” block and change the Custom Maximum
Digits value.
2. In the “SCVCB - Voice Actions” flow, update the Get8DigitCaseNumber formula to append the necessary number of zeros to
match the Salesforce case number.
Prerequisites
To run through this example:
• You must have at least one Digital Engagement license to enable SMS capabilities.
• You must have a working SMS channel in Salesforce.
• You must complete the previous example: Link New or Existing Case to Voice Call Record on page 16.
To learn more about SMS Text Messaging with Salesforce, see Set Up SMS Text Messaging.
21
Examples of Common Use Cases Give Customers the Option to Transfer to SMS in the
Interactive Voice Response (IVR)
4. Click Save.
2. From Setup, enter Flows in the Quick Find box, then select Flows under Process Automation.
3. Open the “SCVB - Voice Actions” flow.
4. Add an outcome to the “IVRSelection” decision element.
a. Click Edit Element on the decision element.
b. Click the + next to Outcome Order.
c. Complete the fields as follows.
22
Examples of Common Use Cases Give Customers the Option to Transfer to SMS in the
Interactive Voice Response (IVR)
Resource $Record.IVRType__c
IVRType__c is a custom field for the VoiceCall Salesforce object.
Operator Equals
Value IVRTransfer
This value matches the value set in the Contact Flow.
23
Examples of Common Use Cases Give Customers the Option to Transfer to SMS in the
Interactive Voice Response (IVR)
b. From the New Action page, search for and select Messaging Notification.
c. Complete the fields as follows.
Messaging Channel Unique Name Enter the Developer Name for your messaging channel that you recorded earlier. For
example, Text_US_15551234567.
Messaging Template Unique Name Select the template you previously created (IVRTransfer).
Recipient Phone Number Change the toggle to “Include” and select New Resource for the field value. Complete
the fields as follows, and then click Done.
• Resource Type: Formula
• API Name: SMSPhone
• Data Type: Text
• Formula: Enter RIGHT({!$Record.FromPhoneNumber}, 10). In other
markets, such as in the UK, if the caller number is already in E164 format, use
{!$Record.FromPhoneNumber} to ensure the outbound SMS is sent.
Note: Amazon Connect passes in the caller’s phone number in E164 format. We
use a formula to convert the number to the necessary format. (This example
assumes US-based phone numbers. For example, +155512234567 is converted
to 5551234567.)
24
Examples of Common Use Cases Give Customers the Option to Transfer to SMS in the
Interactive Voice Response (IVR)
25
Examples of Common Use Cases Give Customers the Option to Transfer to SMS in the
Interactive Voice Response (IVR)
6. On your flow with the new outcome, click Save As, and then click Save.
26
Examples of Common Use Cases Give Customers the Option to Transfer to SMS in the
Interactive Voice Response (IVR)
1. Download the “SCVCB - SMS Transfer” contact flow from our GitHub repo.
Note: From GitHub, right-click the Raw button to download or save the linked file. After downloading, you must remove the
.txt extension (so that there is no file extension) before attempting to upload it to Amazon Connect. Alternatively, clone
27
Examples of Common Use Cases Give Customers the Option to Transfer to SMS in the
Interactive Voice Response (IVR)
our GitHub repository to download all examples at once. This contact flow resides in the Recipes/TransfertoSMSinIVR
folder.
Step 4: Add SMS to the “SCVCB - New Or Existing Case” Contact Flow
Update the “SCVCB - New Or Existing Case” contact flow from the previous example (Link New or Existing Case to Voice Call Record on
page 16) to include the SMS option.
28
Examples of Common Use Cases Enable the Option to Request a Callback
Tip: If you don’t see this flow, go back to that contact flow and click Publish. Only published flows appear in the list.
c. Click Save.
4. Connect Option 3 of the “Get customer input” block to the left side of this “Transfer to flow” block.
5. Add an error message to the “Transfer to flow” block (item 2 in screenshot).
a. From the left panel, in the “Interact” section, drag the “Play prompt” block to the right of the “Transfer to flow” block.
b. Open the “Play prompt” block and select Text-to-speech or chat text.
c. Enter this text: Error with transfer to SMS flow..
d. Click Save.
6. Connect the output of the “Play prompt” block to one of the closest “Disconnect” blocks.
7. Click Publish.
The IVR looks at how long the last person in the queue has been waiting. The wait time is five minutes by default. If the wait time is
greater than the specified time, the IVR asks if the caller wants to continue waiting or to request a callback.
If the caller opts for the callback, the IVR asks the caller to enter a phone number.
When an agent becomes available, the callback request is pushed to the agent in the Omni-Channel utility. If the agent accepts the
callback request, the phone number is automatically dialed.
29
Examples of Common Use Cases Enable the Option to Request a Callback
Prerequisites
If your contact center was created before the Spring ’21 release, download the updated Sample SCV Inbound Flow contact flow from
the Service Cloud Voice repo on Github. Import it into Amazon Connect.
If your contact center was created after the Spring ’21 release, then it already contains the Sample SCV Inbound Flow, so you can skip
the first step.
To implement this use case, you need either the AWS root user or AWS administrator credentials.
Note: If a callback gets voicemail, Amazon Connect treats it as a completed callback and doesn’t retry the call.
• Minimum time between attempts: If the customer doesn't answer the phone, this setting is how long the system waits before
trying again.
30
Examples of Common Use Cases CTR Sync with Amazon Connect
SEE ALSO:
Amazon Connect Administrator Guide: Set up queued callback
Amazon Connect Administrator Guide: About queued callbacks in metrics
31
Examples of Common Use Cases Retry CTR Sync for Voice Call Records
Contact Trace Records are generated on Amazon for each call. This data contains the details about the call including caller and agent
information, call statistics, and queue information. The CTRDataSyncFunction on page 132 Lambda automatically runs for each call in
order to store this data in a Voice Call record. CTRs aren’t retained by Amazon and if the CTR sync process fails for any reason, you could
lose important information about the call.
This solution provides a way to reattempt a sync of the CTR data by first backing up CTR data in a separate Amazon S3 bucket, then
checking for any sync failures, and then re-uploading CTR data whenever necessary.
Prerequisites
To run this example:
1. Have your AWS root user or AWS administrator credentials ready.
2. Be familiar with Amazon S3 buckets. To learn more, see Amazon’s documentation: Creating and configuring an S3 bucket.
3. Be familiar with modifying Amazon Connect Lambda functions. To learn more, see Amazon’s documentation: AWS Lambda Developer
Guide.
4. Configure the OAuth support for the InvokeSalesforceRestApiFunction Lambda on page 116 function. This is required to support the
getAccessToken function.
32
Examples of Common Use Cases Retry CTR Sync for Voice Call Records
event.Records.forEach((record) => {
const payload = Buffer.from(record.kinesis.data, 'base64').toString('ascii');
const ctr = JSON.parse(payload);
if (ctr.ContactId) {
writeCTRToS3(ctr); // ADD THIS LINE: Call to write to S3
const voiceCall = utils.transformCTR(ctr);
promises.push(updateVoiceCallRecord(voiceCall));
} else {
console.log("No ContactId found in CTR: " + JSON.stringify(ctr));
}
});
33
Examples of Common Use Cases Retry CTR Sync for Voice Call Records
There’s one object in S3 for every CTR generated. The object is named with the ContactId of the CTR, so it’s easy to look up.
2. Fetch CTRs from S3. If there are results returned from the previous step, then read from the S3 bucket to fetch CTRs for the given
Voice Call records. Look up this data with the VendorCallKey.
3. Update Voice Call records in the org. Update Voice Call records based on the information returned from the previous step.
Important: This code calls the InvokeTelephonyIntegrationApiFunction on page 123 Lambda. You can make this call in one of
the following two ways:
a) Declare an environment variable for that Lambda and reference it from your code.
b) Hard-code the ARN of the InvokeTelephonyIntegrationApiFunction on page 123 Lambda into your code.
This sample code assumes that there’s an environment variable named INVOKE_TELEPHONY_INTEGRATION_API_ARN (option a),
but you can hard-code the ARN if you prefer.
The following code updates to InvokeSalesforceRestApiFunction on page 120 perform all of the above actions.
Updates to sfRestApi.js.
// Include required JS Modules
const aws = require('aws-sdk');
const lambda = new aws.Lambda();
const s3 = new aws.S3();
if (response.data.errorType) {
console.log("Error querying VoiceCalls: " + response.data.errorMessage);
return {
success: false,
errorMessage: response.data.errorMessage
};
} else if (response.data.totalSize === 0) {
console.log("No VoiceCalls were found that were missing CTR update");
return {};
} else {
console.log("Successfully queried for VoiceCalls");
34
Examples of Common Use Cases Retry CTR Sync for Voice Call Records
if (ctr.ContactId) {
const voiceCall = utils.transformCTR(ctr);
promises.push(updateVoiceCallRecord(voiceCall));
} else {
console.log("No ContactId found in CTR");
}
});
35
Examples of Common Use Cases Retry CTR Sync for Voice Call Records
const params = {
// NEW: Create this as an environment variable
// or hard-code the ARN of the Lambda
FunctionName: process.env.INVOKE_TELEPHONY_INTEGRATION_API_ARN,
Payload: JSON.stringify(payload)
};
return lambda.invoke(params).promise();
}
Updates to QueryEngine.js.
// NEW function to that exposes the Retry CTR
async function retryCTRSync(query, args) {
var formattedQuery = formatQuery(args, query);
return await api.retryCtrSync(formattedQuery);
}
Updates to Handler.js.
// NEW function to dispatch CTR sync
async function dispatch_ctrsync(soql, event){
const parameters = event.Details.Parameters;
let response;
try {
const queryResult = await queryEngine.retryCTRSync(soql, parameters);
response = {
36
Examples of Common Use Cases Retry CTR Sync for Voice Call Records
statusCode: 200,
result: queryResult
}
}
catch (e) {
response = {
statusCode: e.response.status ? e.response.status : 500,
result: e
}
}
return flatten(response);
}
Updates to utils.js.
The following two functions (transformCTR and getCallAttributes) are copied over from CTRDataSyncFunction on page
132 Lambda utils.js. (Alternatively, directly modify CTRDataSyncFunction on page 132 Lambda to support taking a single CTR and
updating the Voice Call record from there.)
// COPIED function to transform CTR
function transformCTR(ctr) {
const voiceCall = {};
voiceCall.startTime = ctr.InitiationTimestamp;
voiceCall.endTime = ctr.DisconnectTimestamp;
voiceCall.parentCallIdentifier = ctr.PreviousContactId;
if (ctr.Agent) {
voiceCall.acceptTime = ctr.Agent.ConnectedToAgentTimestamp;
voiceCall.totalHoldDuration = ctr.Agent.CustomerHoldDuration;
voiceCall.longestHoldDuration = ctr.Agent.LongestHoldDuration;
voiceCall.agentInteractionDuration = ctr.Agent.AgentInteractionDuration;
voiceCall.numberOfHolds = ctr.Agent.NumberOfHolds;
}
if (ctr.Queue) {
voiceCall.enqueueTime = ctr.Queue.EnqueueTimestamp;
voiceCall.queue = ctr.Queue.Name;
}
if (ctr.InitiationMethod) {
voiceCall.initiationMethod = ctr.InitiationMethod;
if (ctr.InitiationMethod === 'OUTBOUND') {
if (ctr.SystemEndpoint) {
voiceCall.fromNumber = ctr.SystemEndpoint.Address;
}
if ( ctr.CustomerEndpoint) {
voiceCall.toNumber = ctr.CustomerEndpoint.Address;
}
} else {
37
Examples of Common Use Cases Retry CTR Sync for Voice Call Records
if (ctr.SystemEndpoint) {
voiceCall.toNumber = ctr.SystemEndpoint.Address;
}
if ( ctr.CustomerEndpoint) {
voiceCall.fromNumber = ctr.CustomerEndpoint.Address;
}
}
}
if (ctr.Recording) {
voiceCall.recordingLocation = ctr.Recording.Location;
}
voiceCall.callAttributes = callAttributes;
}
Object.keys(voiceCall).forEach(function (key) {
if (voiceCall[key] === null || voiceCall[key] === undefined) {
delete voiceCall[key];
}
});
38
Examples of Common Use Cases Disable CTR Sync for Voice Call Records
return JSON.stringify(callAttributes);
}
4. Check that the Voice Call record now has the CTR fields filled in.
39
Examples of Common Use Cases Enable Voice Call Transfers Using Omni-Channel Flows and
Amazon Connect
In this example, we show you how to disable CTR sync so that changes to the CTR data in Amazon Connect are not pushed automatically
to Salesforce.
This configuration applies to the following telephony models.
• Service Cloud Voice with Amazon Connect
• Service Cloud Voice with Partner Telephony from Amazon Connect
Prerequisites
Before you begin:
• Verify that you have AWS root user or AWS administrator credentials.
• Verify the AWS Account you are working with is already connected to a Salesforce org.
4. Click
Save
40
Examples of Common Use Cases Refresh a Sandbox
To enable this feature for Service Cloud Voice with Partner Telephony, go to Enable Voice Call Transfers Using Omni-Channel Flows.
Omni-Channel flows can be used to transfer voice calls through External Routing. Configure this feature to enable voice call transfers
using Omni-Channel flows. When this feature is enabled, all active flows of process type "Omni-Channel Flow" that are assigned to the
phone channel appear in the Omni-Channel widget for agents to select as transfer destinations.
Configuring the feature includes: 1) creating an Omni-Channel flow in Salesforce to route calls to an agent or queue, 2) creating a Service
Cloud Voice contact flow in Amazon Connect to transfer and route voice calls, 3) creating an Amazon Connect quick connect of type
“queue” to transfer voice calls using the newly created contact flow, and editing the Salesforce contact center details by selecting the
quick connect to be used for the Omni-Channel flow transfer.
To enable voice call transfers using Omni-Channel flow and Amazon Connect:
1. Log in to Salesforce and create an Omni-Channel flow, using the “Voice Calls Routed to Agents and Queues” template as a guide.
2. Log in to Amazon AWS and create a contact flow in Amazon Connect, using the Sample SCV Transfer Flow for Omni-Channel Transfers
contact flow in GitHub as a template. The contact flow generates a transfer voice call and routes the call using the Execute an
Omni-Channel Flow REST API.
3. Log in to Amazon AWS and create an Amazon Connect quick connect with the following settings:
• Name: Enter a unique name for the quick connect. This is the name that you’ll select when you connect the quick connect to
your contact center in Salesforce.
• Type: Select Queue.
• Destination: Select the destination queue. This can be any queue, such as Amazon Connect’s default BasicQueue.
• Contact flow: Select the name of the contact flow you created.
• Description: Optionally enter a brief description of the quick connect.
4. Log in to Salesforce and edit the Contact Center Details page in Salesforce by setting the Quick Connect for Omni-Channel Flow
Transfers field to the name of the Amazon Connect quick connect you created.
When an agent transfers a voice call to the Omni-Channel flow, Salesforce uses the Amazon Connect UpdateContactAttributes
action to set a contact attribute as the fully qualified name of the Omni-Channel flow of the parent contact. The call is transferred to the
quick connect that’s selected in the “Quick Connect for Omni-Channel Flow Transfers” field of the Contact Center Details page in Salesforce.
The contact flow defined in the quick connect creates a voice call like it would with other voice call transfers, and then executes the
Omni-Channel flow using the Execute an Omni-Channel Flow API passing the flow name from contact attribute.
Note:
• Make sure the agents and queues are mapped to Amazon Connect ARN. If you don't, the Execute an Omni-Channel Flow
request returns an error. Agent and queue mappings are configured in the Contact Center Details page in Salesforce.
• Don't add the newly created quick connect directly to the list of transfer destinations in the Omni-Channel softphone. If you
do, transfers to the quick connect will fail.
Refresh a Sandbox
Refreshing a sandbox updates its metadata from the source org.
41
Examples of Common Use Cases Refresh a Sandbox
In this example, we show you how to reuse an AWS Account to refresh your sandbox and relink the refreshed sandbox to the Amazon
Connect instance.
This configuration applies to users of Service Cloud Voice with telephony provided by Amazon Connect.
• If your telephony model is Service Cloud Voice with Amazon Connect, complete all the refresh steps in this page.
• If your telephony model is Service Cloud Voice with Partner Telephony from Amazon Connect, complete the steps in this page
except for the ones you are asked to skip.
In this example, you will perform the following steps to refresh the sandbox:
1. Retrieve (back up) the metadata for the following packages:
• *ConversationVendorInfo
• CallCenter
• Single sign-on connected app
Prerequisites
Before you begin:
• Verify that you have AWS root user or AWS administrator credentials.
• Verify the AWS Account you want to use isn’t being used by another Salesforce org.
• Review the Sandbox Org Guidelines guidance around sandbox orgs and sandbox refreshes.
42
Examples of Common Use Cases Refresh a Sandbox
</types>
<version>55.0</version>
</Package>
2. Retrieve the CallCenter metadata from the sandbox org to create a backup copy named package.xml. The CallCenter package
contains the call center definition used to integrate the Salesforce contact center with the Amazon Connect instance.
Here’s a sample version of the CallCenter package, where ContactCenterWest is the internal name of the contact center:
<!— CallCenter Package package.xml-->
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>ContactCenterWest</members>
<name>CallCenter</name>
</types>
<version>55.0</version>
</Package>
3. Retrieve the Single Sign-On Connected App metadata from the sandbox org to create a backup copy named package.xml. The
single sign-on connected app package contains the app configuration used to integrate Salesforce with the Amazon Connect
instance.
Here’s a sample version of the single sign-on connected app package, where ContactCenterWest is the internal name of the
contact center:
<!— ConnectedApp Package package.xml-->
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>ContactCenterWest_Connected_App</members>
<name>ConnectedApp</name>
</types>
<version>55.0</version>
</Package>
6. Skip this step if your telephony model is Service Cloud Voice with Partner Telephony from Amazon Connect.
Perform the following steps to finish turning on Service Cloud Voice in the refreshed sandbox org:
• Go to Setup > Voice > Amazon Setup and verify that Turn on Voice with Amazon Connect is ON and grayed out.
• In the Register Tax Number section, click Confirm Settings.
• Verify that you receive an email from Salesforce confirming Service Cloud Voice is turned on.
7. Deploy the single sign-on connected app metadata to the refreshed sandbox org.
8. Copy the following values from the newly deployed single sign-on connected app to the CallCenter metadata XML file:
43
Examples of Common Use Cases Refresh a Sandbox
• reqConnectedAppId. From the Developer Console, open the ConnectedApplication.obj file and copy the 15- or 18-digit org
ID of the newly deployed connected app. Replace the value of reqConnectedAppId in the XML file with the value you
just copied.
• reqIdentityUrl. Go to Setup > App Manager. Click Manage next to the newly deployed connected app and copy the
IdP-Initiated Login URL. Replace the value of reqIdentityUrl in the XML file with the value you just copied.
9. Give users access to the single sign-on connected app using permission sets (preferred) or profiles. Go to Setup > App Manager.
Click Manage next to the newly deployed connected app and assign the profiles to the app or enable the Service Cloud Voice
Permission Set in the app.
10. Create the REST API OAuth connected app in the refreshed sandbox org by following the steps in the Set Up OAuth in Your Service
Cloud Voice Connected App document.
11. Copy the following value from the newly created REST API OAuth connected app to the CallCenter metadata XML file:
• reqRestApiConnectedAppId. From the Developer Console, open the ConnectedApplication.obj file of the newly deployed
connected app and copy the reqRestApiConnectedAppId value. Replace the value of
reqRestApiConnectedAppId in the XML file with the value you just copied.
12. Delete the contactCenterChannels element from the CallCenter metadata XML file.
13. Deploy the CallCenter metadata containing the values you just updated to the refreshed sandbox org.
14. Map the IdP certificate to the connected apps.
a. To find your IdP certificate, select Setup > Apps > Connected Apps > Manage Connected Apps. Write down the Label name
of the currently chosen certificate.
b. To verify the IdP certificate is mapped to the single sign-on connected app, select Setup > Connected Apps. Click Edit next
to the name of the single sign-on connect app and verify the name of the IdP Certificate matches the name you wrote down.
c. Repeat these steps to verify the IdP certificate is mapped to the REST API OAuth connected app.
15. Update the SalesforceServiceVoiceIdp provider in AWS IAM with the latest IdP certificate.
a. Go to IAM > Identity Providers, and click SalesforceServiceVoiceIdp to drill down to the details.
b. Click Download Metadata to download an XML version of the current IdP metadata.
c. Click Replace Metadata and replace the metadata with the XML file you just downloaded.
16. Set the SALESFORCE_ORG_ID environment variable in the AWS Lambda functions to the org ID of the refreshed sandbox.
a. Find and copy the 15- or 18-digit org ID.
b. Go to AWS Lambda.
c. Click the name of the Lambda function that has the SALESFORCE_ORG_ID environment variable. For example, click
InvokeTelephonyIntegrationApiFunction.
d. Change the value of SALESFORCE_ORG_ID to the org ID you just copied.
e. Repeat these steps for all Lambda functions - including custom ones - that have the SALESFORCE_ORG_ID environment variable.
44
Examples of Common Use Cases Enable Voicemail Support
After you change the SALESFORCE_ORG_ID environment variable for each of the impacted Lambda functions. make sure you publish
the updated version of the Lambda function and set the Alias to the right version.
SEE ALSO:
Salesforce Help: Refresh Your Sandbox
Salesforce Help: Set Up Service Cloud Voice with Amazon
Salesforce Help: Set Up Service Cloud Voice with Partner Telephony from Amazon Connect
Salesforce Help: Developer Console
Amazon Documentation: AWS Lambda Developer Guide
Metadata API Developer Guide
Salesforce Help: Manage Contact Center Certificates
Salesforce Help: Configure Single Sign-on (SSO) to Your Telephony Provider
This configuration applies to the Service Cloud Voice with Partner Telephony from Amazon Connect telephony setup.
This feature is available in the Spring '23 and later releases.
In this example, we show you how to set up your system to support voicemail. There are two ways to enable Voicemail support, depending
on how you provisioned the Amazon Connect instance when you created the contact center:
• If the contact center was created using a new Amazon Connect instance, you must upgrade to contact center version 11.0 or later
to get the latest Lambda functions.
• If the contact center was created using an existing Amazon Connect instance, you must configure Kinesis as the event source to
work with the Lambda functions in the ServiceCloudVoiceLambdas serverless app.
In this example, you’ll perform the following steps to enable voicemail support for Service Cloud Voice with Partner Telephony from
Amazon Connect.
1. Add and configure the VoiceMailAudioProcessingFunction Lambda function. This step only applies if the contact center was created
using an existing Amazon Connect instance.
2. Enable Amazon EventBridge.
3. Configure an EventBridge Rule for the VoiceMailTranscribeFunction Lambda function.
4. Configure an EventBridge Rule for the VoiceMailPackagingFunction Lambda function.
5. Bind the voicemail subflow to the inbound flow in Amazon Connect.
This example applies to both contact centers created using a new or existing Amazon Connect instance.
See Lambda Functions for more information about the VoiceMailAudioProcessingFunction, VoiceMailTranscriberFunction, and
VoiceMailPackagingFunction Lambda functions.
45
Examples of Common Use Cases Enable Voicemail Support
Prerequisites
Complete the prerequisites before you perform the steps:
• Verify that you have AWS root user or AWS administrator credentials.
• Deploy the ServiceCloudVoiceLambdas.
• If the contact center was originally created using a new Amazon Connect instance, upgrade the contact center to version 11.0 or
later.
• Note the name of the S3 bucket you’ll use to store the voicemail recordings and transcription files. The S3 object name is in the
format <contactcentername-salesforceuniquerandomID>.
To implement this use case:
46
Examples of Common Use Cases Enable Voicemail Support
7. Click Add.
8. Click the Configuration tab, select Environment variables, and then click Edit.
9. Find the s3_recordings_bucket key and replace the testVoiceMailBucket value with the name of the contact center S3
bucket that will store the voicemail recordings and transcriptions. For example, contactcenter-123456789123. You can select an S3
bucket that you already use for Service Cloud Voice.
47
Examples of Common Use Cases Enable Voicemail Support
48
Examples of Common Use Cases Enable Voicemail Support
4. Click Next.
5. In the Build event pattern screen, scroll down to the Event pattern section and click Custom patterns (JSON editor).
6. Copy the following JSON sample event and paste it into the Event pattern text box, replacing the name of the bucket with your
contact center’s S3 object name:
{
"detail-type": ["Object Created"],
"source": ["aws.s3"],
"detail": {
"bucket": {
"name": ["contactcenter-123456789123"] // replace with contact center S3 bucket
name
},
"object": {
"key": [{
"prefix": "voicemail_recordings/"
}]
}
}
}
49
Examples of Common Use Cases Enable Voicemail Support
7. Click Next.
8. In the Select target(s) screen, set the Select a target dropdown to Lambda function, and set the Function to the
VoiceMailTranscribeFunction function.
50
Examples of Common Use Cases Enable Voicemail Support
3. In the Define rule detail screen, give the rule a name and optional description. Leave the other default settings.
4. Click Next.
5. In the Build event pattern screen, scroll down to the Event pattern section and click Custom patterns (JSON editor).
6. Copy the following JSON sample event and paste it into the Event pattern text box, replacing the name of the bucket with your
contact center’s S3 object name:
{
"detail-type": ["Object Created"],
"source": ["aws.s3"],
"detail": {
"bucket": {
"name": ["contactcenter-123456789123"] // replace with contact center S3 bucket
name
},
"object": {
"key": [{
"prefix": "voicemail_transcripts/"
}]
}
}
}
51
Examples of Common Use Cases Enable Voicemail Support
7. Click Next.
8. In the Select target(s) screen, click the Select a target dropdown and select Lambda function. Click the Function dropdown and
select VoiceMailPackagingFunction.
9. Click Next twice.
10. In the Review and create screen, review the settings for your new EventBridge rule and click Create rule.
52
Examples of Common Use Cases Enable Voicemail Support
5. Add a Get customer input flow block and configure prompts to give the caller the option to either proceed with the voice call or
leave a voicemail message.
6. Insert the Get customer input flow block into the inbound flow so the voice call option transfers to the Transfer to flow:
Omni-Channel flow block and the voicemail option transfers to the Transfer to flow: Voicemail flow block.
7. Click Save.
Voicemail Process
The diagram illustrates the voicemail process that happens when a caller initiates a voice call with the contact center.
(1) A caller initiates a voice call with the contact center, which triggers an Amazon Connect inbound flow to begin. When the flow
reaches the Get customer input prompt flow block, the caller chooses to leave a voicemail message.
(2) After the caller leaves the voicemail message and hangs up, Amazon Connect generates a Contact Trace Record (CTR) event and
streams the voicemail data to Amazon Kinesis.
(3) The CTR event triggers the VoiceMailAudioProcessingFunction Lambda function to get the voicemail recordings from Amazon Kinesis
and saves them as WAV files to the voicemail_recordings folder in the contact center’s Amazon S3 bucket.
(4) Every time a voicemail recording file is added to the voicemail_recordings folder, an EventBridge rule triggers the
VoiceMailTranscriberFunction Lambda function to read the files in the S3 bucket, transcribe the recordings, and save the files into the
voicemail_transcriptions folder in the contact center’s Amazon S3 bucket.
(5) Every time a voicemail recording file is added to the voicemail_transcriptions folder, an EventBridge rule triggers the
VoiceMailPackagingFunction Lambda function to create a VoiceCall record, attach the voicemail recording and transcription files to the
record, and route it all to the Omni-Channel flow that was configured in the contact center.
The agent who receives the voice call can play back the voicemail recording and read the transcription at any time.
53
Examples of Common Use Cases Set the Voice Call Record Type
SEE ALSO:
VoiceMailAudioProcessingFunction Lambda Function
VoiceMailTranscribeFunction Lambda Function
VoiceMailPackagingFunction Lambda Function
54
Examples of Common Use Cases Disable Call Recording
This example explains how to configure the Sample SCV Inbound Flow to automatically set the record type whenever a voice call goes
through the flow.
To run through this example:
• You must be an AWS admin with the ability to create flows in Amazon Connect.
• You must be a Salesforce admin.
To configure a flow so that voice calls are automatically set to a record type:
1. Find the 18-digit alphanumeric ID of the record type you want the flow to use. For example, 012S30000004B5VIAU.
2. From the Amazon Connect console, select Routing > Flows.
3. Click the name of the flow.
4. Add a Set contact attributes flow block to the flow, making sure it appears before the Invoke AWS Lambda function block.
5. Add the following attribute to the Set contact attributes flow block:
• Namespace: User defined
• Key: sfdc-RecordTypeId
• Select Set manually and set the value to the 18-digit ID of the record type you want to display.
6. Click Save.
Whenever a call comes in through this flow, the voice call record displays the page layout for the record type you specified.
55
Examples of Common Use Cases Enable the Voice Extension Page in Lightning App Builder
• Key: callRecordingDisabled
• Select Set manually and set the value to true.
To use this feature, you must have Service Cloud Voice installed. This configuration applies to the following telephony models:
• Service Cloud Voice with Amazon Connect
• Service Cloud Voice with Partner Telephony
• Service Cloud Voice with Partner Telephony from Amazon Connect
56
Examples of Common Use Cases Enable the Voice Extension Page in Lightning App Builder
Administrators can create and customize Voice Extension pages, then enable them in a contact center so that any agent in the org can
use the feature. For more information about customizing call controls and voice extensions through the Voice Extension page in the
Lightning App Builder, see Customize Call Controls and Voice Extensions.
Before an administrator can create Voice Extension pages, you must perform several configuration steps to expose the page in the
Lightning App Builder and enable the component types you want the page to support.
The Voice Extension page supports the following Lightning App Builder components: Lightning Web Components, Aura, and Visualforce.
You can further extend the Voice Extension feature by linking Aura components to the Service Cloud Voice Toolkit API, allowing agents
to perform call actions, such as muting a call, placing a call on hold, and starting a preview call.
You can either perform the configuration directly in the org through the Developer Console, or build and bundle the custom component
configuration files and deploy the managed package to AppExchange for administrators to download.
Configuring this feature includes:
1. Creating the Voice Extension FlexiPage metadata file
2. Configuring Lightning Web Components for Voice Extensions
3. Configuring Aura components for Voice Extensions
4. Linking components to the Service Cloud Voice Toolkit API
5. Linking components to the telephony system using Lightning Message Service
6. Deploying and distributing the managed package.
If you’re creating custom configuration files for package distribution, use the sample quickstart templates in the
/salesforce/scv-partner-telephony-quickstart/tree/main/force-app/main/default/flexipages folder in GitHub as a starting point.
Steps
To enable the Voice Extension page in the Lightning App Builder:
57
Examples of Common Use Cases Enable the Voice Extension Page in Lightning App Builder
Step 4: Link the Aura Components to the Service Cloud Voice Toolkit API
You can further extend the Voice Extension feature by linking Aura components to the Service Cloud Voice Toolkit API, enabling agents
to perform call operations, such as muting a call, placing a call on hold, and starting a preview call.
To link an Aura component to Service Cloud Voice, see the Service Cloud Voice Aura Toolkit API on page 99 page. For example,
For example,
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId"
access="global">
<!-- subscribe to service cloud voice toolkit api -->
<force:serviceCloudVoiceToolkitApi aura:id="voiceToolkitApi"/>
<aura:handler name="init" value="{!this}" action="{!c.onInit}"/>
<aura:handler name="destroy" value="{!this}" action="{!c.onDestroy}"/>
</aura:component>
58
Examples of Common Use Cases Examples from Amazon Connect
SEE ALSO:
Salesforce Help: Customize Call Controls and Voice Extensions
Note: Salesforce does not maintain the examples provided by Amazon Connect.
• Voicemail Express V2: Provides a basic voicemail capability for Service Cloud Voice. With Voicemail Express, customers can leave
a voicemail for an agent or queue. The voicemail is stored in an S3 bucket as a .wav file, a transcription of the voicemail is created,
and a new case is created in Salesforce that contains the transcription, a link to the recording, and a clickable callback number.
• Follow Me Routing: Provides an option that allows agents to flag themselves as available using an external phone number. When
customers call specifically for that agent, the call is redirected to their external line.
59
CHAPTER 3 Using the Telephony Integration API
In this chapter ... The Telephony Integration API allows you to programmatically manage a voice call. The provided Amazon
Connect Lambda functions automatically use these endpoints to perform telephony functions, but you
• Telephony can also use these APIs separate from the provided Lambda functions.
Integration REST API
Authorization
• Create a Voice Call
Record
• Update a Voice Call
Record
• Create a Transcript
• Create Transcripts in
Bulk
• Execute an
Omni-Channel Flow
• Send a Real-Time
Conversation Event
• Store a Post-Call
Conversation Event
• Clear Routing
• Telephony
Integration REST API
Sample Code
60
Using the Telephony Integration API Telephony Integration REST API Authorization
Once you’ve satisfied these prerequisites, set up authorization for this API.
1. Construct a JWT header with this format: {"alg":"RS256"}.
2. Base64url encode the JWT header as defined in Base 64 Encoding with URL and Filename Safe Alphabet. For example:
eyJhbGciOiJSUzI1NiJ9.
3. Construct a JSON claims set for the JWT with the following parameters:
• iss—The issuer is the Salesforce org ID where you set up your contact center and registered the certificate.
• sub—The subject must contain the “Salesforce Call Center API Name”.
• aud—The audience identifies the authorization server as an intended audience. The authorization server must verify that it is
an intended audience for the token. Use https://scrt.salesforce.com.
• exp—The expiration time of the assertion within 3 minutes, expressed as the number of seconds from 1970-01-01T0:0:0Z
measured in UTC.
• jwtId—The unique ID for the JWT token.
Note: Salesforce doesn’t require JWT ID (JTI) claims in your JWT bearer tokens. However, if you pass a JTI claim in your
JWT bearer token, Salesforce validates that the JTI claim hasn’t been sent before. This validation prevents JWT replay attacks.
4. Base64url encode the JWT claims set without any line breaks.
5. Retrieve the private key stored in the keystore.
6. Sign the payload using the private key to generate JWT token.
7. Use the generated JWT token as part of the Authorization header when making the API request.
61
Using the Telephony Integration API Create a Voice Call Record
When you create a voice call record, it creates a conversation in Salesforce. Only use this API in real time, which means that you should
invoke this API only when a call is initiated.
This API can also be used to create voice call records for transfer by including the parentVoiceCallId parameter in the request
payload.
URI
/telephony/v1/voiceCalls
HTTP Method
POST
Headers
Authorization: Bearer <token>
String. Standard header. The authorization token, where <token> is the JSON Web Token (JWT). Required.
Content-Type: <format>
String. Standard header. The format of the request body. Valid formats include JSON and XML. For example, application/json
or application/xml. Required.
Telephony-Provider-Name: <telephony provider name>
String. Custom header. The name of the telephony provider that calls this API. For example, Amazon Connect.
Parameters
Property Name Type Description Required
callCenterApiName string The API name of the contact center created in Salesforce Yes
associated with the voice call record.
parentVoiceCallId string For transfers, set this value to a Salesforce Voice Call record ID No
or the voice call’s vendor call key (vendorCallKey)
representing the parent record to this newly created voice call
record. This parameter is required if initiationMethod=transfer
Only use this property to create voice call records for transfer.
Don’t include this property when creating the initial voice call
record.
vendorCallKey string A unique key that identifies the voice call record within the Yes
telephony system. For example, if the telephony system is
Amazon Connect, this value is the contact ID in Amazon
Connect.
If another voice call record with the same vendor call key already
exists, a new voice call record won’t be created. Instead,
Salesforce returns the Salesforce voice call ID of the existing
voice call record with this vendor call key.
62
Using the Telephony Integration API Create a Voice Call Record
from string The phone number from where the voice call is made or Yes
transferred.
• For inbound calls, set this value to the end user's phone
number.
• For transfers, set this value to the contact center's phone
number.
queue string Optional queue ID to associate with this voice call. This No
parameter is only used when initiationMethod is set
to Transfer. It’s ignored for other initiation methods.
You can pass in either the Salesforce queue object ID or the
vendor’s external queue ID. Salesforce resolves this value using
the entries in the CallCenterRoutingMap record.
If the queue is resolved to a valid Salesforce queue, the VoiceCall
owner is changed to the queue and the supervisor is able to
see the transferred call waiting in the queue.
See Map Your Salesforce Queues to Telephony Provider Queues.
startTime string The date and time (in UTC) when the voice call started. Yes
63
Using the Telephony Integration API Create a Voice Call Record
For example,
{
"participantKey":"5324881f-1e84-4367-8930-f69a74b30ca6",
"type": "END_USER"
}
callAttributes string Represents additional standard and custom fields in the voice No
call record, where each key-value pair value corresponds to a
standard or custom field and its values.
Possible standard fields are:
• SourceType - Represents the general purpose of the call.
Valid values are: Sales and Service.
• ToPhoneNumber - Represents the recipient of the phone
call.
Here’s an example using the standard field SourceType:
"callAttributes":
"{\"SourceType\":\"Sales\"}"
64
Using the Telephony Integration API Update a Voice Call Record
Example
Request:
POST /telephony/v1/voiceCalls
{
"callCenterApiName": "MyContactCenter",
"vendorCallKey": "5324881f-1e84-4367-8930-f69a74b30ca6",
"to": "8002345678",
"from": "4081456688",
"initiationMethod": "Inbound",
"startTime": "2019-07-02T17:32:28Z",
"participants": [
{
"participantKey": "4081456688",
"type" : "END_USER"
}
],
"callAttributes": "{\"MyField__c\": \"abc\"}"
}
Response:
{
"voiceCallId": "0LQRM0000006CSz",
"errors": []
}
Note: You may encounter errors when creating a voice call record. These errors can be caused by a number of factors due to
triggers, flows, required fields, and field validations. Salesforce bypasses the errors, creates the voice call record, and returns an
errors response like the one in the following example.
{
"voiceCallId": "0LQS70000004YDG",
"errors": "We created your voice call but there were some errors : Required fields
are missing:
[Picklist], Text__c: data value too large: sample123456890"
}
If you encounter an errors response when creating a voice call record, notify your Salesforce administrator.
SEE ALSO:
Object Reference for Salesforce and Lightning Platform: VoiceCall
65
Using the Telephony Integration API Update a Voice Call Record
Note: Don’t run this API call more than one time. If you run this API call more than one time, each subsequent API call overwrites
the following properties with the latest values: totalHoldDuration, numberOfHolds, and agentInteractionDuration.
This API call functions by making two separate database updates. The first database update passes the parameters
recordingLocation and totalRecordingDuration, which are used to create a corresponding VoiceCallRecording
record. The second database update passes all the other parameters. If you’re using the Update a Voice Call Record API call as an Apex
trigger, the trigger is invoked only by the second database update.
URI
/telephony/v1/voiceCalls/{CALL ID}
Where {CALL ID} is the Salesforce voice call ID (voiceCallId) or the telephony vendor's contact ID.
HTTP Method
PATCH
Headers
Authorization: Bearer <token>
String. Standard header. The authorization token, where <token> is the JSON Web Token (JWT). Required.
Content-Type: <format>
String. Standard header. The format of the request body. Valid formats include JSON and XML. For example, application/json
or application/xml. Required.
Telephony-Provider-Name: <telephony provider name>
String. Custom header. The name of the telephony provider that calls this API. For example, Amazon Connect.
Parameters
Property Name Type Description Required
startTime string The date and time (in UTC) No
when the voice call started.
The
VoiceCall.CallDurationInSeconds
value is only updated if both
startTime and endTime
are passed.
66
Using the Telephony Integration API Update a Voice Call Record
67
Using the Telephony Integration API Update a Voice Call Record
68
Using the Telephony Integration API Update a Voice Call Record
69
Using the Telephony Integration API Create a Transcript
Example
Request:
PATCH /telephony/v1/voiceCalls/0LQRM0000006CSz
{
"startTime": "2020-08-26T21:21:14Z",
"endTime": "2019-08-26T21:21:34Z",
"enqueueTime": "2019-08-26T21:21:34Z",
"acceptTime": "2019-08-26T21:21:24Z",
"numberOfHolds": 20,
"longestHoldDuration": 10,
"callAttributes": "{\"dateCustomField__c\": \"2019-08-28T21:21:34Z\", \"checkbox__c\":
false}",
"disconnectReason": {
"value": "TELECOM_PROBLEM",
"isError": true
}
}
Response:
{
"status": "pending"
}
SEE ALSO:
Object Reference for Salesforce and Lightning Platform: VoiceCall
Create a Transcript
Creates a transcribed version of a voice call in real time.
Use this API to create transcripts for one voice call in real time. Voice calls can include inbound calls, transfer calls, outbound calls, and
callback calls. The transcript data is sent to the agent console synchronously in real time and will be persisted in Salesforce asynchronously.
This API and the Create Transcripts in Bulk API (/telephony/v1/voiceCalls/messages) share several characteristics.
• Both APIs create voice call transcripts if the timestamp of the transcript is between the start and end times of the conversation.
• Both APIs pause call transcription whenever the agent pauses the recording or places the call participant on hold. Any messages
being sent in won’t be created or stored by the API during this time.
Where the two APIs differ is by the number of transcripts they can process per request. This API only creates transcripts for one voice
call at a time, while the Create Transcripts in Bulk API creates transcripts in bulk.
70
Using the Telephony Integration API Create a Transcript
To create or update transcripts in bulk after the call has ended, use the Salesforce Connect API.
URI
/telephony/v1/voiceCalls/{vendorCallKey}/messages
Where vendorCallKey is the unique ID of the voice call (VoiceCall) record within the telephony system. For example, if the telephony
system is Amazon Connect, this value is the contact ID in Amazon Connect. In transfer use cases where there are multiple VoiceCall
objects associated to a single call, use the vendorCallKey of the first voice call record created for the call. This value can only be the unique
call identifier of the first contact for the conversation. This value can't be a Salesforce voiceCallId.
HTTP Method
POST
Headers
Authorization: Bearer <token>
String. Standard header. The authorization token, where <token> is the JSON Web Token (JWT). Required.
Content-Type: <format>
String. Standard header. The format of the request body. Valid formats include JSON and XML. For example, application/json
or application/xml. Required.
Telephony-Provider-Name: <telephony provider name>
String. Custom header. The name of the telephony provider that calls this API. For example, Amazon Connect.
Parameters
Property Name Type Description Required
participantId string The call participant role that Yes
uttered this text.
• If senderType is END_USER,
set this value to
{vendorCallKey}END_USER,
where
{vendorCallKey} is
the vendor call key
(vendorCallKey) of the first
voice call (VoiceCall) record
created for the conversation.
If you set this property to
any other value, Salesforce
will set it to
{vendorCallKey}END_USER
internally for privacy
reasons.
71
Using the Telephony Integration API Create a Transcript
72
Using the Telephony Integration API Create a Transcript
Example
Request:
POST telephony/v1/voiceCalls/5324881f-1e84-4367-8930-f69a74b30ca6/messages
{
"participantId": "5324881f-1e84-4367-8930-f69a74b30ca6VIRTUAL_AGENT",
"messageId": "57904eb6-5352-4c5e-adf6-5f100572cf5d116",
"startTime": 1573503300000,
"endTime": 1573503300000,
"content": "Hello All",
"senderType": "VIRTUAL_AGENT"
}
Response:
{
"result": "Accepted"
}
SEE ALSO:
Create Transcripts in Bulk
Upload or Update Transcripts with Connect REST API
73
Using the Telephony Integration API Create Transcripts in Bulk
URI
/telephony/v1/voiceCalls/messages
HTTP Method
POST
Headers
Authorization: Bearer <token>
String. Standard header. The authorization token, where <token> is the JSON Web Token (JWT). Required.
Content-Type: <format>
String. Standard header. The format of the request body. Valid formats include JSON and XML. For example, application/json
or application/xml. Required.
Telephony-Provider-Name: <telephony provider name>
String. Custom header. The name of the telephony provider that calls this API. For example, Amazon Connect.
74
Using the Telephony Integration API Create Transcripts in Bulk
Parameters
Property Name Type Description Required
entries array An array of create transcript Yes
objects for one or more voice
call (VoiceCall) records.
75
Using the Telephony Integration API Create Transcripts in Bulk
Example
Request:
POST /telephony/v1/voiceCalls/messages
76
Using the Telephony Integration API Create Transcripts in Bulk
"entries": [
{
"vendorCallKey": "b09955ce-03be-4335-a28891293zs-18895",
"messages": [
{
"startTime": 1573503300000,
"endTime": 1573503300001,
"participantId": "b09955ce-03be-4335-a28891293zs-18895END_USER",
"messageId": "b09955ce-03be4335xz-a28891293zs",
"senderType": "END_USER",
"content": "Hello All"
},
{
"startTime": 1573503300002,
"endTime": 1573503300003,
"participantId": "b09955ce-03be-4335-a28891293zs-18895VIRTUAL_AGENT",
"messageId": "b09955ce-03be4335ej-a28891293sz",
"senderType": "VIRTUAL_AGENT",
"content": "Hello All"
}
]
},
{
"vendorCallKey": "b09955ce-03be-4335-a28891293sz-188952",
"messages": [
{
"startTime": 1573503300012,
"endTime": 1573503300013,
"participantId": "b09955ce-03be-4335-a28891293sz-188952VIRTUAL_AGENT",
"messageId": "b2922012ne-t13081984si-t04021978re",
"senderType": "VIRTUAL_AGENT",
"content": "Hello All"
}
]
}
]
}
Response:
// All transcripts were successfully processed.
{
"result": "Accepted"
}
77
Using the Telephony Integration API Execute an Omni-Channel Flow
"status": 400,
"message": "Error Processing Transcript with Id(s) [b09955ce-03be-4335-a8a0-2889129].
Error: io.grpc.StatusRuntimeException: PERMISSION_DENIED: Conversation does not exist"
},
{
"vendorCallKey": "b09955ce-03be-4335-saturday-188954",
"status": 202,
"message": "Successfully Processed Transcripts with Id(s)
[b2922012ne-t13081984si-t04021978re]"
},
{
"vendorCallKey": "ghbjnkk-jlme-6789-friday-67754",
"status": 400,
"message": "Error Processing Transcript with Id(s)
[kjikjnkk-jkjhu-6789-kjgjhg-87643]. Error: io.grpc.StatusRuntimeException: PERMISSION_DENIED:
Conversation does not exist"
}
]
}
}
SEE ALSO:
ContactLensConsumerFunction Lambda Function
ContactLensProcessorFunction Lambda Function
Create a Transcript
Upload or Update Transcripts with Connect REST API
URI
/telephony/v1/voiceCalls/{CALL ID}/omniFlow
Where {CALL ID} is the Salesforce voiceCallId or the telephony vendor’s contact ID.
HTTP Method
PATCH
78
Using the Telephony Integration API Execute an Omni-Channel Flow
Headers
Authorization: Bearer <token>
String. Standard header. The authorization token, where <token> is the JSON Web Token (JWT). Required.
Content-Type: <format>
String. Standard header. The format of the request body. Valid formats include JSON and XML. For example, application/json
or application/xml. Required.
Telephony-Provider-Name: <telephony provider name>
String. Custom header. The name of the telephony provider that calls this API. For example, Amazon Connect.
Parameters
Property Name Type Description Required
dialedNumber string Set a new dialed number to account for a dialed number that doesn’t Yes
have a phone channel set up. Dialed number is the phone number
called.
flowDevName string Set the Omni-Channel flow using its developer name. No
fallbackQueue string Set the fallback queue using its Salesforce queue developer name or No
ID.
Important: Service Cloud Voice uses this order of precedence to route voice calls.
1. Uses the Omni-Channel Flow and Fallback Queue settings for the phone channel that matches the dialed number. The flow
takes precedence. If the flow fails, the fallback queue is used.
2. Uses the flowDevName and fallbackQueue parameters specified in the Execute Omniflow API call.
If none of this criteria is satisfied or the admin doesn’t map the Salesforce and telephony queues, the call fails.
Example
Request:
PATCH /telephony/v1/voiceCalls/0LQRM0000006CSz/omniFlow
{
"dialedNumber": "+18445791189"
"flowDevName": "Route_VoiceCall",
"fallbackQueue": "00G111222333444",
"flowInputParameters": {
"Input1": "one",
"Input2": "two"
}
}
79
Using the Telephony Integration API Send a Real-Time Conversation Event
Note: AGENT_INFO and QUEUE_INFO correspond to the ExternalId field in the CallCenterRoutingMap
URI
/telephony/v1/voiceCalls/{vendorCallKey}/realtimeConversationEvents
Where vendorCallKey is the unique ID of the voice call (VoiceCall) record within the telephony system. For example, if the telephony
system is Amazon Connect, this value is the contact ID in Amazon Connect. In transfer use cases where there are multiple VoiceCall
objects associated to a single call, use the vendorCallKey of the first voice call record created for the call. This value can only be the unique
call identifier of the first contact for the conversation. This value can't be a Salesforce voiceCallId.
HTTP Method
POST
Headers
Authorization: Bearer <token>
String. Standard header. The authorization token, where <token> is the JSON Web Token (JWT). Required.
Content-Type: <format>
String. Standard header. The format of the request body. Valid formats include JSON and XML. For example, application/json
or application/xml. Required.
Telephony-Provider-Name: <telephony provider name>
String. Custom header. The name of the telephony provider that calls this API. For example, Amazon Connect.
80
Using the Telephony Integration API Send a Real-Time Conversation Event
Parameters
Property Name Type Description Required
service string The intelligence source for the events. This is a partner-provided Yes
value. For example, set this value to
AmazonConnectContactLens for Amazon Connect or
CXoneAgentAssistService for NICE.
Contact your Salesforce representative to verify that your partner
contact center supports this feature.
events array A piece of signal data generated in real time from a voice call Yes
between an agent and end user. Events must be sorted in
chronological ascending order by startTime. For example, the
following snippet displays a piece of signal data.
{
"type": "IntelligenceSignal__Category",
"value": "CustomerAngry",
"startTime": 1573503450
}
events.type string The signal type of the event. Possible values are: Yes
• IntelligenceSignal__Category
• IntelligenceSignal__Sentiment
events.startTime int64 The date and time (in UTC) when this event started. Measured Yes
in milliseconds since the Unix epoch.
events.score string The confidence score, which evaluates how confident the No
vendor is about the accuracy of the value (events.value). The
score must be between 0 and 1000, where 1000 means the
vendor is very confident that the signal is accurate. This value
comes from the partner telephony service provider.
81
Using the Telephony Integration API Send a Real-Time Conversation Event
Example
Request:
POST /telephony/v1/voiceCalls/5324881f-1e84-4367-8930-f69a74b30ca6/realtimeConversationEvents
{
"service": "AmazonConnectContactLens",
"events": [
{
"type": "IntelligenceSignal__Category",
"value": "OrderStatusCheckingHelp",
"startTime": 1573503300
},
{
"type": "IntelligenceSignal__Category",
"value": "CustomerAngry",
"startTime": 1573503450
}
]
}
Response:
{
status: “202 Accepted”
}
Example
Request:
POST /telephony/v1/voiceCalls/5324881f-1e84-4367-8930-f69a74b30ca6/realtimeConversationEvents
{
"service":"CxoneAgentAssistService",
"persist":false,
"events": [
{
"type": "IntelligenceSignal__Sentiment",
"value": "400.13",
"startTime": 16898867880000,
82
Using the Telephony Integration API Store a Post-Call Conversation Event
"score": 10,
"participant": "CUSTOMER"
}
]
}
Response:
{
status: “202 Accepted”
}
URI
/telephony/v1/voiceCalls/{vendorCallKey}/postConversationEvents
Where vendorCallKey is the unique ID of the voice call (VoiceCall) record within the telephony system. For example, if the telephony
system is Amazon Connect, this value is the contact ID in Amazon Connect. In transfer use cases where there are multiple VoiceCall
objects associated to a single call, use the vendorCallKey of the first voice call record created for the call. This value can only be the unique
call identifier of the first contact for the conversation. This value can't be a Salesforce voiceCallId.
HTTP Method
POST
Headers
Authorization: Bearer <token>
String. Standard header. The authorization token, where <token> is the JSON Web Token (JWT). Required.
Content-Type: <format>
String. Standard header. The format of the request body. Valid formats include JSON and XML. For example, application/json
or application/xml. Required.
Telephony-Provider-Name: <telephony provider name>
String. Custom header. The name of the telephony provider that calls this API. For example, Amazon Connect.
83
Using the Telephony Integration API Store a Post-Call Conversation Event
Parameters
Property Name Type Description Required
service string The intelligence source of the events. Possible values are: Yes
• AmazonConnectContactLens
events array A piece of signal data generated post-call from a voice call Yes
between an agent and end user. This data is used for post-call
event analysis. Events must be sorted in chronological
ascending order by startTime.
For example, the following snippet displays event data used
for post-call analysis:
{
"type": "IntelligenceSignal__Sentiment",
"value": "-1000",
"startTime": 1573503301,
"endTime": 1573503320,
"participant": "CUSTOMER"
}
events.type string The signal type of the event. Possible values are: Yes
• IntelligenceSignal__Sentiment
events.value string The value of the signal detected. For type Yes
IntelligenceSignal__Sentiment, the value represents the
sentiment of the words spoken by the participants in the call,
ranging between -1000 (most negative) and 1000 (most
positive). A value of zero (0) represents a neutral sentiment.
events.startTime int64 The date and time (in UTC) when this event started. Measured Yes
in milliseconds since the Unix epoch.
events.endTime int64 The date and time (in UTC) when this event ended. Measured Yes
in milliseconds since the Unix epoch.
events.participant string The voice call participant type that generated the signal. Yes
Possible values are:
• AGENT - Represents an agent.
• CUSTOMER - Represents a customer.
Example
Request:
POST /telephony/v1/voiceCalls/5324881f-1e84-4367-8930-f69a74b30ca6/postConversationEvents
84
Using the Telephony Integration API Clear Routing
{
"service": "AmazonConnectContactLens",
"events": [ // sort by startTime
{
"type": "IntelligenceSignal__Sentiment",
"value": "1000",
"startTime": 1573503300,
"endTime": 1573532140,
"participant": "AGENT"
},
{
"type": "IntelligenceSignal__Sentiment",
"value": "-1000",
"startTime": 1573503301,
"endTime": 1573503320,
"participant": "CUSTOMER"
}
]
}
Response:
{
status: “202 Accepted”
}
Clear Routing
Deletes the PendingServiceRouting (PSR) record for a voice call. This API doesn’t need to be called for most scenarios; the PSR record is
automatically deleted when the call is no longer being routed. However, there are some scenarios, like for missed or abandoned calls
when using partner telephony systems (excluding Amazon Connect), where you must explicitly call this API to clear the PSR record.
URI
/telephony/v1/voiceCalls/{CALL ID}/clearRouting
Where {CALL ID} is the Salesforce voiceCallId or the telephony vendor’s contact ID.
HTTP Method
PATCH
Headers
Authorization: Bearer <token>
String. Standard header. The authorization token, where <token> is the JSON Web Token (JWT). Required.
Content-Type: <format>
String. Standard header. The format of the request body. Valid formats include JSON and XML. For example, application/json
or application/xml. Required.
85
Using the Telephony Integration API Telephony Integration REST API Sample Code
Parameters
None.
SEE ALSO:
Salesforce Help: The Routing Lifecycle
Note: If enhanced domains aren’t enabled in your org, your URL format is different. For details, see My Domain URL Formats in
Salesforce Help.
const jwt = require('jsonwebtoken');
const SSM = require('aws-sdk/clients/ssm');
const uuid = require('uuid/v1');
resolve(paramValue);
});
});
}
86
Using the Telephony Integration API Telephony Integration REST API Sample Code
var fieldValues = {
"vendorCallKey":"5324881f-1e84-4367-8930-f69a74b30ca6",
"callCenterApiName":"HVCC",
"to":"8002345678",
"from":"4081456688",
"initiationMethod":"Inbound",
"startTime":"2020-07-13T11:43:01Z",
"participants":
[{"participantKey":"+18033568299",
"type": "END_USER"
}]
};
87
Using the Telephony Integration API Telephony Integration REST API Sample Code
context = error.response.data;
} else if (error.request) {
// The request was made but no response was received
context = error.request;
} else {
// Something happened in setting up the request that triggered an error
context = error.message;
}
throw new Error('Error creating VoiceCall record');
});
return response.data;
}
88
CHAPTER 4 Service Cloud Voice Toolkit API
In this chapter ... Service Cloud Voice Toolkit API is a collection of front-end event listeners and API methods for interacting
with the Service Cloud Voice product. The API is available for Lightning components built using both
• Service Cloud Voice the Lightning Web Component framework and the Aura framework.
Lightning Web
Component (LWC) This toolkit is available to all customers. All customers may use this toolkit to interact with Einstein Next
Toolkit API Best Action. Some portions of this toolkit rely on features available only through Service Cloud Voice.
• Service Cloud Voice Note: Components (such as the Lightning Message Bridge) that implement the
Aura Toolkit API lightning:backgroundUtilityItem interface aren’t supported locations for the Service
• Service Cloud Voice Cloud Voice Toolkit API. Use this API in a component that resides on a page, or resides in a visible
Lightning Data utility bar component.
Service
• Service Cloud Voice
Toolkit API Sample
Components
89
Service Cloud Voice Toolkit API Service Cloud Voice Lightning Web Component (LWC) Toolkit
API
<template>
<lightning-service-cloud-voice-toolkit-api>
</lightning-service-cloud-voice-toolkit-api>
...
</template>
For more information about configuration files, see XML Configuration File Elements.
90
Service Cloud Voice Toolkit API Service Cloud Voice LWC Toolkit API Telephony Events
conference Sent when participants on a three-way call are all taken off hold.
swap Sent when participants on a three-way call have their hold status
swapped.
wrapupended Sent when the agent exits after call work status.
To subscribe to these events, add an event listener for each event you want to listen to.
// Subscribe
const toolkitApi = this.template.querySelector('lightning-service-cloud-voice-toolkit-api');
toolkitApi.addEventListener('callstarted', <listener>);
// Unsubscribe
const toolkitApi = this.template.querySelector('lightning-service-cloud-voice-toolkit-api');
toolkitApi.removeEventListener('callstarted', <listener>);
When an event occurs, you receive a JSON payload that contains the event type, along with any relevant data. For instance, the
callstarted event contains the following payload.
{
"type": "callstarted",
"detail": {
"callId": "d7a9f1b7-fc17-43fe-8ca7-e584a2b34792",
"callType": "outbound",
"participant": "+1 (415) 999-0000"
91
Service Cloud Voice Toolkit API Service Cloud Voice LWC Toolkit API Telephony Events
}
}
All payloads contain some basic information, such as the event type (type) and a unique call identifier (callId). Events can contain additional
values within the detail object. Refer to the following table for all the possible properties that can appear within the detail object of the
payload.
92
Service Cloud Voice Toolkit API Service Cloud Voice LWC Toolkit API Telephony Events
93
Service Cloud Voice Toolkit API Service Cloud Voice LWC Toolkit API Telephony Events
94
Service Cloud Voice Toolkit API Service Cloud Voice LWC Toolkit API Telephony Events
95
Service Cloud Voice Toolkit API Service Cloud Voice LWC Toolkit API Telephony Actions
96
Service Cloud Voice Toolkit API Service Cloud Voice LWC Toolkit API Telephony Actions
Programmatically raise softphone call control events or even build your own softphone UI. For example, build integrations with peripherals
like Bluetooth headsets, or programmatically perform actions on the agent's behalf, such as adding a participant to a conference call.
The following methods are available.
97
Service Cloud Voice Toolkit API Service Cloud Voice LWC Toolkit API Telephony Actions
To perform telephony actions, load the Service Cloud Voice Lightning Web Components ToolkitApi, and then add a telephony
method for each call control you want to allow administrators to perform.
For example, add the following components to accept calls, decline calls, end calls, pause call recordings, and resume paused recordings.
({
onAcceptCall() {
this.getToolkitApi().acceptCall();
}
onDeclineCall() {
this.getToolkitApi().declineCall();
}
onEndCall() {
this.getToolkitApi().endCall(this.comboBoxRemoveParticipantValue);
}
onPauseRecording() {
98
Service Cloud Voice Toolkit API Service Cloud Voice LWC Toolkit Next Best Action
this.getToolkitApi().pauseRecording();
}
onResumeRecording() {
this.getToolkitApi().resumeRecording();
}
})
See the Toolkit API sampleLWCComponent.js file in GitHub for more examples.
Note: Next Best Action has usage-based entitlements. Invoking recommendations in Service Cloud Voice counts towards that
usage.
99
Service Cloud Voice Toolkit API Service Cloud Voice Aura Toolkit API Telephony Events
CONFERENCE Sent when participants on a three-way call are all taken off hold.
SWAP Sent when participants on a three-way call have their hold status
swapped.
WRAP_UP_ENDED Sent when the agent exits after call work status.
To subscribe to these events, add a telephony event listener for each event you want to listen to.
// Subscribe
cmp.find('voiceToolkitApi')
.addTelephonyEventListener('CALL_STARTED', telephonyEventListenerFunc);
// Unsubscribe
cmp.find('voiceToolkitApi')
.removeTelephonyEventListener('CALL_STARTED', telephonyEventListenerFunc);
When an event occurs, you receive a JSON payload that contains the event type, along with any relevant data. For instance, the
CALL_STARTED event contains the following payload.
{
"type": "CALL_STARTED",
"detail": {
"callId": "d7a9f1b7-fc17-43fe-8ca7-e584a2b34792",
"callType": "outbound",
"participant": "+1 (415) 999-0000"
100
Service Cloud Voice Toolkit API Service Cloud Voice Aura Toolkit API Telephony Events
}
}
All payloads contain some basic information, such as the event type (type) and a unique call identifier (callId). Events can contain additional
values within the detail object. Refer to the following table for all the possible properties that can appear within the detail object of the
payload.
101
Service Cloud Voice Toolkit API Service Cloud Voice Aura Toolkit API Telephony Actions
102
Service Cloud Voice Toolkit API Service Cloud Voice Aura Toolkit API Telephony Actions
To perform telephony actions, load the Service Cloud Voice Aura Toolkit voiceToolkitApi, and then add a telephony method for
each call control you want to allow admins to perform.
103
Service Cloud Voice Toolkit API Service Cloud Voice Aura Toolkit API Conversation Events
For example, add the following components to let admins accept calls, end calls, decline calls, pause a call recording, and resume a
paused recording.
({
acceptCall: function(cmp) {
cmp.find('voiceToolkitApi').acceptCall()
},
endCall: function(cmp) {
cmp.find('voiceToolkitApi').endCall()
},
declineCall: function(cmp) {
cmp.find('voiceToolkitApi').declineCall()
},
pauseRecording: function(cmp) {
cmp.find('voiceToolkitApi').pauseRecording()
},
resumeRecording: function(cmp) {
cmp.find('voiceToolkitApi').resumeRecording()
}
startPreviewCall: function(cmp) {
var params = cmp.get('v.phoneNumber');
cmp.find('voiceToolkitApi').startPreviewCall(params);
}
})
See the Toolkit API SampleComponentHelper.js file in GitHub for more examples.
FLAG_LOWER Sent when an agent or supervisor lowers a raised flag to cancel the request for supervisor help.
NOTE Sent when an agent or supervisor sends a message without raising a flag. For example, an event is
sent when a user jots down notes but doesn't raise a flag.
104
Service Cloud Voice Toolkit API Service Cloud Voice Aura Toolkit API Conversation Events
To subscribe to an event, add a conversation event listener. For example, add the following event listener to subscribe to the TRANSCRIPT
event:
// Subscribe
cmp.find('voiceToolkitApi')
.addConversationEventListener('TRANSCRIPT', conversationEventListenerFunc);
// Unsubscribe
cmp.find('voiceToolkitApi')
.removeConversationEventListener('TRANSCRIPT', conversationEventListenerFunc);
You can add multiple conversation event listeners. For example, you can add the following event listeners to subscribe to all the events
related to raising and lowering flags:
// Subscribe
cmp.find('voiceToolkitApi')
.addConversationEventListener('FLAG_RAISE', conversationEventListenerFunc);
.addConversationEventListener('FLAG_LOWER', conversationEventListenerFunc);
// Unsubscribe cmp.find('voiceToolkitApi')
.removeConversationEventListener('FLAG_RAISE', conversationEventListenerFunc);
.removeConversationEventListener('FLAG_LOWER', conversationEventListenerFunc);
When an event occurs, you receive a JSON payload that contains the event type, along with any relevant data. For instance:
{
"type": "TRANSCRIPT",
"detail": {
"id": "3115b389-ab50-400e-b8ba-978b7ec51d7a"
"clientSentTimestamp": 1594944652299,
"serverReceivedTimestamp": 1594944652328,
"content":{
"formatType": "Text",
"text": "Hello"
},
"callId": "c5d93c19-e03b-44f8-85e6-a11f02e70c45",
"sender": {
"role": "Agent"
}
}
}
The following table describes the payload properties for the FLAG_RAISE, FLAG_LOWER, NOTE, and TRANSCRIPT events:
detail object Identifying information associated with this voice call event.
detail.clientSentTimestamp number The date and time (in UTC) when the client sent the content.
Measured in milliseconds since the Unix epoch.
detail.serverReceivedTimestamp number The date and time (in UTC) when the server received the content.
Measured in milliseconds since the Unix epoch.
105
Service Cloud Voice Toolkit API Service Cloud Voice Aura Toolkit API Conversation Events
content.formatType string The content format type of the raised flag, note, or transcript.
Possible value is “Text.”
content.text string The body text of the raised flag, note, or transcript.
callId string The unique ID of the voice call within the telephony system. For
example, if the telephony system is Amazon Connect, this value
is the contact ID.
sender object Information about the user whose action initiated the event.
sender.role string The role of the user whose action initiated the event. Possible
values are "Agent" and "Supervisor".
sender.displayName string The name of the user whose action initiated the event.
The following table describes the payload properties for the INTELLIGENCE_SIGNAL event:
detail object Identifying information associated with this voice call event.
detail.events string A piece of signal data generated in real time from a voice call
between an agent and end user. Events must be sorted in
chronological ascending order by startTime. For example, the
following snippet displays a piece of signal data.
{
"type": "IntelligenceSignal__Category",
"value": "CustomerAngry",
"startTime": 1573503450
}
event.service number The intelligence source of the events. Possible values are:
• AmazonConnectContactLens
event.type number The signal type of the event. Possible values are:
• IntelligenceSignal__Category
event.value object The value of the signal generated in real time by the telephony
vendor. For example, this could be a Contact Lens rule defined
in Amazon Connect.
event.startTime string The date and time (in UTC) when this event started. Measured
in milliseconds since the Unix epoch.
106
Service Cloud Voice Toolkit API Service Cloud Voice Aura Toolkit Next Best Action
event.score string The confidence score for the intelligence signal within the range
of 1 and 1000, with 1000 being the highest level of confidence.
Note: Next Best Action has usage-based entitlements. Invoking recommendations in Service Cloud Voice counts towards that
usage.
1. Build a recommendation strategy that uses the filter element and $Request variable. The $Request variable is a map containing key
value pairs. For example, if the recommendation strategy receives the data {intent: "refund"} then $Request.intent evaluates to
"refund". To learn more, see Write an Expression.
2. Enable real time recommendations in your Actions & Recommendations deployment and select the strategy you just built.
3. Invoke Einstein Next Best Action with a record ID and key:value pairs in the updateNextBestActions() function parameters.
Recommendations are displayed for record pages matching the provided ID. The value given to a particular key can be retrieved in
the Recommendation Strategy using $Request.key in the filter element.
The following filter element expression shows recommendations that contain a particular keyword in the recommendation name. To
learn more, see Write an Expression.
$Request.key != '' && CONTAINS(Name, $Request.key)
SEE ALSO:
Salesforce Help: Einstein Next Best Action
Salesforce Help: Einstein Next Best Action Entitlements
107
Service Cloud Voice Toolkit API Service Cloud Voice Toolkit API Sample Components
READ and UPDATE operations are supported for VoiceCall records. UPDATE is restricted to custom fields and the following standard
fields: Call Resolution, RelatedRecord, Description.
SEE ALSO:
Salesforce Help: Lightning Data Service
SEE ALSO:
Toolkit API Sample Component in GitHub
108
CHAPTER 5 Upload or Update Transcripts with Connect REST API
Use Connect REST API to upload and update transcripts for voice calls. This functionality can also be used
for redacting content in transcripts.
These Connect API resources provide programmatic access to voice transcripts (also called “conversation
entries”) so that customers can build custom solutions with voice transcripts.
/connect/conversations/upload (GET)
Get the status of conversation uploads.
/connect/conversations/upload (POST)
Upload bulk conversations.
/connect/conversation/conversationIdentifier/entries (GET)
Get conversation entries.
/connect/conversation/conversationIdentifier/entries (PATCH)
Update conversation entries.
Usage Example
This example describes how to perform bulk upload of transcripts to a voice call after the conversation.
1. Retrieve the VoiceCall ID for a conversation.
In order to perform the subsequent steps, you must get the VoiceCall record ID.
2. Using the VoiceCall ID, retrieve the Conversation record and the ConversationParticipant records.
Using SOQL, you can query for the Conversation ID. For example:
SELECT ConversationId FROM VoiceCall WHERE Id = '0LMRM000000HU8a4AG'
With the Conversation ID, you can query for additional fields on the Conversation record. For example:
SELECT
ConversationChannelId,ConversationIdentifier,CreatedById,CreatedDate,EndTime,Id,IsDeleted,LastModifiedById,LastModifiedDate,Name,StartTime
109
Upload or Update Transcripts with Connect REST API
You can also get information about the ConversationParticipant records. For example:
SELECT
AppType,ConversationId,CreatedById,CreatedDate,Id,IsDeleted,JoinedTime,LastActiveTime,LastModifiedById,LastModifiedDate,LeftTime,Name,ParticipantContext,ParticipantDisplayName,ParticipantEntityId,ParticipantKey,ParticipantRole
Values returned from this SOQL call are used in the subsequent upload API POST payload. Specifically:
• AppType in the SOQL call is used for the “appType” value in the payload. For API version 52.0
and later, refer to the AppType to appType Mapping table.
• ParticipantRole is used for the “role” value. For API version 52.0 and later, refer to the
ParticipantRole to role Mapping table.
• ParticipantKey is used for the “subject” value.
live_message LIVE_MESSAGE
chatbot CHATBOT
messaging MESSAGING
perftool PERFTOOL
agent AGENT
telephony_integration TELEPHONY_INTEGRATION
translation TRANSLATION
iamessage IAMESSAGE
conversation CONVERSATION
Agent AGENT
Chatbot CHATBOT
EndUser END_USER
Supervisor SUPERVISOR
Router ROUTER
110
Upload or Update Transcripts with Connect REST API
Use a payload that contains the desired conversation participant info, along with the conversation
entries. For example, the following payload sample applies to API version 52.0 and later.
{"type": "conversation", "payload": {"conversationId":
"fc803778-76d6-4d60-a53d-fb69d800b10c"}}
{"type": "conversationEntry", "payload": {"conversationId":
"fc803778-76d6-4d60-a53d-fb69d800b10c", "id": "1",
"clientSentTimestamp": 1610580214000, "clientDuration": 123432,
"messageText":"Hello, how can I help you?","sender": {"appType":
"AGENT", "subject": "005RM00000225FB","role": "AGENT"}}}
{"type": "conversationEntry", "payload": {"conversationId":
"fc803778-76d6-4d60-a53d-fb69d800b10c", "id": "2",
"clientSentTimestamp": 1610580214001, "clientDuration": 123432,
"messageText":"I want to return this merchandise. Can you please
help?","sender": {"appType": "TELEPHONY_INTEGRATION", "subject":
"END_USER","role": "END_USER"}}}
Note: Currently, this API only supports existing closed conversations. A previous version of
this API required a conversation channel, the start timestamp, and the end timestamp in the
conversation object, and it required conversation participant objects. These values are now
optional.
You get the following response when the call is successful.
{
"conversationBulkUploadsResults": [
{
"conversationIdentifier":
"fc803778-76d6-4d60-a53d-fb69d800b10c",
"errorDetail": null,
"status": "SUCCESS",
"uploadId": "333e7382-ef11-3396-b7c2-156fb6b5f7ad"
}
]
}
111
Upload or Update Transcripts with Connect REST API
You can get the new conversation entries using an HTTP GET to
/connect/conversation/conversationIdentifier/entries.
112
CHAPTER 6 Using the Service Cloud Voice Lambda Functions for
Amazon Connect
In this chapter ... Salesforce provides a set of Lambda functions, which are available within your Amazon Connect instance
after provisioning the instance with Service Cloud Voice. You can use these Lambdas in Amazon Connect
• How to Use contact flows.
Salesforce Lambda
Functions These Lambdas interact with Salesforce to perform the following actions:
• Service Cloud Voice • Create a voice call (InvokeTelephonyIntegrationApiFunction on page 123).
Authentication When • Start real-time transcription and save transcripts to Salesforce (kvsConsumerTrigger on page 137,
Using kvsTranscriber on page 138).
InvokeSalesforceRestApiFunction
• Sync data between a contact trace record (CTR) and a VoiceCall object (CTRDataSyncFunction on
• InvokeSalesforceRestApiFunction page 132).
Lambda Function
• Invoke the Salesforce REST API to perform CRUD operations on Salesforce objects, such as cases,
• n
I vokeTee
l phonyn
I tegrato
i nApFiuncto
in
accounts, or custom objects (InvokeSalesforceRestApiFunction on page 120).
Lambda Function
For more detail, refer to the reference pages for the Lambda functions.
• ContactLensConsumerFunction
Lambda Function
• ContactLensProcessorFunction SEE ALSO:
Lambda Function Sample Amazon Connect Flows for Service Cloud Voice
• ContactDataSync How to Use Salesforce Lambda Functions
Lambda Function
• CTRDataSyncFunction
Lambda Function
• HandleContactEventsFunction
Lambda Function
• PostCallAnalysisTriggerFunction
Lambda Function
• RealtimeAlertLambda
Lambda Function
• VoiceMailAudioProcessingFunction
Lambda Function
• VoiceMailPackagingFunction
Lambda Function
• VoiceMailTranscribeFunction
Lambda Function
• kvsConsumerTrigger
Lambda Function
• kvsTranscriber
Lambda Function
113
Using the Service Cloud Voice Lambda Functions for Amazon
Connect
114
Using the Service Cloud Voice Lambda Functions for Amazon How to Use Salesforce Lambda Functions
Connect
After calling a Lambda function, be sure to store the output value using a Set contact attributes block. If you don’t store the output,
subsequent calls can overwrite this value.
In the Set contact attributes block, the Attribute must match the output variable and the type must be External.
115
Using the Service Cloud Voice Lambda Functions for Amazon Service Cloud Voice Authentication When Using
Connect InvokeSalesforceRestApiFunction
The Destination key can be whatever value you want to use as a variable later in your contact flow.
SEE ALSO:
AWS Lambda Developer Guide
Salesforce Help: Update Your Contact Center
SEE ALSO:
Salesforce Help: Create a Private Key and Self-Signed Digital Certificate
InvokeSalesforceRestApiFunction Lambda Function
116
Using the Service Cloud Voice Lambda Functions for Amazon Set Up OAuth in Your Service Cloud Voice Connected App
Connect
SEE ALSO:
Salesforce Help: Create a Private Key and Self-Signed Digital Certificate
Salesforce Help: Create a Connected App
Salesforce Help: Enable OAuth Settings for API Integration
117
Using the Service Cloud Voice Lambda Functions for Amazon Set Up OAuth in the AWS Lambda Function
Connect
3. Scroll down to Environment variables. Some of the variables are already configured for your instance, but you have to set the
values for CONSUMER_KEY_PARAM_NAME, PRIVATE_KEY_PARAM_NAME, and SUBJECT.
Note: If you’re testing this functionality in a sandbox org, make sure that these environment variables point to the sandbox
domain (or to test.salesforce.com) instead of login.salesforce.com: AUDIENCE,
SALESFORCE_AUTH_ENDPOINT, SALESFORCE_REST_API_ENDPOINT_BASE.
a. Copy the values for the CONSUMER_KEY_PARAM_NAME, PRIVATE_KEY_PARAM_NAME parameters and paste them
into a text file. These values are the names of the SSM parameters that hold the actual credentials.
b. For the SUBJECT variable, enter the Salesforce username of the user you want to log in to Salesforce through the Lambda
function. The user must be able to access to the objects that the Lambda function will be executed.
In the connected app in Salesforce, check that the user is added to the connected app profile. From Setup in your Salesforce
org, go to App Manager. Open the action menu for the connected app, click Manage, and scroll to the bottom of the page to
see the profiles. Verify that the Permitted Users value is set to "Admin approved users are pre-authorized" for the desired profile.
To learn more about OAuth access policies, see Manage OAuth Access Policies for a Connected App.
4. Click Services > enter SSM in the search box > Systems Manager.
5. Scroll down to the Parameter Store.
6. In the parameter store, search for the CONSUMER_KEY_PARAM_NAME value and the PRIVATE_KEY_PARAM_NAME value
that you copied to the text file.
7. For the Consumer Key, update the value by clicking Edit and pasting the value of the consumer key from the connected app into
the Value field.
118
Using the Service Cloud Voice Lambda Functions for Amazon Set Up OAuth in the AWS Lambda Function
Connect
Note: If you didn’t already copy the Consumer Key from your app, you can get that value from your Salesforce org. From
Setup, enter Apps in the Quick Find box, and select App Manager. Click View in the dropdown menu for your connected
app. Copy the value for the Consumer Key from the connected app page.
119
Using the Service Cloud Voice Lambda Functions for Amazon Test OAuth with Service Cloud Voice Lambda Function
Connect
Note: The private key isn’t the same as the consumer secret, although both are generated by the same key. The private key
begins with “-----BEGIN RSA PRIVATE KEY-----” and ends with “-----END RSA PRIVATE KEY-----”.
Be sure to include that BEGIN and END text as part of the key value.
Note: It can take a few minutes before the changes are applied to the connected app.
SEE ALSO:
Salesforce Help: Create a Private Key and Self-Signed Digital Certificate
Important: Before using this function, you must have OAuth authentication set up. To set up or modify authentication, see Service
Cloud Voice Authentication When Using InvokeSalesforceRestApiFunction on page 116.
This Lambda function uses the environment variable SALESFORCE_REST_API_ENDPOINT_BASE to point to the Salesforce org
API endpoint. (For example, https://MY_DOMAIN.my.salesforce.com/services/data/v50.0.) This variable is
120
Using the Service Cloud Voice Lambda Functions for Amazon InvokeSalesforceRestApiFunction Lambda Function
Connect
automatically created when you set up Service Cloud Voice. However, if you get a response of { success: false }, verify that
this Lambda environment variable is correct.
Sample Contact Flows That Use This Function: Sample_SCV_REST_Check_For_Open_Cases, Sample_SCV_REST_Link_Call_To_Case.
To download these flows, visit our Sample Contact Flows folder in GitHub.
Limitations: This Lambda function is subject to Salesforce API request limits and allocations.
Usage: Use this function to create a record, update an existing record, or query for a record. To learn more about programmatically
managing Salesforce records, refer to the Object Reference for Salesforce and Lightning Platform and the Salesforce REST API Developer
Guide.
This Lambda takes a “methodName” attribute as an argument. This attribute indicates the specific action that the Lambda must perform.
Query for a Salesforce record queryRecord soql containing the desired SOQL query.
For example:
SELECT Id FROM Contact
WHERE Phone =
'$.Attributes.MY_CONTACT_ATTRIBUTE'
queryRecord Names match the names of the fields you A list of the selected fields. Each attribute
queried. contains a different field. Regardless of your
121
Using the Service Cloud Voice Lambda Functions for Amazon InvokeSalesforceRestApiFunction Lambda Function
Connect
TIP: To check that the function returned information successfully, add a condition to a Check contact attributes block to check an
output attribute based on some detail you expect to see in the result. For instance, let’s say you’re creating a contact record. A contact
ID always contains “003” in the ID value, so you can use that information to check the success or failure of the call. The first step is to
store the return attribute in a user-defined attribute by using a Set contact attributes block:
And then you can use a Check contact attributes block to access this user-defined attribute:
122
Using the Service Cloud Voice Lambda Functions for Amazon InvokeTelephonyIntegrationApiFunction Lambda Function
Connect
SEE ALSO:
Service Cloud Voice Authentication When Using InvokeSalesforceRestApiFunction
123
Using the Service Cloud Voice Lambda Functions for Amazon InvokeTelephonyIntegrationApiFunction Lambda Function
Connect
3. Execute an Omni-Channel flow. This action occurs when work is ready to be routed.
4. Cancel an Omni-Channel flow. This action occurs when an existing flow needs to be canceled.
Important: When a Lambda function hasn’t been invoked after a period of time, the AWS framework unloads the function from
memory. The next time the function is invoked, it is “cold” and takes longer to load into memory. This delay can cause a timeout
in the contact flow. To avoid this behavior, learn how to keep this function warm on page 125.
Sample Contact Flows That Use This Function: Sample SCV Transfer Flow for Agent Transfers Sample SCV Transfer Flow for Queue
Transfers, Sample SCV Inbound Flow. To download these flows, visit our Sample Contact Flows folder in GitHub.
Usage: Place this Lambda within one of the relevant contact flows (either for an inbound call or a transfer). This Lambda takes a
“methodName” attribute as an argument. This attribute indicates the specific action that the Lambda must perform.
Request routing instructions from an Omni-Channel flow and create a methodName executeOmniFlow
PendingServiceRequest.
Note: Calls routed with this method appear in the Queue Backlog tab of Omni
Supervisor. If a PendingServiceRequest isn’t created and the voice call isn’t routed
by Omni-Channel, then the Queue Backlog tab doesn’t show the call. For example,
calls that are manually assigned to an agent don’t appear in that tab.
Optionally, provide these inputs:
• flowDevName. Set the Omni-Channel flow using its developer name.
• fallbackQueue. Set the fallback queue using its Salesforce queue developer
name or ID.
• Custom parameters with prefix flowInput-. Set additional inputs to the
Omni-Channel flow.
By default, Service Cloud Voice uses the Omni-Channel flow (or fallback queue) specified
for the phone channel that matches the dialed number. If the dialed number doesn’t
match an existing phone channel, you can optionally set the Omni-Channel flow or
fallback queue in these input parameters. The fallback queue is used only if the specified
flow doesn’t exist or one isn’t specified.
Cancels an Omni-Channel flow that was previously executed. This method also calls the methodName cancelOmniFlowExecution
Clear Routing on page 85 REST API to clear the PendingServiceRouting (PSR) record.
When creating a voice call record, you can also specify custom data to be added to fields on the VoiceCall record. To add custom date,
create a “Set contact attributes” block before the Lambda call. For the destination attribute, specify the name of the custom field with
the “sfdc-” prefix added. The value of this attribute is the data to pass into the custom field For an example, see Pass Data from the
Interactive Voice Response (IVR) System on page 4.
124
Using the Service Cloud Voice Lambda Functions for Amazon Keep the InvokeTelephonyIntegrationApiFunction Lambda
Connect Function Warm
SEE ALSO:
Keep the InvokeTelephonyIntegrationApiFunction Lambda Function Warm
2. From the AWS Lambda function page, select the InvokeTelephonyIntegrationApiFunction Lambda function.
125
Using the Service Cloud Voice Lambda Functions for Amazon Keep the InvokeTelephonyIntegrationApiFunction Lambda
Connect Function Warm
Note: The Lambda function has your contact center name as the prefix.
3. Copy the name of the function to your clipboard so that you can create a unique name for your rule later.
4. From the function overview page, select the Configuration tab (1). Click the Triggers subtab in the sidebar (2). To create a trigger,
click the Add trigger button (3).
5. From the Trigger configuration page, search for the EventBridge trigger and select it.
6. Set up your trigger so that it runs every five minutes using the following values.
126
Using the Service Cloud Voice Lambda Functions for Amazon ContactLensConsumerFunction Lambda Function
Connect
The InvokeTelephonyIntegrationApiFunction Lambda function automatically detects when it’s being executed by a scheduled
event trigger and only performs enough processing to stay warm.
SEE ALSO:
Amazon EventBridge
127
Using the Service Cloud Voice Lambda Functions for Amazon ContactLensProcessorFunction Lambda Function
Connect
Configuration: This function is available to Service Cloud Voice customers who are using an Amazon Connect instance that’s provided
by Salesforce. This function is available in Service Cloud Voice contact center 9.0 and later versions. Starting in contact center version
11.1, we split this Lambda function into two by introducing the ContactLensProcessorFunction Lambda function to improve performance.
Usage: This function performs these actions:
1. Reads the transcripts generated from Contact Lens in real time and sends them to the ContactLensProcessorFunction on page 128
Lambda function.
2. Reads the conversation intelligence signals generated from Contact Lens in real time and sends them to the
ContactLensProcessorFunction Lambda function.
This function supports inbound calls, transfer calls, outbound calls, and callback calls.
SEE ALSO:
Create Transcripts in Bulk
ContactLensProcessorFunction Lambda Function
SEE ALSO:
Create Transcripts in Bulk
ContactLensConsumerFunction Lambda Function
Increase Performance of the ContactLensProcessor Lambda Function
128
Using the Service Cloud Voice Lambda Functions for Amazon Increase Performance of the ContactLensProcessor Lambda
Connect Function
SEE ALSO:
ContactLensProcessorFunction Lambda Function
129
Using the Service Cloud Voice Lambda Functions for Amazon ContactDataSync Lambda Function
Connect
Configuration: This function is available to Service Cloud Voice customers who are using an Amazon Connect instance that’s provided
by Salesforce. This function is available in Service Cloud Voice contact center version 15.0 and later.
Usage: Call this function manually from the AWS Console or by using the AWS CLI.
1. From the AWS Console, select the contactDataSync Lambda function.
2. From the Test tab, run the Lambda.
a. Use the example payload to run an uploadTranscript operation, substituting your contactId and
relatedRecords values. The contactId parameter in Amazon Connect is the unique ID of the voice call record,
equivalent to vendorCallKey in Salesforce. The relatedRecords array lists the 15-digit VoiceCallId.
Here’s an example request payload:
{
"operation": "uploadTranscript",
"payload": [
{
"contactId": "faaa3a21-5990-48cd-a035-e85ca8c861ff",
"relatedRecords": [
"0LQ1Q000002TZtn"
]
},
{
"contactId": "f15c9342-65a1-41e8-a752-81d630a2890d",
"relatedRecords": [
"0LQ1Q000002TAtn"
]
}
]
}
"{\"conversationBulkUploadsResults\":[{\"conversationIdentifier\":\"faaa3a21-5990-48cd-a035-e85ca8c861ff\",
\"errorDetail\":null,\"status\":\"SUCCESS\",\"uploadId\":\"f230e3d9-6c0f-3909-a0a8-1b78c634bbde\"},
{\"conversationIdentifier\":\"f15c9342-65a1-41e8-a752-81d630a2890d\",\"errorDetail\":null,\"status\":
\"SUCCESS\",\"uploadId\":\"2f30e4d9-6c0f-3109-a0a8-1b78c634cdis\"}]
}"
},
{
"StatusCode": 200,
"ExecutedVersion": "$LATEST",
"Payload":
130
Using the Service Cloud Voice Lambda Functions for Amazon ContactDataSync Lambda Function
Connect
"{\"conversationBulkUploadsResults\":[{\"conversationIdentifier\":\"f15c9342-65a1-41e8-a752-81d630a2890d\",
\"errorDetail\":null,\"status\":\"SUCCESS\",\"uploadId\":\"68279b80-a394-3228-b99b-c60f02ff8227\"}]
}"
}
]
b. Find the uploadId values from the response, and use them to run an additional fetchUploadIdsStatus operation
that monitors the progress of the transcript upload.
Here’s an example request payload:
{
"operation": "fetchUploadIdsStatus",
"uploadIds": [
"f230e3d9-6c0f-3909-a0a8-1b78c634bbde",
"68279b80-a394-3228-b99b-c60f02ff8227"
]
}
"{\"conversationBulkUploadStatuses\":[{\"conversationId\":\"fe7095c8-0ec7-48b8-b539-772f4b3c96e4\",
\"errorDetail\":null,\"failedEntryCount\":0,\"failedEntryIds\":[],\"lastUpdatedTimestamp\":1714149083044,
\"status\":\"SUCCESS\",\"successEntryCount\":2,\"uploadId\":\"ca90995b-802d-39f5-8525-2902a338bcbd\"}]
}"
}
Limits:
• You can use this function to backfill and upload transcripts for up to 100 voice calls at a time.
• The timestamps on transcripts that this function backfills and uploads reflect when the function is run, not when the conversation
occurred.
• The contactId that this function takes as input must have an associated agent.
• To backfill and upload complete transcripts, end calls only after Amazon has finalized the transcription process. Voice calls that end
before the transcription process is finalized result in the partial upload of transcripts for those calls.
SEE ALSO:
Salesforce Help: Update Your Contact Center
Upload or Update Transcripts with Connect REST API
131
Using the Service Cloud Voice Lambda Functions for Amazon CTRDataSyncFunction Lambda Function
Connect
DisconnectTimestamp CallEndDateTime
Agent.ConnectedToAgentTimestamp CallAcceptDateTime
Agent.LongestHoldDuration LongestHoldDuration
Agent.NumberOfHolds NumberOfHolds
Queue.EnqueueTimestamp CallQueuedDateTime
Queue.Name QueueName
InitiationMethod CallType (only when creating a new record) This value is used to infer values for
ToPhoneNumber and FromPhoneNumber.
Also used for the CallType field if creating a
new VoiceCall record.
Supported InitiationMethod values include:
132
Using the Service Cloud Voice Lambda Functions for Amazon Customize Synced CTR Fields Using CTRDataSyncFunction
Connect
• API
• INBOUND
• OUTBOUND
• CALLBACK
• TRANSFER
Usage: The data synchronization automatically starts when a CTR is generated. You don’t need to call this function manually.
Tip: The CustomerHoldDuration and NumberOfHolds fields don’t have values until after the CTRDataSyncFunction Lambda
function runs. As such, to determine if the Lambda function is done, search for these values in these fields.
SEE ALSO:
Salesforce Help: Configure Your Amazon Connect Instance
133
Using the Service Cloud Voice Lambda Functions for Amazon Customize Synced CTR Fields Using CTRDataSyncFunction
Connect
3. In the utils.js file for the CTRDataSyncFunction Lambda, update the end of the transformCTR(ctr) function (where there’s a
comment to Add custom fields here).
// Check if there are custom contact attributes
if (ctr.Attributes) {
let callAttributes = {};
voiceCall.callAttributes = JSON.stringify(callAttributes);
}
...
In that location, you can add any custom attributes to the callAttributes object. Add this code before the
JSON.stringify(callAttributes) line. Your custom attributes are synced along with the automatically-synced attributes. The following
example adds two fields to the list of synced fields:
// Check if there are custom contact attributes
if (ctr.Attributes) {
let callAttributes = {};
voiceCall.callAttributes = JSON.stringify(callAttributes);
}
...
4. Deploy the new version of the Lambda function in your Amazon Connect instance.
To learn more about managing Lambda function versions, see Lambda function versions in the AWS Lambda Developer Guide.
134
Using the Service Cloud Voice Lambda Functions for Amazon HandleContactEventsFunction Lambda Function
Connect
SEE ALSO:
AWS Lambda Developer Guide
SEE ALSO:
Store a Post-Call Conversation Event
135
Using the Service Cloud Voice Lambda Functions for Amazon VoiceMailAudioProcessingFunction Lambda Function
Connect
SEE ALSO:
Customer Alerts Alarms
Customer Alerts Platform Event
SEE ALSO:
Enable Voicemail Support
VoiceMailTranscribeFunction Lambda Function
VoiceMailPackagingFunction Lambda Function
136
Using the Service Cloud Voice Lambda Functions for Amazon VoiceMailTranscribeFunction Lambda Function
Connect
1. Gets the voicemail recording and transcription files from the contact center’s Amazon S3 bucket.
2. Creates a VoiceCall record. Sets the callOrigin parameter to Voicemail, and sets other parameters, including from, to, and
duration.
3. Attaches the voicemail recording and the transcription files to the VoiceCall record.
4. Routes the VoiceCall record to the Omni-Channel flow that was configured in the contact center.
For an example, see Set Up Voicemail.
SEE ALSO:
Enable Voicemail Support
VoiceMailAudioProcessingFunction Lambda Function
VoiceMailTranscribeFunction Lambda Function
SEE ALSO:
Enable Voicemail Support
VoiceMailAudioProcessingFunction Lambda Function
VoiceMailPackagingFunction Lambda Function
137
Using the Service Cloud Voice Lambda Functions for Amazon kvsTranscriber Lambda Function
Connect
custom vocabulary and vocabulary filtering, see Improve Amazon Transcribe's Transcription Accuracy with Custom Vocabulary and
Filters on page 7.
138
Using the Service Cloud Voice Lambda Functions for Amazon Query AWS Lambda Functions to Analyze a Voice Call
Connect
/aws/lambda/ContactCenter1-InvokeTelephonyIntegrationApiFunction
/aws/lambda/ContactCenter1-kvsConsumerTrigger
/aws/lambda/ContactCenter1-kvsTransriber
/aws/lambda/ContactCenter1-RealtimeAlert
/aws/lambda/ContactCenter1-RententionPeriodFunction
/aws/lambda/ContactCenter1-VoiceMailAudioProcessingFunction
6. In the query editor, type the following query, where VENDOR_CALL_KEY is the unique ID of the voice call (VoiceCall) record
within the telephony system. The query is case sensitive.
fields @timestamp, @message, @logStream, @log
| filter ContactId = 'VENDOR_CALL_KEY' OR context.contactId = 'VENDOR_CALL_KEY' | sort
@timestamp asc
For example,
fields @timestamp, @message, @logStream, @log
| filter ContactId = '12faf34a-f1d5-6b07-89fc-6e3bce61d65f' OR context.contactId =
'12faf34a-f1d5-6b07-89fc-6e3bce61d65f'
| sort @timestamp asc
To learn more about the query syntax, see the Amazon CloudWatch Logs Insights Query Syntax documentation.
7. Specify the date range of the voice call record you want to query, click Custom, select the Absolute tab, and then select and apply
the date range of the voice call.
8. Click Run query. Amazon CloudWatch finds all logs across all Amazon Lambda functions and Amazon Connect flows that are related
to the specified voice call record and displays the results in the Logs tab.
The first event is created when the voice call record begins. Expand each event to view its details, including the name of the Amazon
Connect flow or AWS Lambda output, and any error messages.
SEE ALSO:
Knowledge Article: Update Your Contact Center
Object Reference for the Salesforce Platform: VoiceCall
Amazon CloudWatch: CloudWatch Logs Insights Query Syntax
139
CHAPTER 7 Amazon Connect Flows
In this chapter ... An Amazon Connect flow depicts a customer’s voice call journey from beginning to end. Configure
Service Cloud Voice flows for your contact center to determine how Salesforce handles inbound calls,
• Amazon Connect outbound calls, and call transfers.
Flows Best Practices
Each Service Cloud Voice flow is configured in Amazon Connect using a flow map made up of blocks,
• Sample Flows for
beginning with an Entry block and ending with a Transfer to flow or Disconnect block. To learn more
Service Cloud Voice
about Amazon flows, see the Amazon Connect Administrator Guide.
Salesforce provides several out-of-the box Sample Service Cloud Voice flows in GitHub you can customize
for your Service Cloud Voice contact center environment. For example, the Sample SCV Inbound Flow
is used to route incoming voice calls. When a customer calls the contact center, the call triggers the
inbound flow starting at the Entry block. The call then traverses the flow, block by block, stopping at
each block to determine what happens next. The flow eventually arrives at the Transfer to flow block,
which ends this flow and transfers the call to the Omni-Channel Subflow. If errors are encountered at
any point in the flow, the call gets routed to the Disconnect block.
A subflow is a flow within a flow. Salesforce offers several out-of-the-box subflows that let you add
features to a flow, such as Omni-Channel routing, callbacks, and voicemails. A subflow can’t be used on
its own; instead, it must be added to a flow using the Transfer to flow block. You can add multiple
subflows to a flow by daisy-chaining them together. In fact, some of the sample flows include several
subflows daisy-chained together. For example, the Sample SCV Inbound Flow includes the Sample SCV
Omni-Channel Subflow, which then transfers out to a series of other subflows ending with the Sample
SCV Transcription Subflow with Contact Lens.
Here’s how an inbound call flows through the daisy chain of subflows using the Salesforce-provided
"Sample SCV" flows:
1. A call comes in, which triggers the Sample SCV Inbound Flow.
2. The call moves through the Sample SCV Inbound Flow, creating a voice call (VoiceCall) record
and setting the contact attribute for voiceCallId before it’s transferred to the Sample SCV
Omni-Channel Subflow.
3. The call moves through the Sample SCV Omni-Channel Subflow, routing and prioritizing the call
based on the routing logic of the specified Omni-Channel flow. After this, the call is transferred to
the Sample SCV Callback Subflow.
4. The call moves through the Sample SCV Callback Subflow, giving the caller the option to schedule
a callback if the queue is busy. If the caller chooses to schedule a callback, the call is transferred to
the Callback queue. If the caller chooses to remain on the line, the call is transferred to the Sample
SCV Transcription Subflow with Contact Lens.
5. The call moves through the Sample SCV Transcription Subflow with Contact Lens, enabling real-time
transcription before finally transferring the call to the queue. This ends the entire flow.
The order of the subflow chain matters. For example, for inbound calls, if you place the Omni-Channel
Subflow before the Callback Subflow, callback calls will be routed correctly. If you flip the subflows by
140
Amazon Connect Flows
placing the Callback Subflow before the Omni-Channel Subflow, callback calls will be routed to the basic
queue.
For inbound calls, you can’t point a phone number directly to a subflow; instead, point your phone
number to the inbound flow. Subflows don’t create a voice call record in Salesforce; they rely on the
inbound flow to do that.
Note: Service Cloud Voice doesn’t support queue transfers for voice calls already in one queue
and transferred to another queue using the Transfer to queue block in the Amazon Connect flow.
In this scenario, the call recording and transcription are available in Amazon Connect but not
Salesforce. Alternatively, you can use routing profiles to transfer voice calls to groups of agents to
take calls for queues they don't typically handle when certain criteria are met. See Managing
Increases in Call Volumes with Routing Profiles.
SEE ALSO:
GitHub: Sample Service Cloud Voice Flows
Amazon Connect Flow Documentation
141
Amazon Connect Flows Amazon Connect Flows Best Practices
Voice Resiliency
Voice resiliency ensures that the telephony system stays operational when the number of conversations is over limit or when certain
background services are affected. See the Voice Resiliency for Service Cloud Voice knowledge article for more information about voice
resiliency.
If you customized any of the following Sample Service Cloud Voice flows in GitHub, verify they are configured to support voice resiliency:
• Sample SCV Inbound Flow
• Sample SCV Transfer Flow For Agent Transfers
• Sample SCV Transfer Flow For Omni-Channel Transfers
• Sample SCV Transfer Flow For Queue Transfers
• Sample SCV Callback Subflow
To support voice resiliency, make sure the the inbound, transfer, and callback flows do the following if the Invoke AWS Lambda function
block fails:
• Routes the voice call to an agent or queue.
• Doesn’t hang up/disconnect the call, even if a contact flow block errors out.
The Sample SCV flows in GitHub for inbound, transfer, and callback flows are configured to support voice resiliency. Here’s an example
from the Sample SCV Inbound Flow contact flow:
142
Amazon Connect Flows Sample Flows for Service Cloud Voice
The sample flows are occasionally updated and released with Salesforce contact center updates. To ensure you see the latest versions
of the sample flows in Amazon Connect, first verify that your contact center is updated to the latest version. The JSON files in GitHub are
always updated to the latest version.
Salesforce offers the following sample flows, which you can customize for your Service Cloud Voice contact center environment:
Inbound Flows
• Sample SCV Inbound Flow: Creates a voice call record in Salesforce for the inbound call and transfers the call to the SCV
Omni-Channel subflow. Associate your phone number with this flow so customers can reach your contact center. JSON file
If you customize the Sample SCV Inbound Flow, make sure it's configured to support voice resiliency. See the Amazon Connect Flows
Best Practices on page 142 page for more information.
Outbound Flows
• Sample SCV Outbound Flow With Transcription Using Amazon Transcribe: Starts media streaming. Also starts transcription
using Amazon Transcribe, capturing and transcribing audio for outbound voice calls. If you use this preferred flow, you can’t use the
Sample SCV Outbound Flow With Transcription Using Amazon Transcribe flow. Since the Sample SCV Outbound Flow With Transcription
Using Contact Lens on page 11 offers more robust transcription features, consider using that flow instead of this one. JSON file
• Sample SCV Outbound Flow With Transcription Using Contact Lens: Starts transcription using Contact Lens for Amazon
Connect, capturing and transcribing audio for outbound voice calls. If you use this preferred flow, you can’t use the Sample SCV
Outbound Flow With Transcription Using Amazon Transcribe flow. JSON file
Transfer Flows
• Sample SCV Transfer Flow For Agent Transfers: Creates a voice call record and transfers the call from one agent to another
specified agent. JSON file
• Sample SCV Transfer Flow For Omni-Channel Transfers: Creates a voice call record and transfers the call from an agent to a
specified Omni-Channel flow. JSON file
• Sample SCV Transfer Flow For Queue Transfers: Creates a voice call record and transfers the call from an agent to a specified
queue. JSON file
If you customize the Sample SCV Transfer flows, make sure it's configured to support voice resiliency. See the Amazon Connect Flows
Best Practices on page 142 page for more information.
Subflows
• Sample SCV Callback Subflow: Gives the caller the option to schedule a callback if the queue is busy. If the caller chooses to
schedule a callback, transfers the voice call to the Callback queue. If the caller chooses to remain on the line, transfers the call to one
of the SCV Transcription Subflows. JSON file
If you customize the Sample SCV Callback Subflow, make sure it's configured to support voice resiliency. See the Amazon Connect
Flows Best Practices on page 142 page for more information.
143
Amazon Connect Flows Sample Flows for Service Cloud Voice
• Sample SCV Field Service Phone Call Subflow: Connects field agents to contact center agents. JSON file
• Sample SCV Omni-Channel Subflow - Basic Routing With Case Creation: Creates a case for each inbound voice call, routes the
call to a queue, and opens a screen-pop for the new case record when an agent accepts the call. JSON file
• Sample SCV Transcription Subflow With Amazon Transcribe: Enables call recording and real-time transcription using Amazon
Transcribe, and then transfers the voice call to the queue. JSON file
• Sample SCV Transcription Subflow With Contact Lens: Enables call recording and real-time transcription using Contact Lens,
and then transfers the voice call to the queue. JSON file
• Sample SCV Voicemail Subflow: Gives the caller the option to leave a voicemail. Agents can play the recordings and read the
transcriptions of all voicemails routed to them. JSON file
Other Flows
These flows demonstrate how you can use the InvokeSalesforceRestApiFunction Lambda function on page 120 to perform
some common tasks with the Salesforce REST API.
• Sample_SCV_REST_Check_For_Open_Cases: Checks for open cases using the InvokeSalesforceRestApiFunction
Lambda function. JSON file
• Sample_SCV_REST_Link_Call_To_Case: Links a voice call to an open case using the
InvokeSalesforceRestApiFunction Lambda function. This flow adds on to the Sample SCV Invoke REST API Check For
Open Cases flow. JSON file
144
CHAPTER 8 Service Cloud Voice Customer Alerts with
CloudWatch
In this chapter ... Ensure that your Service Cloud Voice implementation is running properly with the Amazon CloudWatch
dashboards and alarms that we provide. Monitor the health of your contact center with two dashboards.
• Customer Alerts Fine-tune the alarms so they trigger when something needs attention in your environment. Notify the
Alarms right people about these events with the new RealtimeAlertEvent platform event.
• Customer Alerts
Dashboards
• Customer Alerts
Platform Event
These customer alert features are available to all customers running version 8.0 or later of the Service
Cloud Voice contact center in Amazon. To learn how to view or update your contact center, see Update
Your Contact Center in Salesforce Help.
SEE ALSO:
Salesforce Help: Update Your Contact Center
145
Service Cloud Voice Customer Alerts with CloudWatch Customer Alerts Alarms
You can monitor these alarms directly from within CloudWatch, using the provided dashboards on page 150, or by listening for the
RealtimeAlertEvent platform event on page 151 in your Salesforce org. The alarms automatically trigger this platform event using a
Lambda function (RealtimeAlertLambda Lambda Function on page 135).
The following alarms are automatically installed with the Customer Alerts template. Review the Initial State column to see which alarms
are automatically turned on by default. To learn how to enable alarms, or how to fine-tune alarms, see Using Amazon CloudWatch alarms
in the Amazon CloudWatch User Guide.
Concurrent Calls SCV Connect Concurrent Triggers when the number Enabled Contact Amazon to increase number
Calls Percentage of concurrent active voice of concurrent voice calls allowable for
calls in the connect instance your implementation. Contact your
during the evaluation period Salesforce admin for help.
is greater than the threshold.
146
Service Cloud Voice Customer Alerts with CloudWatch Customer Alerts Alarms
Errors SCV Lambda The number of invocations Enabled Check Salesforce Trust for maintenance
InvokeTelephonyIntegrationApiFunction of this Lambda function that or Service Cloud Voice service
Errors resulted in a function error. disruption. Contact the Salesforce
Function errors include support team.
exceptions thrown by your
code and exceptions thrown
by the Lambda runtime.
Criteria: Errors >= 3 for 1
data point within 1 minute.
Throttle SCV Lambda The number of invocation Disabled Increase the concurrency limit for the
InvokeTelephonyIntegrationApiFunction requests of this Lambda Lambda function. Check for guidance
Throttles function that are throttled. with Amazon customer support.
Review concurrent
executions quota for the
region, or the reserved
concurrency limit that you
configured on the function.
Criteria: Errors >= 5 for 1
data point within 1 minute.
Errors SCV Lambda The number of invocations Disabled Check Salesforce Trust for maintenance
InvokeSalesforceRestApiFunction of this Lambda function that or Service Cloud Voice service
Errors resulted in a function error. disruption. Contact the Salesforce
Function errors include support team.
exceptions thrown by your
code and exceptions thrown
by the Lambda runtime.
Criteria: Errors >= 3 for 1
data point within 1 minute.
Throttle SCV Lambda The number of invocation Disabled Increase the concurrency limit for the
InvokeSalesforceRestApiFunction requests of this Lambda Lambda function. Check for guidance
Throttles function that are throttled. with Amazon customer support.
Review concurrent
executions quota for the
region, or the reserved
147
Service Cloud Voice Customer Alerts with CloudWatch Customer Alerts Alarms
Errors SCV Lambda The number of invocations Enabled Check Salesforce Trust for maintenance
HandleContactEvents of this Lambda function that or Service Cloud Voice service
Errors resulted in a function error. disruption. Contact the Salesforce
Function errors include support team.
exceptions thrown by your
code and exceptions thrown
by the Lambda runtime.
Criteria: Errors >= 3 for 1
data point within 1 minute.
Throttle SCV Lambda The number of invocation Disabled Increase the concurrency limit for the
HandleContactEvents requests of this Lambda Lambda function. Check for guidance
Throttles function that are throttled. with Amazon customer support.
Review concurrent
executions quota for the
region, or the reserved
concurrency limit that you
configured on the function.
Criteria: Errors >= 5 for 1
data point within 1 minute.
Errors SCV Lambda The number of invocations Enabled Check Salesforce Trust for maintenance
CTRDataSyncFunction of this Lambda function that or Service Cloud Voice service
Errors resulted in a function error. disruption. Contact the Salesforce
Function errors include support team.
exceptions thrown by your
code and exceptions thrown
by the Lambda runtime.
Criteria: Errors >= 3 for 1
data point within 1 minute.
Throttle SCV Lambda The number of invocation Disabled Customer should increase the
CTRDataSyncFunction requests of this Lambda concurrency limit for the Lambda
Throttles function that are throttled. function. Check for guidance with
Review concurrent Amazon customer support.
executions quota for the
region, or the reserved
148
Service Cloud Voice Customer Alerts with CloudWatch Customer Alerts Alarms
Errors SCV Lambda The number of invocations Disabled Check Salesforce Trust for maintenance
kvsConsumerTrigger of this Lambda function that or Service Cloud Voice service
Errors resulted in a function error. disruption. Contact the Salesforce
Function errors include support team.
exceptions thrown by your
code and exceptions thrown
by the Lambda runtime.
Criteria: Errors >= 3 for 1
data point within 1 minute.
Throttle SCV Lambda The number of invocation Disabled Increase the concurrency limit for the
kvsConsumerTrigger requests of this Lambda Lambda function. Check for guidance
Throttles function that are throttled. with Amazon customer support.
Review concurrent
executions quota for the
region, or the reserved
concurrency limit that you
configured on the function.
Criteria: Errors >= 5 for 1
data point within 1 minute.
Errors SCV Lambda The number of invocations Disabled Check Salesforce Trust for maintenance
kvsTranscriber Errors of this Lambda function that or Service Cloud Voice service
resulted in a function error. disruption. Contact the Salesforce
Function errors include support team.
exceptions thrown by your
code and exceptions thrown
by the Lambda runtime.
Criteria: Errors >= 3 for 1
data point within 1 minute.
149
Service Cloud Voice Customer Alerts with CloudWatch Customer Alerts Dashboards
SEE ALSO:
Amazon CloudWatch User Guide: Using Amazon CloudWatch alarms
Customer Alerts Dashboards
Customer Alerts Platform Event
150
Service Cloud Voice Customer Alerts with CloudWatch Customer Alerts Platform Event
To learn what each of the metrics means, see Monitoring your instance using CloudWatch in the Amazon Connection Administrative
Guide.
This dashboard tracks invocations, concurrent executions, and errors associated with each Lambda function.
SEE ALSO:
Amazon CloudWatch User Guide: Using Amazon CloudWatch dashboards
Amazon Connect Administrator's Guide: Monitoring your instance using CloudWatch
151
Service Cloud Voice Customer Alerts with CloudWatch Customer Alerts Platform Event
To learn more about this platform event and to view some sample code, see RealtimeAlertEvent in the Platform Events Developer Guide.
SEE ALSO:
Platform Events Developer Guide: RealtimeAlertEvent
Customer Alerts Alarms
152
CHAPTER 9 Service Cloud Voice Limits and Scaling
In this chapter ... Service Cloud Voice runs in a multitenant environment and uses both Salesforce resources and Amazon
Connect resources to provide a native Salesforce telephony solution.
• Service Cloud Voice
Limits per Salesforce
To ensure quality for all Voice users, Voice enforces the following limits on calls and transcription.
Org
• Service Cloud Voice SEE ALSO:
Best Practices for Amazon Connect
Error Handling
153
Service Cloud Voice Limits and Scaling Service Cloud Voice Limits per Salesforce Org
Conversations per second Maximum number of voice calls 50 calls initiated per second • Includes all types of calls (for
created per second. per org example, inbound, outbound,
transfer, callback).
• After the limit is reached,
transcriptions won’t work for
additional calls in that
second.
Utterances per second Maximum number of utterances 5,000 utterances per second • This limitation may result in
that can be transcribed within per org some voice calls sporadically
each second interval. The length missing transcriptions within
of an utterance is variable, a call. For example, suppose
depending on when pauses that there are 1,401
occur within a spoken concurrent conversations. If
conversation. every conversation generates
an utterance exactly at the
same time, then one call
won’t have a transcription.
154
Service Cloud Voice Limits and Scaling Monitor Transcription-Related Limit Errors
Important: If you change the name of the custom field to a different value than
sf_realtime_transcription_status__c, you must manually modify both kvsTranscriber and CTRDataSync Lambda
functions to accept the new name.
155
Service Cloud Voice Limits and Scaling Monitor VoiceCall Limit Errors
3. From within the contact flow, the Lambda errors out, so as part of the error branch of the Lambda block, place a check contact
attribute block and verify if the attribute is TRUE. If so, you can put a loop block in the contact flow and play a prompt before trying
to create a VoiceCall record. Track of the number of retries using another contact attribute. You can put a limit on the number of
times the system tries to create the VoiceCall record. To learn more about contact attributes, see the Amazon Connect Administrator
Guide on checking contact attributes.
156
Service Cloud Voice Limits and Scaling Monitor VoiceCall Limit Errors
This approach uses a fallback mechanism when the per second limit is hit.
OPTION 2: See the number of failed calls
This approach shows you how many calls failed because of the limit error.
1. Write the error to a contact attribute such as Voice_Call_Creation_Status.
2. To identify how many calls failed as a result of the limit error, do a contact search using the contact attribute. Use a filter to search
based on contract attributes. Update the Lambda function to check a condition on the contact attribute.
157