Direct Messages
The Chat SDK provides a unified API for opening direct message conversations and sending private messages to users.Opening a DM
Open a direct message conversation with a user:Adapter Interface
TheopenDM method is available on adapters:
Example: DM from Button Click
Send a DM when a user clicks a button:Example: DM from Mention
Send a DM when mentioned:Checking if Thread is a DM
Determine if a thread is a direct message:Adapter Support
Check if an adapter supports DMs:Thread ID Format
DM thread IDs follow the same format as regular threads:- Slack:
slack:D123ABC:1234567890.123456(D-prefix for DMs) - Teams:
teams:{base64(conversationId)}:{base64(serviceUrl)} - Google Chat:
gchat:spaces/AAAA_BBB:{base64(threadName)}
Platform-Specific User IDs
Each platform has different user ID formats:Slack
Slack user IDs start withU followed by uppercase alphanumeric characters:
Microsoft Teams
Teams user IDs are Azure AD object IDs:Google Chat
Google Chat user IDs are in the formatusers/{user}:
User ID from Message Author
Get the user ID from a message author:Complete Example: Onboarding DM
Send an onboarding message via DM when a user joins:Error Handling
Handle cases where DM opening fails:DM Privacy Settings
Some platforms allow users to restrict who can send them DMs:- Slack: Users can restrict DMs in workspace settings
- Teams: Users can block external messages
- Google Chat: Users can control who can message them
Best Practices
Ask for consent before DMing
Ask for consent before DMing
Don’t send unsolicited DMs. Provide a button or command that users can trigger to receive private messages.
Keep DMs concise
Keep DMs concise
Direct messages feel more personal than channel messages. Keep them brief and relevant.
Provide context in DMs
Provide context in DMs
Since DMs are separate from channel context, include enough information so the user understands why they received the message.
Respect privacy settings
Respect privacy settings
Handle DM failures gracefully and don’t repeatedly attempt to message users who have blocked DMs.
Next Steps
Ephemeral Messages
Send temporary messages visible to specific users
Actions
Trigger DMs from button clicks