Skip to content

Latest commit

 

History

History
190 lines (131 loc) · 2.87 KB

File metadata and controls

190 lines (131 loc) · 2.87 KB
title description ms.date ms.topic author ms.author ms.reviewer ms.custom
lcw:onMessageReceived
lcw onMessageReceived event (Omnichannel for Customer Service JavaScript API reference).
05/15/2024
conceptual
gandhamm
mgandham
nenellim
bap-template

lcw:onMessageReceived event (Omnichannel for Customer Service JavaScript API reference)

[!INCLUDEcc-use-with-omnichannel]

The lcw:onMessageReceived event is triggered when the chat widget gets a new message. You can use this event to create custom experiences for the user. For example, play a sound notification or update the page title to catch the user eye for the new message.

Users such as an agent in Dynamics 365 can send the message or the system can send an automated message. So, the possible values for messageType are user and system.

This event contains data in the payload to explain the source of the message.

Sample payload

Agent assigned

{ 

"channelData": { 

"tags": [
    "system",
    "agentassignmentready"
],

},
"messageType": "system"

} 

Agent accepted

{ 

"channelData": { 

"tags": [
    "system",
    "agentaccepted"
],

},
"messageType": "system"

} 

Agent sent a message

{ 

"channelData": { 

"tags": [
    "public",
    "client_activity_id:1612311164266bkaspzvq05b"
],

},
"messageType": "user"

} 

Agent ended the conversation

{ 

"channelData": { 

"tags": [
    "system",
    "agentendconversation"
],

},
"messageType": "system"

} 

Agent ended the session

{ 

"channelData": { 

"tags": [
    "system",
    "primarysessionclosed"
],

},
"messageType": "system"

} 

Agent assignment accepted

{ 

"channelData": { 

"tags": [
    "system",
    "agentaccepted"
],

},
"messageType": "system"

} 

Agent assignment failed

{ 

"channelData": { 

"tags": [
    "system",
    "agentassignmentfailure"
],

},
"messageType": "system"

} 

Queue position

{ 

"channelData": { 

"tags": [
    "system",
    "queueposition",
    "customerqueuepositionnext"
],

},
"messageType": "system"

} 

Example

window.addEventListener("lcw:onMessageReceived", function handleWidgetMessageReceivedEvent(payload){ // Handle the live chat widget message sent event });

See also

lcw:ready
lcw:error
lcw:chatRetrieved
lcw:chatQueued
lcw:onClose
lcw:closeChat
lcw:startChat
lcw:onMinimize
lcw:onMaximize
lcw:onMessageSent
lcw:threadUpdate
Live chat SDK JavaScript API reference

[!INCLUDEfooter-include]