# Inbox

Receive Slack DMs and bot mentions in the inbox and start a conversation with any workspace member.

import { Tab, Tabs } from 'fumadocs-ui/components/tabs';

Slack supports DMs and channel mentions in the [inbox](/messages/list-inbox-conversations), delivered in realtime through Slack's Events API.

## What Zernio ingests

Zernio ingests:

- DMs to the Zernio bot
- Channel messages that @-mention the bot
- Replies in threads the bot is already part of, including under a post Zernio published
- The bot's own messages
- Emoji reactions added to or removed from a message, as [`reaction.received`](/webhooks/inbox/reaction-received)

Ordinary channel conversation is deliberately not ingested. The inbox is not a mirror of the workspace, so day-to-day chatter in a connected channel is never stored.

## Receive messages

Every incoming message fires the `message.received` event. Its `metadata` carries:

| Field | Meaning |
|-------|---------|
| `threadTs` | Present when the message is a thread reply |
| `mentionsBot` | `true` when the message @-mentions the Zernio bot |

That pair covers the usual agent rule: answer when mentioned in a channel, always answer DMs, and reply inside the thread.

## Reply and react

Reply from the inbox or with [Send inbox message](/messages/send-inbox-message) on `POST /v1/inbox/conversations/{conversationId}/messages`. The message goes out as the bot, and `replyTo` threads the reply.

React to a message with:

```
POST /v1/inbox/conversations/{conversationId}/messages/{messageId}/reactions
```

The emoji has to have a Slack name, such as `:thumbsup:`. An unnamed character returns a `400`.

## Constraints

- No history backfill. The inbox starts at connect time, a Slack restriction for apps not listed in the Marketplace.
- Messages from other bots appear for context but never trigger automations or webhook events (loop guard).
- Attachments appear as links that open in Slack.
- Contacts and the built-in automations (sequences, workflows) are DM-only.

**Contacts.** Someone who DMs the bot becomes a contact. People talking in a connected channel do not; otherwise every colleague in the channel would be added as a contact.

Automate channels with your own agent reacting to `message.received`.

## Start a conversation

You do not have to wait for someone to message the bot first.

Look up a workspace member with [List Slack members](/slack/list-slack-members). Then open the DM by passing their member id as `participantId` to [Create inbox conversation](/messages/create-inbox-conversation):

<Tabs items={['Node.js', 'Python', 'curl']}>
<Tab value="Node.js">
```typescript
const { data: members } = await zernio.slack.listSlackMembers({
  path: { accountId: '66b2e19d8c3f5a7e9d0b1c2d' },
  query: { query: 'maria' }
});

const { data: conversation } = await zernio.messages.createInboxConversation({
  body: {
    accountId: '66b2e19d8c3f5a7e9d0b1c2d',
    participantId: members.members[0].id,
    message: 'Hi Maria, the campaign is live.'
  }
});

console.log(conversation.data.conversationId);
```
</Tab>
<Tab value="Python">
```python
members = client.slack.list_slack_members(
    account_id="66b2e19d8c3f5a7e9d0b1c2d",
    query="maria"
)

conversation = client.messages.create_inbox_conversation(
    account_id="66b2e19d8c3f5a7e9d0b1c2d",
    participant_id=members["members"][0]["id"],
    message="Hi Maria, the campaign is live."
)

print(conversation["data"]["conversationId"])
```
</Tab>
<Tab value="curl">
```bash
curl "https://zernio.com/api/v1/accounts/66b2e19d8c3f5a7e9d0b1c2d/slack-members?query=maria" \
  -H "Authorization: Bearer $ZERNIO_API_KEY"

curl -X POST https://zernio.com/api/v1/inbox/conversations \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "accountId": "66b2e19d8c3f5a7e9d0b1c2d",
    "participantId": "U01ABCDEF",
    "message": "Hi Maria, the campaign is live."
  }'
```
</Tab>
</Tabs>

Response (`200`) from the member lookup:

```json
{
  "members": [
    { "id": "U01ABCDEF", "name": "Maria Lopez", "username": "maria", "picture": "https://..." }
  ]
}
```

Response (`201`) from the conversation call:

```json
{
  "success": true,
  "data": {
    "messageId": "1785320613.863000",
    "conversationId": "66c3d2ae7b4f6c8d0e1f2a3b",
    "participantId": "U01ABCDEF",
    "participantName": "Maria Lopez"
  }
}
```

Slack addresses people by opaque id, never by name.

Bots, deactivated members and Slackbot are left out of the lookup, because they cannot hold a DM conversation.

The DM comes from the workspace's connected bot, so it reaches members of that workspace only. The reply lands in the same conversation.