Receive Message
Listens for incoming messages from Discord channels and triggers your automation flow when messages are received. This node has no inputs and acts as a trigger node.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Options
- Bot Token - Discord bot token credential for authentication. This creates a persistent connection to Discord.
- Server Id - (Optional) Filter messages by Discord server (guild) ID. Only messages from this server will be received.
- Channel Id - (Optional) Filter messages by Discord channel ID. Only messages from this channel will be received.
- Sender Id - (Optional) Filter messages by Discord user ID. Only messages from this user will be received.
Output
- Message - The received Discord message object containing all message details including content, author, channel info, attachments, and metadata.
How It Works
The Receive Message node creates a persistent WebSocket connection to Discord and listens for incoming messages. When executed, the node:
- Retrieves the bot token from credentials
- Creates a Discord bot session
- Opens a WebSocket connection to Discord
- Adds a message event handler
- Applies filters based on Server Id, Channel Id, and Sender Id options
- Emits the message object when a matching message is received
- Continues listening until the flow is stopped
Requirements
- A valid Discord bot token
- The bot must be added to the server you want to monitor
- Message Content Intent must be enabled in Discord Developer Portal
- Read Messages permission in the target channels
Message Object Structure
The output message object contains:
{
"ID": "1234567890123456789",
"ChannelID": "987654321098765432",
"GuildID": "111111111111111111",
"Content": "Hello, bot!",
"Timestamp": "2024-01-15T10:30:00Z",
"Author": {
"ID": "222222222222222222",
"Username": "JohnDoe",
"Discriminator": "1234",
"Avatar": "abc123"
},
"Mentions": [],
"Attachments": [],
"Embeds": [],
"Reactions": []
}
Filtering Messages
Use the filter options to control which messages trigger your automation:
Filter by Server:
- Set Server Id to only receive messages from a specific Discord server
- Useful when your bot is in multiple servers
Filter by Channel:
- Set Channel Id to only receive messages from a specific channel
- Perfect for monitoring a single channel like #support or #alerts
Filter by Sender:
- Set Sender Id to only receive messages from a specific user
- Useful for bot-to-bot communication or monitoring specific users
Combine Filters:
- Use multiple filters together for precise control
- Example: Server Id + Channel Id = messages from one channel in one server
Enabling Message Content Intent
To receive message content, you must enable the intent in Discord Developer Portal:
- Go to your application in Discord Developer Portal
- Navigate to the "Bot" section
- Scroll to "Privileged Gateway Intents"
- Enable "Message Content Intent"
- Save changes
Without Message Content Intent enabled, you'll receive message events but the Content field will be empty unless the bot is mentioned.
Error Handling
The node will emit errors in the following cases:
- ErrInvalidArg - Invalid or missing bot token
- ErrInvalidArg - Empty credential content
- Discord WebSocket connection errors
- Permission errors
Usage Notes
- This is a trigger node with no inputs - it starts automatically when the flow runs
- The node runs continuously until the flow is stopped
- Each received message triggers one execution of the connected nodes
- The bot must have appropriate permissions to read messages
- Messages sent by the bot itself are also received (consider filtering them in your flow)
Example: Simple Message Logger
Configuration:
- Bot Token: (your bot credentials)
- Channel Id: "123456789012345678"
Flow:
- Receive Message (triggers on every message in the channel)
- Log node → Logs
{{message.Content}}
Result: Every message in the channel is logged.
Example: Command Bot
Configuration:
- Bot Token: (your bot credentials)
- Server Id: "111111111111111111"
Flow:
1. Receive Message → message
2. Condition: message.Content starts with "!"
3. If True:
- Extract command from message.Content
- Process command
- Send Channel Message with response
Result: A bot that responds to commands starting with "!".
Example: Auto-Responder
Configuration:
- Bot Token: (your bot credentials)
- Channel Id: "123456789012345678"
Flow:
1. Receive Message → message
2. Condition: message.Content contains "help"
3. If True:
- Send Channel Message
- Channel Id: {{message.ChannelID}}
- Message Text: "How can I assist you?"
Result: Bot automatically replies when users type "help".
Example: User-Specific Monitor
Configuration:
- Bot Token: (your bot credentials)
- Sender Id: "222222222222222222"
Flow:
1. Receive Message → message
2. Send Direct Message to admin
- User Id: "333333333333333333"
- Message: "User sent: {{message.Content}}"
Result: Monitor and forward messages from a specific user.
Accessing Message Data
Use mustache syntax to access message properties in subsequent nodes:
{{message.Content}}- The message text{{message.ChannelID}}- Channel where message was sent{{message.GuildID}}- Server ID{{message.Author.ID}}- Message author's user ID{{message.Author.Username}}- Author's username{{message.ID}}- Unique message ID
Bot Permissions Required
- View Channel - See the channels
- Read Message History - Read past messages
- Message Content Intent - Read message content (Privileged Intent)
Performance Considerations
- The node maintains an active WebSocket connection
- Memory usage is minimal for the connection itself
- Processing many messages per second may require flow optimization
- Consider using filters to reduce unnecessary processing
Tips and Best Practices
- Use filters - Reduce noise by filtering at the source
- Handle bot messages - Add logic to ignore messages from your own bot
- Error handling - Wrap message processing in try-catch blocks
- Rate limiting - Be mindful of Discord rate limits when auto-responding
- Testing - Test with a dedicated test channel first
- Message Content Intent - Remember to enable this in Developer Portal
- Restart on errors - Implement retry logic for connection failures