lightning:conversationNewMessage

Messaging event triggered when the customer sends a new message. In Enhanced Messaging channels, this event is triggered only for text messages. This event is not triggered for messages with files or rich content. To work with Enhanced Messaging channels, the session must be active and the Enhanced Conversation Component must be visible on the page.

Response 

NameTypeDescription
recordIdStringThe ID of the work record that’s associated with the current conversation.
contentStringThe message sent by the customer.
nameStringThe name of the user who sent the message. This name matches the username displayed in the conversation log.
typeStringThe type of message that was received, such as an Agent or Visitor message.
timestampDate/TimeThe date and time the message was received.

Example 

Component code:

1<aura:component implements="flexipage:availableForAllPageTypes" access="global" description="Conversation toolkit api sample">
2  <lightning:conversationToolkitAPI aura:id="conversationKit" />
3  <aura:handler event="lightning:conversationNewMessage" action="{!c.onNewMessage}" />
4</aura:component>

Controller code:

1({
2    onNewMessage: function(cmp, evt, helper) {
3        var recordId = evt.getParam('recordId');
4        var content = evt.getParam('content');
5        var name = evt.getParam('name');
6        var type = evt.getParam('type');
7        var timestamp = evt.getParam('timestamp');
8
9        console.log("recordId:" + recordId + " content:" + content + " name:" + name + " timestamp:" + timestamp);
10    }
11})