---
title: Direct messages
description: Initiate DM conversations with users programmatically.
type: guide
prerequisites:
  - /docs/usage
---

# Direct messages



Open direct message conversations with users using `bot.openDM()`. The adapter is automatically inferred from the user ID format.

## DM behavior

DMs behave slightly differently from channel messages:

* **Implicit mentions** — DM messages automatically set `isMention=true`, so your `onNewMention` handler fires without the user needing to @-mention the bot. This feels natural for 1:1 conversations.
* **Per-conversation threading** — Each top-level DM starts a new conversation. Thread replies within a DM continue the same conversation, giving you the same per-thread isolation as channels.

## Open a DM

### From an Author object

The most common pattern — use the `author` from an incoming message:

```typescript title="lib/bot.ts" lineNumbers
bot.onSubscribedMessage(async (thread, message) => {
  if (message.text === "DM me") {
    const dmThread = await bot.openDM(message.author);
    await dmThread.post("Hello! This is a private message.");
  }
});
```

### From a user ID

Pass a user ID string directly. The adapter is inferred from the ID format:

```typescript title="lib/bot.ts"
const dmThread = await bot.openDM("U1234567890"); // Slack
```

| Format              | Platform    |
| ------------------- | ----------- |
| `U...`              | Slack       |
| `29:...`            | Teams       |
| `users/...`         | Google Chat |
| Snowflake (numeric) | Discord     |

## Check if a thread is a DM

```typescript title="lib/bot.ts" lineNumbers
bot.onSubscribedMessage(async (thread, message) => {
  if (thread.isDM) {
    await thread.post("This is a private conversation.");
  }
});
```
