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
Usethread.postEphemeral() or channel.postEphemeral():
Method Signature
Fallback to DM
WhenfallbackToDM: true, the SDK automatically sends a DM if the platform doesn’t support native ephemeral messages:
No Fallback
WhenfallbackToDM: false, the method returns null if native ephemeral isn’t supported:
EphemeralMessage Response
User Parameter
Pass either a user ID string or anAuthor 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
Usechannel.postEphemeral() for channel-level messages:
Limitations
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
Use ephemeral for errors and validation
Use ephemeral for errors and validation
Error messages should be shown only to the user who triggered them, not the entire channel.
Provide public confirmation for actions
Provide public confirmation for actions
When a user performs an action, post a public message for transparency and a private ephemeral for personal confirmation.
Consider platform differences
Consider platform differences
Remember that Slack ephemeral messages are session-dependent, while Google Chat private messages persist.
Use fallbackToDM for important messages
Use fallbackToDM for important messages
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