Interaction In
Listens for Discord interactions including slash command invocations, button clicks, modal submissions, and autocomplete requests. This node has no inputs and acts as a trigger node.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Options
- Bot Token - Discord bot token credential for authentication.
- Server Id - (Optional) Filter by Discord server (guild) ID.
- Channel Id - (Optional) Filter by Discord channel ID.
- Sender Id - (Optional) Filter by Discord user ID.
- Command Name - (Optional) Filter by command name (only for command interactions).
- Interaction Type - The type of interaction to listen for:
- All - Listen for all interaction types
- Command - Slash command invocations
- Message Component - Button clicks, select menu selections
- Autocomplete - Autocomplete requests
- Modal Submit - Modal form submissions
Output
- Interaction - The complete Discord interaction object with all interaction details.
- Modal Data - (For modal submissions) Key-value pairs of modal form data.
How It Works
The Interaction In node creates a persistent WebSocket connection to Discord and listens for interactions. When executed, the node:
- Retrieves the bot token from credentials
- Creates a Discord bot session
- Opens a WebSocket connection to Discord
- Adds an interaction event handler
- Applies filters based on type, server, channel, sender, and command name
- Emits the interaction object when a matching interaction is received
- Continues listening until the flow is stopped
Requirements
- A valid Discord bot token
- The bot must be added to servers where it will receive interactions
- Slash commands must be registered (for command interactions)
- Appropriate intents enabled in Discord Developer Portal
Error Handling
The node will emit errors in the following cases:
- ErrInvalidArg - Invalid or missing bot token
- ErrInvalidArg - Interaction type not selected
- Discord WebSocket connection errors
Interaction Object Structure
For command interactions:
{
"ID": "123456789012345678",
"Type": 2,
"Token": "interaction_token_here",
"GuildID": "987654321098765432",
"ChannelID": "111111111111111111",
"Member": {
"User": {
"ID": "222222222222222222",
"Username": "JohnDoe"
}
},
"Data": {
"Name": "ping",
"Options": []
}
}
For button clicks:
{
"ID": "123456789012345678",
"Type": 3,
"Token": "interaction_token_here",
"Data": {
"CustomID": "approve_btn"
}
}
For modal submissions:
{
"ID": "123456789012345678",
"Type": 5,
"Token": "interaction_token_here",
"Data": {
"CustomID": "feedback_modal",
"Components": [...]
}
}
Modal Data Output
For modal submissions, the Modal Data output contains parsed form values:
{
"field_name_1": "User entered value 1",
"field_name_2": "User entered value 2",
"user_id": "222222222222222222"
}
Interaction Types
- Type 2 - Application Command (slash command)
- Type 3 - Message Component (button, select menu)
- Type 4 - Autocomplete request
- Type 5 - Modal Submit
Example: Handle Slash Command
Configuration:
- Bot Token: (your credentials)
- Interaction Type: "Command"
- Command Name: "hello"
Flow:
1. Interaction In → interaction
2. Interaction Out
- Interaction Id: {{interaction.ID}}
- Response: {"type": "message", "response_message": "Hello!"}
Result: Bot responds to /hello command.
Example: Handle Button Click
Configuration:
- Interaction Type: "Message Component"
Flow:
1. Send message with buttons (using Send Channel Message)
2. Interaction In → interaction
3. Condition: interaction.Data.CustomID == "approve_btn"
4. If True:
- Interaction Out with approval message
5. If False:
- Interaction Out with rejection message
Result: Bot handles button clicks.
Example: Modal Form Submission
Configuration:
- Interaction Type: "Modal Submit"
Flow:
1. Interaction In → interaction, modal_data
2. Extract form data:
- Name: {{modal_data.name_field}}
- Email: {{modal_data.email_field}}
3. Process submission
4. Interaction Out with confirmation
Result: Process form submissions from modals.
Example: Command with Options
Configuration:
- Interaction Type: "Command"
- Command Name: "greet"
Flow:
1. Interaction In → interaction
2. Get options:
- User: {{interaction.Data.Options[0].Value}}
- Message: {{interaction.Data.Options[1].Value}}
3. Interaction Out
- Response: "{{Message}} {{User}}"
Result: Handle command with user-provided options.
Example: Autocomplete
Configuration:
- Interaction Type: "Autocomplete"
Flow:
1. Interaction In → interaction
2. Get partial input: {{interaction.Data.Options[0].Value}}
3. Search database for matches
4. Interaction Out
- Response with choices array
Result: Provide autocomplete suggestions.
Accessing Interaction Data
Use mustache syntax to access interaction properties:
For commands:
{{interaction.Data.Name}}- Command name{{interaction.Data.Options[0].Value}}- First option value{{interaction.Member.User.ID}}- User who invoked
For components:
{{interaction.Data.CustomID}}- Button/component ID{{interaction.Message.ID}}- Original message ID
For modals:
{{modal_data.field_name}}- Form field values{{modal_data.user_id}}- User who submitted
Response Requirement
Discord interactions must be responded to within 3 seconds or they will fail. Always follow Interaction In with Interaction Out or use deferred responses for longer operations.
Deferred Responses
For operations taking longer than 3 seconds:
1. Interaction In → interaction
2. Interaction Out (deferred message)
- Response: {"type": "deferred message"}
3. Perform long operation
4. Update Interaction Respond
- With final result
Use Cases
- Slash commands - Handle user command invocations
- Interactive buttons - Respond to button clicks
- Form submissions - Process modal form data
- Menu selections - Handle select menu choices
- Autocomplete - Provide dynamic autocomplete suggestions
- Multi-step workflows - Chain interactions for complex flows
Filtering
By Command Name:
- Only receive specific command interactions
- Useful when multiple commands exist
By User:
- Only process interactions from specific users
- Good for admin-only features
By Channel:
- Only handle interactions in specific channels
- Useful for feature-specific channels
Tips and Best Practices
- Response timing - Respond within 3 seconds or use deferred responses
- Error handling - Always handle interaction errors gracefully
- Validation - Validate user input from interactions
- Permissions - Check user permissions before executing actions
- User feedback - Always provide clear feedback to users
- Ephemeral responses - Use ephemeral messages for private responses
- Testing - Test interactions thoroughly before deployment
- Logging - Log interactions for debugging and analytics