# 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`](/sdks/sync-conversation) or [`nvSyncConversation`](/sdks/nv-sync-conversation) methods.

```typescript
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
from linkedapi import ConversationPollRequest, LinkedApiError

try:
    # Poll multiple conversations for new messages
    result = linkedapi.poll_conversations(
        [
            ConversationPollRequest(
                person_url="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
            ),
            ConversationPollRequest(
                person_url="https://www.linkedin.com/sales/people/ABC123",
                type="nv",  # Sales Navigator conversation
                since="2024-01-15T10:30:00Z",
            ),
            ConversationPollRequest(
                person_url="https://www.linkedin.com/in/jane-smith",
                type="st",
                # No 'since' parameter = retrieve entire conversation history
            ),
        ]
    )
    data = result.data
    errors = result.errors

    # The list of possible execution errors is below
    if errors:
        print("Workflow completed with execution errors:")
        for error in errors:
            print(f" - Type: {error.type}, Message: {error.message}")

    if data:
        print("Successfully retrieved conversations")

        for conversation in data:
            print(f"\nConversation with {conversation.person_url}:")
            print(f"Type: {conversation.type}")
            print(f"Messages: {len(conversation.messages)}")

            for message in conversation.messages:
                sender = "You" if message.sender == "us" else "Them"
                print(f"{sender} ({message.time}): {message.text}")
except LinkedApiError as e:
    # A list of all critical errors can be found here:
    # https://linkedapi.io/sdks/handling-results-and-errors/#handling-critical-errors
    print(f"Critical Error - Type: {e.type}, Message: {e.message}")
except Exception as error:
    print("An unexpected, non-API error occurred:", error)
```

## Params

Pass an array of conversation objects each containing the following:

- `personUrl` – [public or hashed](/faq/what-are-hashed-url-and-public-url) 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` or `nv`).
- `messages` – array of messages.
  - `id` – unique identifier for the message.
  - `threadId` – identifier of the conversation thread. Pass it to [`sendMessage`](/sdks/send-message) / [`nvSendMessage`](/sdks/nv-send-message) to reply into the thread. May be `null` for messages captured before a thread identifier was known.
  - `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](/sdks/sync-conversation) before polling: {conversations_list}.

---

**Recommended flow for integrations:**

If you integrate this method into a frontend application, we recommend the following approach:

1. Leave `since` empty to retrieve the full conversation history.
2. For subsequent requests, pass the **timestamp of the last message** you received as `since` to retrieve only new messages.
3. Continue using `since` to fetch new messages periodically. If new messages are returned, update the `since` 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).
