Overview
The Discord Trigger node for n8n allows workflows to be triggered by a wide range of Discord events, such as messages, commands, user interactions, and changes in user presence or roles. This node is particularly useful for automating actions based on activity within a Discord server, such as responding to specific messages, handling custom commands, tracking user join/leave events, or reacting to role changes.
Common scenarios:
- Automatically respond to certain keywords or patterns in chat messages.
- Trigger workflows when users join or leave the server.
- Handle custom slash commands with optional input fields.
- React to button or select menu interactions.
- Monitor changes in user presence (online, offline, etc.) or role assignments.
Practical examples:
- Send a welcome message when a new user joins.
- Log all messages containing a specific keyword.
- Assign roles automatically when a command is issued.
- Track when users go offline or change their status.
Properties
| Name | Meaning |
|---|---|
| Listen to | Select the text channels to listen to for triggering the workflow. If none are selected, all channels will be monitored. Requires bot credentials and at least one available text channel. |
| From roles | (For certain trigger types) Optionally restrict triggers to messages from specific roles. If none are selected, listens to everyone. |
| Trigger type | Type of event to listen to: - Message - Command - Interaction - User joins - User leaves - User presence update - User role added - User role removed |
| Which roles | (For "User role added"/"User role removed") Restrict to specific roles. If none are selected, listens to everyone. |
| Presence | (For "User presence update") Type of presence change to listen to: - Any change - Online - Offline - Do not disturb - Idle |
| Pattern | (For "Message" trigger) How to match the value: - Equals - Starts with - Contains - Ends with - Regex |
| Value | (For "Message" trigger) The value to test against incoming messages. Mentions are removed and whitespace is trimmed before matching. |
| Name | (For "Command" trigger) The name of the command to listen to (alphanumeric only). |
| Description | (For "Command" trigger) The description of the command. |
| Input field type | (For "Command" trigger) The type of input field: - None - Text - Number - Integer - Boolean |
| Input field description | (For "Command" trigger with input field) Description of the input field. |
| Input field required | (For "Command" trigger with input field) Whether the input field is required. |
| Case Sensitive | (For "Message" trigger) Whether the value match should be case sensitive. |
| Bot Mention | (For "Message" trigger) If true, the message must mention the bot to trigger the workflow. |
| Message ID | (For "Interaction" trigger) The message ID of the button/select to listen to. |
| Placeholder | Optional placeholder message shown in the channel while the workflow runs. Can be replaced by a response from a Discord Send node. |
Output
The node outputs a JSON object with the following possible fields, depending on the event type:
{
"content": "Message content (if applicable)",
"channelId": "ID of the channel where the event occurred",
"userId": "ID of the user involved",
"userName": "Username of the user",
"userTag": "User's Discord tag",
"messageId": "ID of the message (if applicable)",
"presence": "Presence status (if applicable)",
"addedRoles": ["List", "of", "added", "role", "IDs"],
"removedRoles": ["List", "of", "removed", "role", "IDs"],
"interactionMessageId": "ID of the interaction message (if applicable)",
"interactionValues": ["Values", "from", "interaction"],
"userRoles": ["List", "of", "user", "role", "IDs"],
"attachments": [
{
"id": "Attachment ID",
"url": "URL to the attachment",
// ...other attachment properties
}
]
}
- Not all fields will be present for every event type.
- If there are attachments (e.g., files sent with a message), they are included as an array under
attachments.
Dependencies
- External Service: Requires a Discord bot and valid Discord API credentials (
discordApi). - n8n Configuration: The bot must be running and have access to the relevant Discord server and channels.
- Environment: At least one text channel must be available in the server for most triggers.
Troubleshooting
Common issues:
- No channels or roles listed: Ensure your Discord credentials are set, the bot is running, and you have at least one text channel. Try closing and reopening the node modal to reload options.
- Workflow not triggering: Double-check that the correct event type and filters (channels, roles, etc.) are set. Make sure the bot has sufficient permissions.
- Command not showing up in Discord: Ensure the trigger is active and restart your Discord client.
- Error connecting to Discord: Verify your API key and base URL are correct and that the bot is online.
Common error messages:
- "Cannot read property '...' of undefined" — This may occur if expected data is missing from the event. Check your trigger configuration and ensure the event type matches your use case.
- "No channels available" — Add at least one text channel to your Discord server and ensure the bot has access.