Ephemeral messages
Send messages visible only to a specific user.
Ephemeral messages are visible only to a specific user within a thread. They're useful for confirmations, hints, and private notifications.
Send an ephemeral message
await thread.postEphemeral(user, "Only you can see this!", {
fallbackToDM: true,
});The fallbackToDM option is required and controls behavior on platforms without native ephemeral support:
fallbackToDM: true— send as a DM if native ephemeral is not supportedfallbackToDM: false— returnnullif native ephemeral is not supported
Platform behavior
| Platform | Native support | Behavior | Persistence |
|---|---|---|---|
| Slack | Yes | Ephemeral in channel | Session-only (disappears on reload) |
| Google Chat | Yes | Private message in space | Persists until deleted |
| Discord | No | DM fallback | Persists in DM |
| Teams | No | DM fallback | Persists in DM |
Check for fallback
const result = await thread.postEphemeral(user, "Private notification", {
fallbackToDM: true,
});
if (result?.usedFallback) {
console.log("Sent as DM instead of ephemeral");
}Graceful degradation
Only send if the platform supports native ephemeral:
const result = await thread.postEphemeral(user, "Contextual hint", {
fallbackToDM: false,
});
if (!result) {
// Platform doesn't support native ephemeral
// Message was not sent
}Ephemeral cards
Cards work with ephemeral messages too:
await thread.postEphemeral(
event.user,
<Card title="Ephemeral Card">
<CardText>Only you can see this card.</CardText>
<Actions>
<Button id="open_modal" style="primary">Open Modal</Button>
</Actions>
</Card>,
{ fallbackToDM: true }
);