Direct messages
Initiate DM conversations with users programmatically.
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 youronNewMentionhandler 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:
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:
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
bot.onSubscribedMessage(async (thread, message) => {
if (thread.isDM) {
await thread.post("This is a private conversation.");
}
});