Direct Messages
Use bot.openDM() to open a direct message conversation with a user. When the user ID format is unique to one platform, Chat SDK infers the adapter from the ID.
DM behavior
DMs behave slightly differently from channel messages:
- If you register
onDirectMessage, every incoming DM routes there beforeonSubscribedMessage,onNewMention, and pattern handlers. DM-centric flows such as WhatsApp conversations, Telegram DMs, and web chat then run through one handler. - If no
onDirectMessagehandlers are registered, DMs continue through normal routing. Unsubscribed DMs are treated as mentions, so existingonNewMentionbots keep working without the user having to @-mention the bot. - 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.
Handle incoming DMs
Open a DM
From an Author object
The most common pattern is to pass the author from an incoming message:
From a user ID
Pass a user ID string directly. The adapter is inferred from the ID format:
| Format | Platform |
|---|---|
U... / W... | Slack |
29:... | Teams |
users/... | Google Chat |
| Numeric ID | Discord or Telegram |
Numeric IDs can be ambiguous when multiple numeric-ID adapters are registered. For platforms whose user IDs are not globally distinguishable, call the adapter directly and wrap the returned thread ID with bot.thread().
Check if a thread is a DM
Read more
Creating a Chat Instance
Initialize the Chat class with adapters, state, and configuration options.
Ephemeral Messages
Send messages visible only to a specific user.
File Uploads
Send and receive files across chat platforms.
History
Store and retrieve message history across user, thread, and channel scopes.