Overview
The Discord Interaction node enables sending various types of interactions to a Discord server via a bot. It supports sending plain messages, embedded rich content, confirmation prompts for user interaction, and performing specific actions such as removing messages or managing user roles within a guild (server).
Common scenarios where this node is beneficial include:
- Sending announcements or updates to a Discord channel.
- Prompting users for confirmation before proceeding with an automated workflow.
- Moderation tasks like bulk deleting recent messages.
- Managing user permissions by adding or removing roles dynamically.
Practical examples:
- Automatically send a welcome message with rich embed content when a new user joins.
- Ask a user to confirm an action (e.g., delete files) via a confirmation prompt in Discord.
- Remove the last 10 messages from a channel after a certain event triggers.
- Assign a "Verified" role to a user after they complete a verification process.
Properties
| Name | Meaning |
|---|---|
| Type | Choose the type of interaction: Action (perform an action), Message (send a message), or Confirmation (prompt user to confirm). |
| Action | When Type is Action, select the specific action: Remove Messages, Add Role to User, or 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, messages must be less than 4 weeks old). Applicable only for Remove Messages action. |
| User ID | The Discord user ID to add or remove roles from. Required for Add/Remove Role actions. |
| Which Role Names or IDs | Select or specify one or more roles to add or remove from the user. Required for Add/Remove Role actions. |
| Content | Text content of the message or confirmation prompt. Cannot be empty if buttons or selects are used. |
| Embed | Whether to send the message as an embed (rich content) instead of plain text. |
| Color | Color of the embed sidebar (if embed is enabled). |
| Title | Title of the embed message. |
| URL | URL linked from the embed title. |
| Author Name | Name displayed as the author of the embed. |
| Author Icon URL or Base64 | Image URL or base64 string for the author's icon in the embed. |
| Author URL | URL linked from the author name in the embed. |
| Description | Description text inside the embed. |
| Thumbnail URL or Base64 | URL or base64 image shown as the embed thumbnail. |
| Fields | Custom fields inside the embed; each has a title, value, and inline display option. |
| Image URL or Base64 | URL or base64 image displayed in the embed. |
| Footer Text | Text shown in the embed footer. |
| Footer Icon URL or Base64 | Image URL or base64 for the footer icon. |
| Displayed Date | Timestamp shown in the embed footer. |
| Files | Attach up to 5 images/files to the message by specifying URLs or base64 strings. |
| Mention Role Names or IDs | Roles to mention/tag in the message. |
| Additional Fields (Confirm type only) | Confirmation Timeout (seconds): how long to wait for user response before considering the prompt expired. |
Output
The node outputs JSON data containing details about the interaction result. Typical output fields include:
value: The main response or result value from the interaction.channelId: The ID of the channel where the interaction occurred.userId: The ID of the user involved in the interaction.userName: The username of the user.userTag: The user's Discord tag (username#discriminator).messageId: The ID of the message sent or interacted with.action: The action performed (if applicable).
For confirmation prompts, the output is split into three separate outputs representing confirmed, canceled, or no response states.
If the node sends files/images, it handles them as attachments but does not output binary data directly.
Dependencies
- Requires a valid Discord bot API authentication token configured in n8n credentials.
- The bot must be running and connected to the specified guilds and channels.
- Uses socket communication internally to interact with the bot process.
- Requires access to Discord guilds, channels, roles, and users as per the bot's permissions.
Troubleshooting
- No channels or roles listed: Ensure you have selected at least one guild/server before loading channels or roles. Also, verify that the bot has appropriate permissions and is online.
- Failed connection errors: Check that the Discord bot token is valid and the bot is running. Network issues or invalid credentials can cause connection failures.
- Removing messages fails: The Discord API limits bulk deletion to messages younger than 2 weeks and a maximum of 100 messages. Adjust the "How Many?" property accordingly.
- Role management errors: Verify the user ID and role IDs are correct and that the bot has permission to manage roles in the guild.
- Confirmation prompt timeout: If no user response is received within the timeout period, the node outputs a "no response" result.
- Empty content error: When sending messages or confirmations with buttons/selects, ensure the content field is not empty.