Newer Version Available

This content describes an older version of this product. View Latest

Service Cloud Voice LWC Toolkit API Telephony Events

Make your LWC components context-aware by listening to events that take place during phone calls.

The following events are available.

Event Name Description
callstarted Sent when the call starts.
callconnected Sent when the call connects.
callended Sent when the call ends.
hold Sent when the call is put on hold.
resume Sent when the call resumes after hold.
mute Sent when the call is muted.
unmute Sent when the call is unmuted.
participantadded Sent when a participant is added to the call.
participantremoved Sent when a participant is removed from the call.
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.
pauserecording Sent when the agent pauses call recording.
resumerecording Sent when the agent resumes call recording.
transcript Sent when a new utterance is received by the transcription system.
wrapupended Sent when the agent exits after call work status.
flagraise Sent when an agent, while communicating with a customer, quietly raises a flag to get help from a supervisor.
flaglower 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.

To subscribe to these events, add an event listener for each event you want to listen to.

1// Subscribe
2const toolkitApi = this.template.querySelector('lightning-service-cloud-voice-toolkit-api');
3toolkitApi.addEventListener('callstarted', <listener>);
4
5// Unsubscribe
6const toolkitApi = this.template.querySelector('lightning-service-cloud-voice-toolkit-api');
7toolkitApi.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.

1{
2  "type": "callstarted",
3  "detail": {
4    "callId": "d7a9f1b7-fc17-43fe-8ca7-e584a2b34792",
5    "callType": "outbound",
6    "participant": "+1 (415) 999-0000"
7  }
8}

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.

Event Name Payload “detail” Properties
callstarted
  • callId (string): Unique call identifier value
  • callType (string): "inbound" or "outbound"
  • participant (string): the phone number
callconnected
  • callId (string): Unique call identifier value
  • callType (string): "inbound" or "outbound"
  • participant (string): the phone number
callended
  • callId (string): Unique call identifier value
hold
  • callId (string): Unique call identifier value
  • participant (string): the phone number or Amazon Quick Connect name

resume
  • callId (string): Unique call identifier value
  • participant (string): the phone number or Amazon Quick Connect name

mute
  • callId (string): Unique call identifier value
unmute
  • callId (string): Unique call identifier value
participantadded
  • callId (string): Unique call identifier value
  • participant (string): the phone number or Amazon Quick Connect name

participantremoved
  • callId (string): Unique call identifier value
  • participant (string): the phone number or Amazon Quick Connect name
conference
  • callId (string): Unique call identifier value
swap
  • callId (string): Unique call identifier value
pauserecording
  • callId (string): Unique call identifier value
resumerecording
  • callId (string): Unique call identifier value
wrapupended
  • callId (string): Unique call identifier value
transcript
  • id (string): Unique identifier for the message.
  • clientSentTimestamp (number): The date and time (in UTC) when the client sent the content. Measured in milliseconds since the Unix epoch.
  • serverReceivedTimestamp (number): The date and time (in UTC) when the server received the content. Measured in milliseconds since the Unix epoch.
  • content (object): Information about the content.
  • content.formatType (string): Content format type of the transcript. Possible value is “Text.”
  • content.text (string) The body text of the transcript.
  • callId (string): 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".

For example:

1{
2    "type": "transcript",
3    "detail": {
4        "id": "3115b389-ab50-400e-b8ba-978b7ec51d7a"
5        "clientSentTimestamp": 1594944652299,
6        "serverReceivedTimestamp": 1594944652328,
7        "content":{
8            "formatType": "Text",
9            "text": "Hello"
10        },
11        "callId": "c5d93c19-e03b-44f8-85e6-a11f02e70c45",
12        "sender": {
13            "role": "Agent"
14        }
15    }
16}
flagraise
  • id (string): Unique call identifier value
  • clientSentTimestamp (number): The date and time (in UTC) when the client sent the content. Measured in milliseconds since the Unix epoch.
  • serverReceivedTimestamp (number): The date and time (in UTC) when the server received the content. Measured in milliseconds since the Unix epoch.
  • content (object): Information about the content
  • content.formatType (string): The content format type of the raised flag. Possible value is “Text.”
  • content.text (string) The body text of the raised flag
  • callId (string): 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

For example:

1{
2    "type": "flagraise",
3    "detail": {
4        "id": "3115b389-ab50-400e-b8ba-978b7ec51d7a"
5        "clientSentTimestamp": 1594944652299,
6        "serverReceivedTimestamp": 1594944652328,
7        "content":{
8            "formatType": "Text",
9            "text": "The customer wants a credit note."
10        },
11        "callId": "c5d93c19-e03b-44f8-85e6-a11f02e70c45",
12        "sender": {
13            "role": "Agent",
14            "displayName": "Angela Agent"
15        }
16    }
flaglower
  • id (string): Unique call identifier value
  • clientSentTimestamp (number): The date and time (in UTC) when the client sent the content. Measured in milliseconds since the Unix epoch.
  • serverReceivedTimestamp (number): The date and time (in UTC) when the server received the content. Measured in milliseconds since the Unix epoch.
  • content (object): Information about the content.
  • content.formatType (string): This value is NULL because it doesn't apply to the flaglower event.
  • content.text (string) This value is NULL because it doesn't apply to the flaglower event.
  • callId (string): 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.

For example:

1{
2    "type": "flaglower",
3    "detail": {
4        "id": "3115b389-ab50-400e-b8ba-978b7ec51d7a"
5        "clientSentTimestamp": 1594944652299,
6        "serverReceivedTimestamp": 1594944652328,
7        "content":{
8            "formatType": NULL,
9            "text": NULL
10        },
11        "callId": "c5d93c19-e03b-44f8-85e6-a11f02e70c45",
12        "sender": {
13            "role": "Supervisor",
14            "displayName": "Samir Supervisor"
15        }
16    }
note
  • id (string): Unique call identifier value
  • clientSentTimestamp (number): The date and time (in UTC) when the client sent the content. Measured in milliseconds since the Unix epoch.
  • serverReceivedTimestamp (number): The date and time (in UTC) when the server received the content. Measured in milliseconds since the Unix epoch.
  • content (object): Information about the content.
  • content.formatType (string): Content format type of the note. Possible value is “Text.”
  • content.text (string) The body text of the note.
  • callId (string): 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.

For example:

1{
2    "type": "note",
3    "detail": {
4        "id": "3115b389-ab50-400e-b8ba-978b7ec51d7a"
5        "clientSentTimestamp": 1594944652299,
6        "serverReceivedTimestamp": 1594944652328,
7        "content":{
8            "formatType": "Text",
9            "text": "The customer wants a refund or store credit."
10        },
11        "callId": "c5d93c19-e03b-44f8-85e6-a11f02e70c45",
12        "sender": {
13            "role": "Agent",
14            "displayName": "Angela Agent"
15    }
16}

Payloads may contain other system-generated information.