How to get Conversation Entries for Salesforce Enhanced Channels?

How to get Conversation Entries for Salesforce Enhanced Channels?

Connect API can be used to fetch the Conversation Entries for Salesforce Enhanced Channels.

1. Use the following SOQL to fetch the ConversationId and the Conversation Identifier of the Messaging Session record.

SELECT Conversation.ConversationIdentifier, 
ConversationId 
FROM MessagingSession 
WHERE Id = '<Id Of Messaging Session>'

Apex Code to find the Conversation Identifier:

MessagingSession objMS = [
    SELECT Conversation.ConversationIdentifier, ConversationId
	FROM MessagingSession
	WHERE Id = '<Id Of Messaging Session>'
];
System.debug(
    'ConversationIdentifier is ' + 
    objMS.Conversation.ConversationIdentifier
);

2. Use the following path with your My Domain URL to fetch the Conversation Entries.

/services/data/v60.0/connect/conversation/<ConversationIdentifier>/entries

You can also use following SOQL. But, the message text will not be available.

SELECT Id, ActorId, ActorName, 
ActorType, EntryType, Message,
MessageSendTime, MessageReadTime, 
MessageStatus, MessageStatusCode,
CreatedDate, ClientDuration, 
ClientTimestamp, EntryTime
FROM ConversationEntry
WHERE ConversationId = '<ConversationId>'

Leave a Reply