pollConversations
This method allows you to poll multiple conversations to retrieve message history and monitor for new messages across both standard and Sales Navigator conversations.
Before polling conversations, you must first sync each conversation using
syncConversation
or nvSyncConversation
methods.
try {
// Poll multiple conversations for new messages
const { data, errors } = await linkedapi.pollConversations([
{
personUrl: "https://www.linkedin.com/in/john-doe",
type: "st", // Standard LinkedIn conversation
since: "2024-01-01T00:00:00Z" // Optional: only get messages since this date
},
{
personUrl: "https://www.linkedin.com/sales/people/ABC123",
type: "nv", // Sales Navigator conversation
since: "2024-01-15T10:30:00Z"
},
{
personUrl: "https://www.linkedin.com/in/jane-smith",
type: "st"
// No 'since' parameter = retrieve entire conversation history
}
]);
// The list of possible execution errors is below
if (errors && errors.length > 0) {
console.warn('Workflow completed with execution errors:');
errors.forEach(error => {
console.warn(` - Type: ${error.type}, Message: ${error.message}`);
});
}
if (data) {
console.log('Successfully retrieved conversations');
data.forEach(conversation => {
console.log(`\nConversation with ${conversation.personUrl}:`);
console.log(`Type: ${conversation.type}`);
console.log(`Messages: ${conversation.messages.length}`);
conversation.messages.forEach(message => {
const sender = message.sender === 'us' ? 'You' : 'Them';
console.log(`${sender} (${message.time}): ${message.text}`);
});
});
}
} catch (e) {
// A list of all critical errors can be found here:
// https://linkedapi.io/sdks/handling-results-and-errors/#handling-critical-errors
if (e instanceof LinkedApiError) {
console.error(`Critical Error - Type: ${e.type}, Message: ${e.message}`);
} else {
console.error('An unexpected, non-API error occurred:', e);
}
}
# Python SDK is coming soon!
#
# You can always use Linked API through HTTP
# https://linkedapi.io/docs/
// Go SDK is coming soon!
//
// You can always use Linked API through HTTP
// https://linkedapi.io/docs/
Params
Pass an array of conversation objects each containing the following:
personUrl
– public or hashed LinkedIn URL of the person whose conversation you want to poll.since
(optional) – timestamp indicating the starting point for retrieving messages. If not provided, the entire conversation history will be returned.type
– enum indicating the conversation type:st
– for standard conversations.nv
– for Sales Navigator conversations.
Data
Array of conversations. Each conversation contains:
personUrl
– LinkedIn URL of the person.since
– timestamp that was used for filtering (if provided).type
– conversation type (st
ornv
).messages
– array of messages.id
– unique identifier for the message.sender
– enum indicating who sent the message. Possible values:us
– message was sent by you.them
– message was sent by the person.
text
– message text.time
– timestamp when the message was sent or received.
Errors
conversationsNotSynced
– conversations must be synced before polling: {conversations_list}.
Recommended flow for integrations:
If you integrate this method into a frontend application, we recommend the following approach:
- Leave
since
empty to retrieve the full conversation history. - For subsequent requests, pass the timestamp of the last message you received as
since
to retrieve only new messages. - Continue using
since
to fetch new messages periodically. If new messages are returned, update thesince
timestamp to the latest message time.
This flow helps keep conversations up to date and allows your app to handle new message events (e.g., display notifications, play sounds, and so on).