lightning:conversationNewMessage
Event triggered when the customer sends a
new message. This event is also triggered when using Enhanced Messaging channels. To
work with Enhanced Messaging channels, the session must be active and the Enhanced
Conversation Component must be visible on the page.
Response
Name | Type | Description |
---|---|---|
recordId | String | The ID of the work record that’s associated with the current chat. |
content | String | The text sent by the customer. |
name | String | The name of the user who sent the message. This name matches the username displayed in the chat log. |
type | String | The type of message that was received, such as an Agent or Visitor message. |
timestamp | Date/Time | The date and time the message was received. |
Example
Component code:
<aura:component implements="flexipage:availableForAllPageTypes" access="global" description="Conversation toolkit api sample">
<lightning:conversationToolkitAPI aura:id="conversationKit" />
<aura:handler event="lightning:conversationNewMessage" action="{!c.onNewMessage}" />
</aura:component>
Controller code:
({
onNewMessage: function(cmp, evt, helper) {
var recordId = evt.getParam('recordId');
var content = evt.getParam('content');
var name = evt.getParam('name');
var type = evt.getParam('type');
var timestamp = evt.getParam('timestamp');
console.log("recordId:" + recordId + " content:" + content + " name:" + name + " timestamp:" + timestamp);
}
})