Discord Trigger icon

Discord Trigger

Trigger based on Discord events

Overview

This node triggers workflows based on various Discord events. It listens to specific Discord server activities such as messages, commands, user interactions with buttons or selects, user join/leave events, presence updates, and role changes. This is useful for automating responses or actions in a Discord server when these events occur.

Common scenarios include:

  • Triggering a workflow when a message matching certain criteria is sent in specified channels.
  • Responding to custom slash commands issued by users.
  • Reacting to user interactions with persistent buttons or select menus.
  • Monitoring user join or leave events to welcome or log members.
  • Tracking presence status changes (online, offline, idle, etc.).
  • Detecting when roles are added or removed from users.

Example: Automatically send a welcome message when a user joins the server, or trigger a workflow when a command like /help is used.

Properties

Name Meaning
Listen to Select one or more text channels to listen to for triggering the workflow. If none selected, all channels are listened to. Requires bot running and proper credentials.
From roles Filter events by user roles. If no roles selected, listens to everyone (@everyone). Only applies to certain event types (message, command, user leaves, presence update, role added/removed, interaction).
Trigger type Type of Discord event to listen for. Options: Message, Command, Interaction, User joins, User leaves, User presence update, User role added, User role removed.
Which roles For role added/removed events, specify which roles to listen for. If none selected, listens to everyone.
Presence For presence update events, specify which presence state changes to listen for: any change, online, offline, do not disturb, idle.
Pattern For message events, how to match the message content: equals, starts with, contains, ends with, regex. The message is tested after removing mentions and trimming whitespace.
Value The string value to test against messages for triggering (required for message events).
Name Name of the command to listen for (alphanumeric only, required for command events).
Description Description of the command (required for command events).
Input field type Type of input field for the command: None, Text, Number, Integer, Boolean (required for command events).
Input field description Description of the command's input field (required if input field type is not None).
Input field required Whether the command's input field is required (boolean, optional).
Case Sensitive For message events, whether matching should be case sensitive (default false).
Bot Mention For message events, require that the message also mentions the bot to trigger (does not exclude other criteria).
Message ID For interaction events, the message ID of the button/select to listen to (required).
Placeholder A placeholder message shown in the channel when the workflow is running. Can be replaced by a response message from a Discord Send node.

Output

The node outputs JSON data representing the Discord event that triggered it. The output fields include:

  • content: The message content (for message events).
  • channelId: The ID of the channel where the event occurred.
  • userId: The ID of the user involved.
  • userName: The username of the user.
  • userTag: The user's tag (username#discriminator).
  • messageId: The ID of the message (if applicable).
  • presence: The user's presence status (if applicable).
  • addedRoles: Roles added to the user (if applicable).
  • removedRoles: Roles removed from the user (if applicable).
  • interactionMessageId: The message ID related to an interaction event.
  • interactionValues: Values from the interaction (e.g., selected options).
  • userRoles: Roles of the user at the time of the event.
  • attachments: Any attachments included in the message.

If binary data were supported, it would represent files or media attached to messages, but this node primarily outputs JSON event data.

Dependencies

  • Requires a valid Discord API credential with appropriate permissions.
  • The Discord bot must be running and connected to the server.
  • The bot needs access to the specified channels and roles.
  • The node uses an internal IPC mechanism to communicate with the bot process.
  • Proper configuration of webhook URL and credentials in n8n is necessary.

Troubleshooting

  • No channels listed: Ensure the bot is running and has permission to view channels. Close and reopen the modal to refresh the channel list.
  • Commands not triggering: Verify the command name is alphanumeric and the trigger node is active. Restart the Discord client if commands do not appear.
  • Workflow not triggering: Check that the bot has the required permissions and the correct channels/roles are selected.
  • Error connecting to Discord API: Confirm the API key credential is valid and the base URL is correct.
  • Regex pattern issues: Make sure the regex syntax is valid ECMAScript regex.
  • Missing required properties: Some trigger types require specific properties (e.g., message ID for interaction triggers).

Links and References

Discussion