How to Integrate n8n with Discord: Full Setup
In this article
Yes, you can integrate n8n with Discord using official webhooks and bots. This lets you automate messages, notifications, and even moderate servers. You'll need an n8n instance (self-hosted or cloud) and a Discord server where you have permission to manage webhooks or create a bot.
What You'll Need
- An n8n instance (self-hosted or cloud) with admin access.
- A Discord server where you have "Manage Webhooks" or "Manage Server" permissions.
- For bot-based workflows: a Discord application with bot permissions (created via the Discord Developer Portal).
- Basic familiarity with n8n workflows and nodes.
Step-by-Step
Method 1: Using a Discord Webhook (Simplest)
- Create a webhook in Discord: Open your Discord server, go to the channel where you want messages sent. Click the gear icon (Channel Settings) next to the channel name. Select "Integrations" > "Webhooks" > "Create Webhook." Give it a name (e.g., "n8n Bot") and optionally set an avatar. Copy the Webhook URL.
- Open n8n: Log in to your n8n instance and create a new workflow.
- Add a trigger node: Choose a trigger that fits your use case (e.g., Schedule Trigger for periodic messages, Webhook Trigger for incoming HTTP requests, or a manual trigger for testing).
- Add an HTTP Request node: Drag an "HTTP Request" node onto the canvas. In its settings:
- Method: POST
- URL: Paste the Discord webhook URL you copied.
- Body Content Type: JSON
- Define body as JSON: {"content": "Your message here"} (you can use n8n expressions to insert dynamic data, e.g., ).
- Test the workflow: Click "Execute Node" on the HTTP Request node (or run the whole workflow) to send a test message to your Discord channel.
- Activate the workflow: Once it works, toggle the workflow to "Active" so it runs automatically.
Method 2: Using a Discord Bot (For Advanced Features)
- Create a Discord application: Go to the Discord Developer Portal and click "New Application." Give it a name.
- Create a bot: In your application, go to the "Bot" tab and click "Add Bot." Copy the bot token (keep it secret).
- Invite the bot to your server: In the "OAuth2" > "URL Generator" tab, select "bot" under scopes. Under bot permissions, choose "Send Messages" (and others like "Read Messages" if needed). Copy the generated URL, open it in a browser, and select your server to invite the bot.
- In n8n, add a Discord node: In your workflow, add a "Discord" node (it's available in the nodes panel). You'll need to provide credentials: click "Create New" and enter the bot token you copied.
- Configure the Discord node: Choose the operation (e.g., "Send a message"). Fill in the Channel ID (right-click your Discord channel > "Copy Channel ID" — enable Developer Mode in Discord settings to see this). Enter the message text.
- Test and activate: Execute the node to test, then activate the workflow.
Common Mistakes
- Using the wrong webhook URL: Make sure you copied the full URL, including the token part after the last slash.
- Not setting Content-Type to JSON: If you send a plain text body, Discord will return an error.
- Forgetting to enable Developer Mode in Discord: Without it, you can't copy channel IDs for the bot method.
- Using a bot token instead of a webhook URL (or vice versa): They are not interchangeable.
- Not activating the workflow: A workflow that isn't toggled to Active won't run automatically.
Tips
- Use n8n expressions for dynamic content: For example, to send a message with data from a previous node, use in the message body.
- Add error handling: In n8n, you can add an "Error Trigger" node to catch failures and send you a notification.
- Rate limits: Discord has rate limits (e.g., 5 messages per second per webhook). If you're sending many messages, add a small delay between nodes.
- Use environment variables: Store your Discord webhook URL or bot token in n8n's environment variables for security, rather than hardcoding them.
Troubleshooting
If your messages aren't appearing, follow these checks in order:
- Check the webhook URL: Make sure there are no extra spaces or missing characters. Try re-copying it.
- Check the HTTP Request node output: In n8n, click on the node and look at the "Output" tab. If you see a 4xx error, Discord is rejecting the request. Common errors: 400 (bad request — likely malformed JSON), 401 (unauthorized — wrong webhook or token), 404 (not found — webhook deleted).
- Check Discord permissions: For webhooks, the channel must allow webhooks. For bots, ensure the bot has "Send Messages" permission in the channel.
- Verify the workflow is active: If you're using a schedule trigger, make sure the workflow is toggled on and the trigger is configured correctly.
- Restart n8n: Sometimes a simple restart fixes credential or connection issues.
- If using a bot, re-invite the bot: If you changed permissions, remove the bot from the server and re-invite with the correct permissions.
Frequently Asked Questions
Can I send embedded messages (rich embeds) via webhook?
Yes, you can send embeds by including an "embeds" array in the JSON body. Example: {"embeds": [{"title": "Hello", "description": "World"}]}
How do I get a channel ID in Discord?
Enable Developer Mode in Discord (Settings > Advanced > Developer Mode), then right-click the channel and select "Copy Channel ID."
Can I use a Discord bot to receive messages in n8n?
Yes, you can set up a bot that listens to messages using the "Discord Trigger" node in n8n. This requires the bot to have "Read Messages" permission and the workflow to be active.
Is there a limit to how many messages I can send?
Discord limits webhooks to 30 messages per minute per channel. Bots have a global rate limit of 50 requests per second, but it's safer to stay under 10 messages per second per channel.
Can I send messages to a DM (direct message) with a webhook?
No, webhooks only work in channels. To send DMs, you need a bot that has the user's ID and the "Send Messages" permission in DMs (which requires the user to have accepted DMs from the bot).
What if my webhook URL gets exposed?
You should delete the webhook in Discord and create a new one. Anyone with the URL can send messages to that channel.