Newer Version Available

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

Service Cloud Voice LWC Toolkit API 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.

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) Timestamp for when the client sent this content.
  • serverReceivedTimestamp (number) Timestamp for when the server received this content.
  • content (object) Information about the content.
  • content.formatType (string) Content format type. For example, “Text.”
  • content.text (string) Content text.
  • callId (string) Unique call identifier value.
  • sender (object) Information about the sender.
  • sender.role (string) Role of the sender. For example, “Agent”.

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}

Payloads may contain other system-generated information.