
Connect API can be used to fetch the Conversation Entries for Salesforce Enhanced Channels.
Since there is a data storage differences, the Conversation Entries for enhanced channels and Messaging for In-App and Web are accessible only via the Salesforce Connect API.
For Standard Channels, you can directly query the Conversation Entries.
Developer Article:
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

By default, we will get only 25 entries. To get more than 25, use recordLimit parameter. Maximum value for the recordLimit is 1000.
You can also use the following Salesforce SOQL. But, the message text will not be available. In order to get the Message information, use the Connect API.
SELECT Id, ActorId, ActorName,
ActorType, EntryType, Message,
MessageSendTime, MessageReadTime,
MessageStatus, MessageStatusCode,
CreatedDate, ClientDuration,
ClientTimestamp, EntryTime
FROM ConversationEntry
WHERE ConversationId = '<ConversationId>'