VoiceTranscriptObject - Scoped
The VoiceTranscriptObject scriptable API provides methods to save third-party voice conversation transcript data to a table within a ServiceNow instance.
When calling the VoiceTranscriptObject class, use the sn_cs namespace identifier.
Agent Workspace page with customer details and conversations displayed.
Availability
This API is available in the base ServiceNow system. Access is restricted by the ACLs imposed on the Interaction [interaction] and Conversation [sys_cs_conversation] tables.
Parent Topic:Server API reference
VoiceTranscriptObject - addVoiceInteractionMessage(String interactionId, String Json)
Adds the specified messages to the specified voice transaction record.
You can call this endpoint multiple times during real-time transcribing of the call or pass all messages in a single call if you are transcribing the call for historical purposes. If you are processing a real-time conversation, you should call this endpoint frequently, so that the messages appear in Agent Workspace in a timely manner. Messages are ordered based on their start and end times in relation to the start of the call.
| Name | Type | Description |
|---|---|---|
| interactionId | String | Sys\_id of the interaction record to add the specified messages to. This value is returned by the VoiceTranscriptObject - startVoiceInteraction(String Json) method.Table: Interaction \[interaction\] |
| <json\_string> | String \(Array of Objects\) | List of messages to attach to the specified voice interaction. |
| <json\_string>.attributes | Array of Objects | Key-value pairs to associate to the voice interaction. These can be any type of data object, from simple objects to complex compound objects. They are used as unique identifiers when invoking Amazon Web Services APIs. Default: None |
| <json\_string>.beginOffsetMillis | Long | Required. Time offset between the start of the voice interaction and the start of the associated message. For example: "beginOffsetMillis": 2650. Unit: Milliseconds |
| <json\_string>.content | String | Required. Text of the message to add to the voice interaction. |
| <json\_string>.endOffsetMillis | Long | Required. Time offset between the start of the voice interaction and the end of the message. For example: "endOffsetMillis": 9380. Unit: Milliseconds |
| <json\_string>.id | String | Message UUID of the source of this voice conversation, such as for AmazonConnect. Sets the source message ID column value. Default: None |
| <json\_string>.isEvent | Boolean | Set by Amazon Connect but not currently used by the method. Flag that indicates whether the associated message is an event. Valid values: - true: Message is an event. - false: Message is not an event. Default: false |
| <json\_string>.isInternalMessage | Boolean | Flag that indicates whether this is an internal message and shouldn't be shown to the caller. Transcriptions are typically considered internal messages and only appear for the agent and not to the caller. In addition, Agent Whisper is used when a silent third-party is chatting with or is brought into a phone conversation without the caller knowing and offers advice to an agent. The caller doesn't hear or see these messages, but the agent does. Valid values: - true: Internal message, don't display to the caller. - false: Not an internal message, display to caller. Default: false |
| <json\_string>.loudnessScore | Number | Measurement as to how loudly a customer or agent is speaking during a call. Contact Lens displays an analysis of the conversation that shows where they may be talking loudly and have a negative sentiment. Default: Null |
| <json\_string>.participantId | String | Required. Participant associated with the message. Valid values: - AGENT - CUSTOMER |
| <json\_string>.sentiment | String | Sentiment of the message. This value is generated by a third-party provider. Based on the ServiceNow instance configuration settings, this value is then translated to be either positive, negative, or neutral and is stored in the conversation and interaction record. Valid values: - NEGATIVE - NEUTRAL - POSITIVE Default: Null |
| Type | Description |
|---|---|
| String | Message that describes the results of the call. |
| String | If successful, sys\_id of the voice interaction message record that was created. If an error occurred, an error message describing the reason for the failure. Table: Voice Transcript Conversation Message \[sys\_cs\_message\_voice\_transcript\] |
The following example shows how to add messages to an existing voice interaction record.
var request = [
{
"isEvent":"False",
"isInternalMessage":"False",
"beginOffsetMillis":100000,
"content":"This is John. How can I help you?",
"endOffsetMillis":150000,
"id":"954c4edc-31a8-48b0-8f6e-7fa0c4ca00a8",
"participantId":"AGENT",
"sentiment":"NEUTRAL"
},
{
"isEvent":"False",
"isInternalMessage":"False",
"beginOffsetMillis":200000,
"content":"Uh, yes, John. Um, I'm a little very frustrated right now.",
"endOffsetMillis":25000,
"id":"18bcf19c-4a9b-4af1-9bd7-7bfb5ba53b9f",
"participantId":"CUSTOMER",
"sentiment":"NEGATIVE"
}
];
gs.log(sn_cs.VoiceTranscriptObject.addVoiceInteractionMessage("1f4ed6fdb7471110b6e8bc15ae11a971", JSON.stringify(request)));
Output:
// Success
Voice conversation transcript has been successfully saved. Conversation id: ea01113cb7f71110b6e8bc15ae11a94d
// Error
Exception occurred while adding the message: <error message>
VoiceTranscriptObject - createConversation(String interactionId, String Json)
Creates a conversation record within the Conversation [sys_cs_conversation] table for the specified interaction.
| Name | Type | Description |
|---|---|---|
| interactionId | String | Sys\_id of the interaction record for which to create a conversation record. This value is returned by the VoiceTranscriptObject - startVoiceInteraction(String Json) method and stored in the Interaction \[interaction\] table. |
| <json\_string> | String | JSON string of the input parameters. |
| <json\_string>.agentId | String | Unique identifier of the agent to assign the voice interaction to. Default: None. Assigned to the next available agent. Table: In the User ID field of the User \[sys\_user\] table. |
| <json\_string>.callerPhoneNumber | String | Caller's callback phone number. This is the number the agent uses to reach the caller in case the call drops. Format: E.164 standard compliant Default: None |
| <json\_string>.clientSessionId | String | Unique identifier of a record in an external system used to track this phone call. This information links the records between the two systems. Default: None |
| <json\_string>.inboundId | String | Unique identifier of the application provider for the voice service. Default: Pull from chat Table: In the Inbound ID field of the Provider Channel Application \[sys\_cs\_provider\_application\] table. |
| <json\_string>.userId | String | Required. Phone number of the caller who made the call associated with the voice transaction.Format: Defined by the software that created the voice conversation script. Typically E.164 standard compliant. |
| Type | Description |
|---|---|
| String | If successful, returns the sys\_id of the newly created conversation record. If an error occurs, returns a detailed error message.Table: Conversation \[sys\_cs\_conversation\] |
The following code example shows how to create a new conversation record using this method.
var request = {
"userId": "+14089178877"
};
var response = sn_cs.VoiceTranscriptObject.createConversation("e0fc03d7b7a21110b6e8bc15ae11a96c", JSON.stringify(request));
gs.log("Conversation id: " + JSON.stringify(response));
Output:
// Success
{"conversationId":"28435dbcb7f71110b6e8bc15ae11a972","status":"SUCCESS"}
// Error
{"error":"Exception occurred while creating a conversation: <error message>","status":"FAILED"}
VoiceTranscriptObject - endVoiceInteraction(String interactionId, String Json)
Terminates the specified voice interaction. Once called, no additional voice messages are translated and stored for the phone conversation.
| Name | Type | Description |
|---|---|---|
| interactionId | String | Sys\_id of the interaction record whose voice interaction to terminate. Located in the Interaction \[interaction\] table. |
| <json\_string> | JSON String | Optional. Parameters that contain additional information about the voice interactions. |
| <json\_string>.recordingURL | String | Optional. URL where the original voice recording is located.If configured to do so, this URL appears in Agent Workspace. Default: None |
| Type | Description |
|---|---|
| String | If successful, returns Success. If an error occurs, returns a detailed error message. |
The following code example shows how to end an active voice interaction and pass in the original voice recording URL.
var request = {
"recordingURL": "https://servicenow.zoom.us/rec/QbF7XmPFHPlX1LG"
};
gs.log(sn_cs.VoiceTranscriptObject.endVoiceInteraction("1f4ed6fdb7471110b6e8bc15ae11a971", JSON.stringify(request)));
Output:
// Success
Success
// Error
Exception occurred while ending the interaction: <error message>
VoiceTranscriptObject - saveVoiceConversationTranscript(String voiceConversationJson)
Saves third-party voice conversation transcript data to tables within a ServiceNow instance that is then accessible through Customer Service Management (CSM).
These voice conversations are typically generated using third-party vendor software. This method parses the passed JSON and saves the data into the Conversation [sys_cs_conversation], Conversation Message [sys_cs_message], and Voice Transcript Conversation Message [sys_cs_message_voice_transcript] tables within the ServiceNow instance. CSM accesses the information in these tables to display the voice conversation transcripts.
| Name | Type | Description |
|---|---|---|
| voiceConversationJson | String | JSON that represents the voice conversation to store. This JSON is sent by another ServiceNow plugin, such as OpenFrame. Third-party vendors, such as Amazon, send the JSON to the plugin. The associated plugin parses out the voice conversation and sends the JSON in the required format to Virtual Agent.For example, the following is an example of an Amazon Connect conversation: ``` { "interactionId":"bgr09b5a-7308-47b2-jy97-737de9f45d19", "source":"AmazonConnect", "conversationStarted":"2021-08-06 15:07:51", "transcript":[ { "isEvent":"False", "isInternalMessage":"False", "beginOffsetMillis":2650, "content":"This is John. How can I help you? Yeah,", "endOffsetMillis":9380, "id":"954c4edc-31a8-48b0-8f6e-7fa0c4ca00a8", "participantId":"AGENT", "Sentiment":"NEUTRAL", "loudnessScore":"null,null", "attributes": [{ "key":"key1", "value":"value1" },{ "key":"key2", "value":"value2" }] }, { "isEvent":"False", "isInternalMessage":"False", "beginOffsetMillis":9120, "content":"Uh, yes, John. I'm a little very frustrated right now.", "endOffsetMillis":22900, "id":"18bcf19c-4a9b-4af1-9bd7-7bfb5ba53b9f", "participantId":"CUSTOMER", "sentiment":"NEGATIVE", "loudnessScore":"null,null", "attributes": [{ "key":"key1", "value":"value1" },{ "key":"key2", "value":"value2" } ] }, { "isEvent":"True", "isInternalMessage":"True", "beginOffsetMillis":23590, "content":"Agent asked for help in chat", "endOffsetMillis":30610, "id":"ab09b3b6-23fd-4e41-be05-6b2b53c19059", "participantId":"CUSTOMER", "sentiment":"NEUTRAL", "loudnessScore":"null,null,null,null", "attributes": [] } ] } |