Skip to main content

Ephemeral Messages

Ephemeral messages are visible only to a specific user in a channel or thread. They’re perfect for:
  • Error messages and validation feedback
  • Help text and usage instructions
  • Private confirmations and status updates
  • User-specific data that shouldn’t clutter the channel

Platform Behavior

Different platforms handle ephemeral messages differently:
  • Slack: Native ephemeral messages (session-dependent, disappear on reload)
  • Google Chat: Native private messages (persist, only target user sees them)
  • Discord: No native support - must use DM fallback
  • Microsoft Teams: No native support - must use DM fallback

Posting Ephemeral Messages

Use thread.postEphemeral() or channel.postEphemeral():

Method Signature

Fallback to DM

When fallbackToDM: true, the SDK automatically sends a DM if the platform doesn’t support native ephemeral messages:

No Fallback

When fallbackToDM: false, the method returns null if native ephemeral isn’t supported:

EphemeralMessage Response

User Parameter

Pass either a user ID string or an Author object:

Message Content Types

Ephemeral messages support the same content types as regular messages (except streaming):

Plain Text

Markdown

Rich Cards

Example: Error Validation

Show error messages only to the user who triggered them:

Example: Help Text

Show help information privately:

Example: Private Confirmation

Confirm actions privately while posting public status:

Channel Ephemeral Messages

Use channel.postEphemeral() for channel-level messages:

Limitations

Ephemeral messages do not support streaming. If you try to pass an AsyncIterable<string>, it will fail.
Ephemeral messages cannot be edited or deleted after posting (platform limitation).
On Slack, ephemeral messages disappear when the user reloads their app. They are session-dependent.

Complete Example

Slash command with ephemeral validation and public result:

Best Practices

Error messages should be shown only to the user who triggered them, not the entire channel.
When a user performs an action, post a public message for transparency and a private ephemeral for personal confirmation.
Remember that Slack ephemeral messages are session-dependent, while Google Chat private messages persist.
If the message must reach the user regardless of platform, set fallbackToDM: true.

Next Steps

Direct Messages

Send persistent private messages via DM

Error Handling

Handle errors in ephemeral message delivery