Discord Trigger icon

Discord Trigger

Trigger based on Discord events

Overview

The Discord Trigger node for n8n allows workflows to be triggered by a wide variety of Discord events, such as messages, commands, user interactions, and changes in user presence or roles. This node is highly configurable, enabling you to listen to specific channels, filter by user roles, and fine-tune the type of event that should trigger your workflow.

Common scenarios:

  • Automate responses to specific messages or commands in Discord.
  • Monitor when users join or leave a server.
  • React to role changes or presence updates (e.g., notify when a user goes online).
  • Handle button or select menu interactions within Discord messages.

Practical examples:

  • Start an approval process when a certain command is issued in a channel.
  • Log all messages containing a keyword to an external database.
  • Send a welcome message when a new user joins the server.
  • Track when a user's role is updated and trigger related automations.

Properties

Name Meaning
Listen to Select the text channels to monitor for triggering the workflow. If none are selected, all channels will be listened to. Requires bot credentials and at least one available text channel.
From roles (For certain trigger types) Optionally restrict triggers to users with specific roles. If none are selected, listens to everyone.
Trigger type Type of Discord event to listen for:
- 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") Specify which roles to monitor. If none are selected, listens to all roles.
Presence (For "User presence update") Filter by presence change:
- 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.
Name (For "Command" trigger) The name of the command to listen for (alphanumeric only).
Description (For "Command" trigger) Description of the command.
Input field type (For "Command" trigger) 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 matching the value is 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 single item per trigger event with the following structure in the json field:

{
  "content": "...",                // The content of the message (if applicable)
  "channelId": "...",              // The ID of the channel where the event occurred
  "userId": "...",                 // The ID of the user involved in the event
  "userName": "...",               // The username of the user
  "userTag": "...",                // The Discord tag of the user (e.g., username#1234)
  "messageId": "...",              // The ID of the message (if applicable)
  "presence": "...",               // The user's presence status (if applicable)
  "addedRoles": [...],             // Array of role IDs added to the user (if applicable)
  "removedRoles": [...],           // Array of role IDs removed from the user (if applicable)
  "interactionMessageId": "...",   // The message ID for interaction events (if applicable)
  "interactionValues": [...],      // Values from button/select interactions (if applicable)
  "userRoles": [...],              // Array of current role IDs for the user (if applicable)
  "attachments": [...]             // Array of attachment objects if the event includes files
}
  • Fields may be omitted if not relevant to the triggered event.
  • If binary data (attachments) is present, it will be included in the attachments array.

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 specified channels/roles.
  • Environment: At least one text channel must be available in the Discord server.

Troubleshooting

Common issues:

  • No channels/roles listed: Ensure your Discord credentials are set, the bot is running, and there is at least one text channel/role available. Try closing and reopening the property modal to reload options.
  • Workflow not triggering: Double-check that the correct event type, channels, and roles are selected. For command triggers, ensure the command is registered and the bot has necessary permissions.
  • Missing output fields: Some fields (like attachments, interactionValues) will only appear for relevant event types.
  • Error connecting to Discord: Verify your API key and base URL. Make sure the bot is online and has permission to read messages/events in the selected channels.

Error messages:

  • "Cannot get channels/roles" – Check bot permissions and connection.
  • "Invalid credentials" – Re-enter your Discord API credentials.
  • "No text channels available" – Create at least one text channel in your Discord server.

Links and References

Discussion