Επεξεργασία

Κοινή χρήση μέσω


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

Omnichannel for Customer Service offers a suite of capabilities that extend the power of Dynamics 365 Customer Service Enterprise to enable organizations to instantly connect and engage with their customers across digital messaging channels. An additional license is required to access Omnichannel for Customer Service. For more information, see the Dynamics 365 Customer Service pricing overview and Dynamics 365 Customer Service pricing plan pages.

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 });

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