Skip to main content

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

The openDM 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 with U followed by uppercase alphanumeric characters:
Extract user ID from mentions:

Microsoft Teams

Teams user IDs are Azure AD object IDs:

Google Chat

Google Chat user IDs are in the format users/{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
Always handle DM failures gracefully and provide alternative communication methods.

Best Practices

Direct messages feel more personal than channel messages. Keep them brief and relevant.
Since DMs are separate from channel context, include enough information so the user understands why they received the message.
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