Types of Interactions
There are different types of interactions in your app’s toolbelt that you can pick and choose from to build engaging, interactive experiences in Discord.Commands
Application commands provide users a native way to invoke an app in Discord. They often map to an app’s core features or functionality. When an app creates a command it can choose the command’s type, which determines where it appears in the Discord client and the metadata the app will receive when the command is invoked. There are four types of application commands:- Slash commands are the most common type and are accessed by typing
/in the chat input, or by opening the command picker. - Message commands are commands related to a message or a message’s content. They’re accessed by clicking on the context menu (the three dots) at the top-right of a message (or right-clicking), then navigating to the “Apps” section.
- User commands are commands related to a user in Discord. They’re accessed by right-clicking on a user profile, then navigating to the “Apps” section.
- Entry Point commands are commands used as the primary way to launch Activities from the App Launcher.
Message Components
Message components are interactive elements that can be included in the content of messages your app sends in Discord. The main interactive components that apps can send in messages include:- Buttons are clickable components that can be customized with different styles, text, and emoji.
- Static select menus are components that a user can open to see a list of developer-defined options with custom labels and descriptions.
- Auto-populated select menus are a set of four different select components populated with contextual Discord resources, like a list of users or channels in a server.
Modals
Modals are single-user pop-up interfaces that allow apps to collect form-like data. Modals can only be opened in response to a user invoking one of your app’s commands or message components. The only interactive components that modals can contain are text inputs and other form components like radio groups and checkboxes, which allow users to fill out form inputs. Details about creating and using modals are in the Receiving and Responding documentation.Preparing for Interactions
When a user interacts with your app, you can receive interactions in one of two mutually exclusive ways:- WebSocket-based Gateway connection
- HTTP via outgoing webhooks
Configuring an Interactions Endpoint URL
An Interactions Endpoint URL is a public endpoint for your app where Discord can send HTTP-based interactions. If your app uses Gateway-based interactions, you don’t need to configure one.Setting Up an Endpoint
Before you can add your Interactions Endpoint URL to your app, your endpoint must be prepared for two things:Acknowledge PING requests from Discord
When adding your Interactions Endpoint URL, Discord will send a
POST request with a PING payload (type: 1) to your endpoint. Your app must return a 200 response with a PONG payload (also type: 1).You must provide a valid
Content-Type when responding to PINGs. See here for further information.Responding to PING Requests
Responding to PING Requests
To properly acknowledge a
PING payload, return a 200 response with a payload of type: 1:Validate security-related request headers
Each interaction is sent with the following headers:
In addition to checking headers when you save your endpoint, Discord will also perform automated, routine security checks against your endpoint, including purposefully sending invalid signatures. If validation fails, Discord will remove your interactions URL and alert you via email and System DM.We highly recommend checking out the Community Resources for libraries that include decorators for API frameworks like Flask and Express to make validation easy.
X-Signature-Ed25519as a signatureX-Signature-Timestampas a timestamp
401 error code.Validating Security Headers
Validating Security Headers
- JavaScript
- Python
Adding an Interactions Endpoint URL
After you have a public endpoint ready, add it to your app by going to your app’s settings. On the General Information page, look for the Interactive Endpoint URL field. Paste your public URL that is set up to acknowledgePING messages and correctly handle security-related signature headers.
Handling Interactions
Once your app is prepared for interactions, explore the Receiving and Responding documentation for technical details on handling interaction requests in your app.Application Commands
Create slash commands, user commands, and message commands.
Receiving and Responding
Technical reference for receiving and responding to interactions.