Newer Version Available
Customize Synced CTR Fields Using CTRDataSyncFunction
Although the provided CTRDataSyncFunction Lambda automatically syncs
many of the fields between Amazon’s contact trace record (CTR) and a VoiceCall record,
you can customize this function to sync additional fields.
The CTRDataSyncFunction Lambda documentation lists all the fields that are automatically synced with a VoiceCall record. Use these instructions to sync more fields.
- In your Salesforce org, create a custom field on the VoiceCall object for the desired attribute in the CTR data model.
-
In Amazon Connect, select the CTRDataSyncFunction Lambda function. From the menu select so that you can get access to the function source code. If you
already have the source code for this function, you don’t need to perform this
step.

-
In the utils.js file for the CTRDataSyncFunction
Lambda, update the getCallAttributes function so that it syncs the
desired attribute with the desired custom field.
The following example adds a few lines of code to sync the AgentConnectionAttempts attribute with an AgentConnectionAttempts__c custom field. Use this example as a template for further customizations.
1function getCallAttributes(rawCallAttributes) { 2 const prefix = 'sfdc-'; 3 const prefixLen = prefix.length; 4 let callAttributes = {}; 5 6 for (const key in rawCallAttributes) { 7 if (rawCallAttributes.hasOwnProperty(key) && key.startsWith(prefix)) { 8 callAttributes[key.substring(prefixLen)] = rawCallAttributes[key]; 9 } 10 // Set SCV Limits Error if the specific contact attribute is set 11 if (rawCallAttributes.sf_realtime_transcription_status) { 12 callAttributes.sf_realtime_transcription_status = 13 rawCallAttributes.sf_realtime_transcription_status; 14 } 15 } 16 17 // *** START OF CUSTOM CODE *** 18 // Custom code to sync a CTR attribute with a custom field 19 if (rawCtr.AgentConnectionAttempts) { 20 callAttributes.AgentConnectionAttempts__c = rawCtr.AgentConnectionAttempts; 21 } 22 // *** END OF CUSTOM CODE *** 23 24 return JSON.stringify(callAttributes); 25} -
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.
In subsequent calls, the new data should be synced.