Discord Interaction icon

Discord Interaction

Sends messages, embeds and prompts to Discord

Overview

The Discord Interaction node enables sending various types of interactions to Discord servers via a bot. It supports sending plain messages, embedded rich content, confirmation prompts, and performing actions such as removing messages or managing user roles within specified Discord guilds (servers) and channels.

This node is useful in automation workflows where you want to:

  • Send notifications or announcements to Discord channels.
  • Prompt users for confirmation before proceeding with an action.
  • Manage server moderation tasks like bulk deleting messages or updating user roles programmatically.
  • Create rich embed messages with images, fields, and formatted content.

Practical examples:

  • Automatically send a welcome message with an embed when a new user joins a Discord server.
  • Ask users to confirm an important decision via interactive buttons before continuing a workflow.
  • Remove the last 10 messages from a channel after a certain event triggers.
  • Add or remove roles from users based on external system events or commands.

Properties

Name Meaning
Type Choose the type of interaction:
- Action: Perform an action like removing messages or modifying user roles.
- Message: Send a simple text or embed message.
- Confirmation: Prompt user to confirm or cancel.
Action When Type is "Action", select the specific action:
- Remove Messages
- Add Role to User
- Remove Role From User
Server Name or ID Select or specify the Discord guild (server) where the action/message will be performed.
Channel Name or ID Select or specify the text channel within the guild to send the message or perform the action.
How Many? Number of last messages to remove (max 100). Only applicable when action is "Remove Messages".
User ID The Discord user ID to add or remove roles from. Required for role management actions.
Which Role Names or IDs Roles to add or remove from the user. Multiple selection allowed.
Content Text content of the message or confirmation prompt. Cannot be empty if using buttons or selects.
Embed Whether to send the message as an embed instead of plain text.
Color Embed color (hex).
Title Embed title.
URL URL linked from the embed title.
Author Name Embed author name.
Author Icon URL or Base64 Image URL or base64 string for the embed author icon.
Author URL URL linked from the author name.
Description Embed description text.
Thumbnail URL or Base64 URL/base64 for embed thumbnail image.
Fields Embed fields: multiple entries each with title, value, and inline display option.
Image URL or Base64 URL/base64 for main embed image.
Footer Text Embed footer text.
Footer Icon URL or Base64 URL/base64 for footer icon image.
Displayed Date Timestamp to show in the embed footer.
Files Attach up to 5 images/files to the message by URL or base64.
Mention Role Names or IDs Roles to mention/tag in the message.
Additional Fields (Confirm type only) Confirmation-specific options:
- Timeout (seconds) for user response
- Custom labels for Yes and No buttons

Output

The node outputs JSON data representing the result of the interaction or action performed. The structure includes:

  • value: The main returned value or response from the Discord bot.
  • channelId: The ID of the channel where the interaction occurred.
  • userId: The ID of the user involved (if applicable).
  • userName: The username of the user involved.
  • userTag: The user's tag (username#discriminator).
  • messageId: The ID of the message sent or affected.
  • action: The action performed (e.g., "removeMessages", "addRole").

For confirmation prompts, the output is split into three outputs corresponding to confirmed, canceled, or no response states.

If binary files are attached, they represent images or files sent along with the message.


Dependencies

  • Requires a valid Discord Bot API token credential configured in n8n.
  • The bot must be running and connected to the specified guild(s) and channels.
  • Uses internal helper functions to fetch guilds, channels, and roles dynamically.
  • Relies on a socket connection to communicate with the Discord bot process for sending messages and receiving callbacks.

Troubleshooting

  • Error: "Please select at least one server before choosing channels."
    Occurs if no guild/server is selected when trying to load channels or roles. Fix by selecting at least one guild.

  • Connection errors or timeouts when communicating with the bot:
    Ensure the Discord bot is running and properly authenticated. Check network connectivity and bot permissions.

  • Invalid user or role IDs:
    Verify that user IDs and role IDs exist in the selected guild and are correctly entered.

  • Removing messages older than 4 weeks fails:
    Discord API restricts bulk deletion to messages less than 2 weeks old; adjust the number or age of messages accordingly.

  • Empty content error when sending messages with buttons/selects:
    Provide non-empty content text when using interactive prompts.


Links and References

Discussion