n8n trigger node for Discord @mention messages
  • TypeScript 100%
Find a file
2026-06-03 15:23:37 +02:00
dist Initial n8n Discord trigger node 2026-06-03 15:14:40 +02:00
example Initial n8n Discord trigger node 2026-06-03 15:14:40 +02:00
src Initial n8n Discord trigger node 2026-06-03 15:14:40 +02:00
.gitignore Initial n8n Discord trigger node 2026-06-03 15:14:40 +02:00
AGENTS.md Initial n8n Discord trigger node 2026-06-03 15:14:40 +02:00
package-lock.json Initial n8n Discord trigger node 2026-06-03 15:14:40 +02:00
package.json Initial n8n Discord trigger node 2026-06-03 15:14:40 +02:00
README.md Update installation instructions and add verification steps for n8n Discord trigger node 2026-06-03 15:23:37 +02:00
tsconfig.json Initial n8n Discord trigger node 2026-06-03 15:14:40 +02:00

n8n-nodes-discord-trigger

An n8n community node package that adds a Discord trigger node. It starts workflows when a Discord bot receives messages, optionally only when the bot is mentioned.

Features

  • Trigger workflows from Discord messages
  • Listen for @mention messages or all messages
  • Optional channel ID filtering
  • Optional bot-message filtering
  • Optional mention stripping from emitted text
  • Supports guild channels and direct messages

Installation for n8n admins

This package is not published to npm yet, so it cannot currently be installed through n8n's Community Nodes UI by entering the package name. Install it directly from the Forgejo Git repository on the n8n host.

Standard/self-hosted n8n

Run the install as the same OS user that runs n8n:

mkdir -p ~/.n8n/custom
cd ~/.n8n/custom
npm init -y
npm install git+https://git.miskam.xyz/mxm/n8n-nodes-discord-trigger.git

Then restart n8n so it discovers the new node.

Docker-based n8n

Install the package inside the n8n user folder that is persisted by your n8n volume. Example:

docker exec -it <n8n-container> sh
mkdir -p /home/node/.n8n/custom
cd /home/node/.n8n/custom
npm init -y
npm install git+https://git.miskam.xyz/mxm/n8n-nodes-discord-trigger.git
exit

Then restart the container:

docker restart <n8n-container>

If your n8n container image does not include git, either install git in a custom image or clone/build this repository separately and install from a local package/tarball.

Verify installation

After restart, create or edit a workflow and search for Discord Trigger in the node picker. Then add Discord Bot API credentials under n8n credentials.

Updating

To update to the latest main branch:

cd ~/.n8n/custom
npm install git+https://git.miskam.xyz/mxm/n8n-nodes-discord-trigger.git#main

Restart n8n after updating.

Local development

For development only, clone the repository and build it locally:

git clone https://git.miskam.xyz/mxm/n8n-nodes-discord-trigger.git
cd n8n-nodes-discord-trigger
npm install
npm run build

Discord setup

  1. Create an application in the Discord Developer Portal.
  2. Add a bot to the application.
  3. Copy the bot token.
  4. Enable the required gateway intents for your bot, especially:
    • Server Members Intent, if needed by your server setup
    • Message Content Intent
  5. Invite the bot to your server with permissions to read messages in the channels you want to monitor.

Credentials

Create Discord Bot API credentials in n8n with:

  • Bot Token: The bot token from the Discord Developer Portal.
  • Bot User ID: The bot user's ID. This is commonly the application ID shown under General Information.

Node options

Trigger On

  • @Mention: Trigger only when the bot is mentioned.
  • All Messages: Trigger on every received message in watched channels.

Channel IDs

Comma-separated list of channel IDs to watch. Leave empty to watch all channels the bot can see.

Example:

123456789012345678,987654321098765432

Ignore Bots

When enabled, messages from other bots are ignored.

Strip Mention

When enabled, Discord mention markup like <@123> or <@!123> is removed from the emitted text field.

Output

The trigger emits one item per Discord message:

{
  "text": "message text",
  "originalContent": "<@123> message text",
  "authorId": "000000000000000000",
  "authorUsername": "username",
  "authorDisplayName": "Display Name",
  "channelId": "000000000000000001",
  "messageId": "000000000000000002",
  "guildId": "000000000000000003",
  "timestamp": 1710000000000,
  "isDM": false
}

Example workflow

An example n8n workflow is included in example/Discord Bot Webhook Handler.json.

It demonstrates a common Discord bot flow:

  1. Discord Trigger receives a message that mentions the bot.
  2. ACK + Process prepares a quick acknowledgement and processed result.
  3. Send ACK to Discord replies to the original Discord message through the Discord REST API.
  4. Send Result to Discord posts the processed result back to the same channel.

Example workflow

To use it:

  1. Import the JSON workflow into n8n.
  2. Configure the Discord Bot API credentials on the Discord Trigger node.
  3. Configure the HTTP Header Auth credentials used by the HTTP Request nodes.
    • Header name: Authorization
    • Header value: Bot <your-discord-bot-token>
  4. Activate the workflow and mention your bot in Discord.

The included workflow contains example node IDs, credential names, and pinned data. Replace them with your own credentials and runtime data before using it in production.

Development

Build the package:

npm run build

Run TypeScript in watch mode:

npm run dev

Source files:

  • src/nodes/DiscordTrigger/DiscordTrigger.node.ts
  • src/credentials/DiscordBotApi.credentials.ts

Compiled output is written to dist/.

License

MIT