# List messages — Sendbird

> Retrieves a list of past messages of a specific channel. See the docs here

- Key: `sendbird-list-messages`
- Type: Action (Read-only)
- Version: 0.0.2
- App: Sendbird (`sendbird`) — https://pipedream.com/apps/sendbird.md
- This page (HTML): https://pipedream.com/apps/sendbird/actions/list-messages
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/sendbird/actions/list-messages/list-messages.mjs

## Description

Retrieves a list of past messages of a specific channel. [See the docs here](https://sendbird.com/docs/chat/v3/platform-api/message/messaging-basics/list-messages)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `applicationId` | `string` | Yes | Specifies the unique ID of the Application. To find the application ID, sign in to Sendbird Dashboard, go to Settings > Application > General, and then check Application ID. |
| `channelType` | `string` | Yes | Specifies the type of the channel. Acceptable values are open_channels and group_channels. |
| `channelUrl` | `string` | Yes | Specifies the url of the channel. Options are loaded from the connected account. |
| `messageTs` | `integer` | No | Specifies the timestamp to be the reference point of the query in Unix milliseconds. Either this or the Message Id should be specified. |
| `messageId` | `integer` | No | Specifies the unique ID of the message to be the reference point of the query. Either this or the Message Timestamp should be specified. |
| `prevLimit` | `integer` | No | Specifies the number of previously sent messages to retrieve before message_ts. For example, if message_ts=1484202848298, then prev_limit=50 returns 50 messages sent by 1484202848297 (message_ts - 1). |
| `nextLimit` | `integer` | No | Specifies the number of sent messages to retrieve after message_ts. For example, if message_ts=1484202848298, then next_limit=50 returns 50 messages sent from 1484202848299 (message_ts + 1). |
| `include` | `boolean` | No | Determines whether to include messages sent exactly on the specified message_ts in the results. (Default: true) |
| `reverse` | `boolean` | No | Determines whether to sort the results in reverse chronological order. If set to true, messages appear in reverse chronological order where the newest comes first and the oldest last. (Default: false) |
| `senderIds` | `string[]` | No | Restricts the search scope to only retrieve messages sent by one or more users. Options are loaded from the connected account. |
| `operatorFilter` | `string` | No | Restricts the search scope to only retrieve messages sent by operators or non-operator users of the channel. |
| `messageType` | `string` | No | Specifies a message type to retrieve. If not specified, all messages are retrieved. |
| `includingRemoved` | `boolean` | No | Determines whether to include messages removed from the channel in the results. |
| `withSortedMetaArray` | `boolean` | No | Determines whether to include the sorted_metaarray property in the response. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "sendbird",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "sendbird-list-messages",
  arguments: {
    applicationId: "Application Id",
    channelType: "Channel Type",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "sendbird-list-messages",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    sendbird: { authProvisionId: "apn_xxxxxxx" },
    applicationId: "Application Id",
    channelType: "Channel Type",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "sendbird-list-messages",
    "configured_props": {
      "sendbird": { "authProvisionId": "apn_xxxxxxx" },
      "applicationId": "Application Id",
      "channelType": "Channel Type"
    }
  }'
```

---

- App: https://pipedream.com/apps/sendbird.md · All apps: https://pipedream.com/apps
