Fetch Salesforce Conversation Entries using Conversation Data API

Fetch Salesforce Conversation Entries using Conversation Data API

Salesforce Conversation Data API: Easily Fetch Conversation Entries (Step-by-Step Guide)

Introduction

In today’s multi-channel world, accessing and analyzing customer conversation data is critical for improving service quality, training AI models, and gaining deeper customer insights. Salesforce’s Conversation Data API provides a powerful, programmatic way to retrieve detailed conversation entries from various messaging channels.

This step-by-step guide will walk you through setting up the necessary prerequisites and using the API to fetch conversation entries associated with a Messaging Session record in your Salesforce org.


✅ Prerequisites: Setting Up Your Salesforce Org

Before you can make API calls, you need to configure your Salesforce environment for the Conversation Data API.

  1. Enable Conversation Service APIs:
    • Navigate to Setup in your Salesforce org.
    • In the Quick Find box, search for and select “Conversation Service APIs”.
    • Ensure this feature is enabled.
  2. Configure an External Client App (Headless):
    • The Conversation Data API requires an OAuth 2.0 flow to securely authenticate. The recommended method for server-to-server communication is the JWT Bearer flow, which is set up using an External Client App.Follow all the steps detailed in the official Salesforce Developer documentation to configure your External Client App:

Reference:

https://developer.salesforce.com/docs/service/conversation-data-api/guide/get-started-conversation-data-api.html


🔧 Step-by-Step Guide: Fetching Conversation Entries

Once your setup is complete, you can begin the two-part process: first, getting an Access Token and the Conversation Identifier, and then, using those to call the Conversation Data API.

Step 1: Obtain the Access Token

You must first authenticate your application to access Salesforce resources. This example uses the standard OAuth 2.0 Username-Password flow for simplicity, which is common in testing and specific integration scenarios.

  • Request Method: POST
  • Endpoint: https://{Your-Salesforce-Domain}.my.salesforce.com/services/oauth2/token
  • Action: Send a POST request to this endpoint, providing your Consumer Key and Consumer Secret (along with username, password, and grant type) in the request body to receive the Access Token.

The successful response will include your required Access Token.

Step 2: Retrieve the Conversation Identifier

The Conversation Data API operates using a Conversation Identifier, which is a unique ID linking all related data entries. This identifier is stored on the Conversation object, which is referenced by the Messaging Session record.

  • Action: Execute the following SOQL query against your Salesforce org:

SOQL

SELECT Conversation.ConversationIdentifier
FROM MessagingSession
WHERE Id = '<Id Of Messaging Session>'
  • Result: This query will return the ConversationIdentifier associated with the specific Messaging Session you are analyzing.

Step 3: Call the Conversation Data API

With the Access Token and the Conversation Identifier, you are now ready to fetch the conversation entries.

  • Request Method: GET
  • Endpoint: https://api.salesforce.com/platform/engagement/v1.0/conversation-entries
  • Header: Include the Access Token from Step 1 in the Authorization header as a Bearer token.
  • Parameter: Pass the Conversation Identifier from Step 2 as a query parameter:
    • Parameter Name: conversationIdentifier
    • Parameter Value: <The ConversationIdentifier you retrieved>

The full API call will look something like this:

GET https://api.salesforce.com/platform/engagement/v1.0/conversation-entries?conversationIdentifier=fac85e3c-59a4-4592-961b-24ca587da056
Authorization: Bearer <Your Access Token>
  • Result: The API will return a JSON payload containing the sequence of conversation entries (messages, events, etc.) that make up the complete interaction.

Limitations

The API provides transcripts in plain text only and does not support rich media elements such as images or interactive buttons.

https://help.salesforce.com/s/articleView?id=service.access_conv_data_using_conversation_entries.htm&type=5

When we query an individual conversation via API, the API call marks that conversation as active, which counts against your organization’s simultaneous active conversation limit.

Maximum simultaneous active messaging sessions varies based on multiple factors like channel(Standard or Enhanced). Check the following resources for your reference.

https://developer.salesforce.com/docs/service/messaging-object-model/guide/messaging-object-model-access-data.html

https://help.salesforce.com/s/articleView?id=service.livemessage_limitations.htm&type=5


Conclusion

The Salesforce Conversation Data API is an invaluable tool for extracting granular interaction details, enabling powerful analytics and integration capabilities outside the core platform. By following these steps, you can successfully integrate and leverage your valuable customer conversation data.


Reference:

https://developer.salesforce.com/docs/service/conversation-data-api/references/conversation-data-api-reference?meta=getConversationEntries

Leave a Reply