Slash Commands
Slash commands let users invoke your bot with /command syntax. Register handlers with onSlashCommand to respond to them.
Slash commands are supported on Slack, Discord, and Telegram.
Handle a specific command
Handle multiple commands
Catch-all handler
Register a handler without a command to catch all slash commands:
SlashCommandEvent
The event object passed to slash command handlers:
| Property | Type | Description |
|---|---|---|
command | string | The command name (e.g., /status) |
text | string | Arguments after the command |
user | Author | The user who invoked the command |
channel | Channel | The channel where the command was invoked |
adapter | Adapter | The platform adapter |
triggerId | string (optional) | Platform trigger ID for opening modals |
openModal | (modal) => Promise<{ viewId: string } | undefined> | Open a modal dialog |
raw | unknown | Platform-specific payload |
Respond to a command
Use event.channel to post messages:
See Ephemeral Messages for platform support and the fallbackToDM option.
Open a modal
Use event.openModal() to open a modal in response to a slash command:
When a modal is opened from a slash command, the submit handler receives relatedChannel instead of relatedThread. Use this to post back to the channel where the command was invoked.
Telegram
Telegram supports bot commands such as /status and /status@mybot. Register handlers with onSlashCommand; commands addressed to another bot are ignored as slash commands and continue through the normal message path.
Discord
Discord slash commands arrive through HTTP Interactions, so no Gateway connection is needed. The adapter sends Discord a deferred response, then resolves it when your handler calls event.channel.post().
To make selected Discord slash command responses ephemeral, return DiscordInteractionResponseFlag.Ephemeral from the Discord adapter's interactionFlags option.
Subcommands
Discord supports subcommand groups and subcommands. The adapter flattens these into the event.command path:
| Discord command | event.command | event.text |
|---|---|---|
/status | /status | "" |
/project create --name="Acme" | /project create | Acme |
/project issue list --status="open" | /project issue list | open |
For full option details such as names and types, read the original Discord interaction payload from event.raw.
Registering commands with Discord
You need to register slash commands with the Discord API before they appear in the client. The Chat SDK handles incoming commands but does not register them for you.
Read more
Modals
Collect structured user input through modal dialogs with text fields, dropdowns, and validation.
Ephemeral Messages
Send messages visible only to a specific user.
Getting Started
Pick a guide to start building with Chat SDK.
Emoji
Type-safe, cross-platform emoji that convert to each platform's format.