Skip to main content

Send Direct Message

Sends a direct message (DM) to a Discord user with support for rich content including embeds, file attachments, buttons, and message replies.

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.
info

If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.

Inputs

  • Client Id - The Discord bot client identifier from the Connect node (optional if Bot Token provided).
  • User Id - The ID of the Discord user to send the direct message to.
  • Message Text - The text content of the message to send.

Options

  • Bot Token - Discord bot token credential (optional if using Client ID from Connect node).
  • Reply Message Id - The message ID to reply to in the DM conversation.
  • Files - An array of file paths to attach to the message.
  • Embed - An embed object for rich content (structured formatted messages).
  • Buttons - An array of button objects to add interactive components.

Output

  • Message - The sent message object containing message details, ID, timestamp, and other metadata.

How It Works

The Send Direct Message node creates a DM channel with the user (if it doesn't exist) and sends a message to it. When executed, the node:

  1. Authenticates using either Client ID or direct bot token
  2. Validates the user ID and message text
  3. Creates or retrieves the DM channel with the specified user
  4. Constructs the message with optional components (files, embeds, buttons)
  5. Processes file attachments if provided
  6. Sends the message to the DM channel
  7. Returns the complete message object

Requirements

  • Active Discord bot session (Client ID) or bot token credentials
  • Valid user ID (the bot and user must share at least one server)
  • User must have DMs enabled and not have the bot blocked

Error Handling

The node will return specific errors in the following cases:

  • ErrInvalidArg - Client ID or bot token missing/invalid
  • ErrInvalidArg - User ID is empty
  • ErrInvalidArg - Message text is empty
  • ErrInternal - File processing errors
  • ErrInternal - Invalid embed or button structure
  • Discord API errors (user has DMs disabled, bot is blocked, etc.)

Direct Message Limitations

  • Users can disable DMs from server members in their privacy settings
  • Users can block your bot, preventing DMs
  • The bot and user must share at least one mutual server
  • Users may have DMs from non-friends disabled
  • First-time DMs may be caught in user's message request inbox

File Attachments

Same as Send Channel Message - accepts an array of file paths:

["/path/to/file.pdf", "/path/to/image.png"]

Embed Objects

Same format as Send Channel Message. Example:

{
"title": "Welcome Message",
"description": "Thank you for joining our server!",
"color": 3447003,
"fields": [
{
"name": "Next Steps",
"value": "Please read the rules in #rules channel"
}
]
}

Button Components

Same format as Send Channel Message:

[
{
"Label": "Accept",
"Style": 3,
"CustomID": "accept_terms"
}
]

Example: Welcome DM

Inputs:

  • User Id: "123456789012345678"
  • Message Text: "Welcome to our server!"
  • Embed:
{
"title": "Getting Started",
"description": "Here's what you need to know...",
"color": 5763719
}

Result: A rich welcome message sent to the user's DMs.

Example: Notification with File

Inputs:

  • User Id: "123456789012345678"
  • Message Text: "Your report is ready:"
  • Files: ["/reports/user-report.pdf"]

Result: DM with attached report file.

Example: Interactive DM

Inputs:

  • User Id: "123456789012345678"
  • Message Text: "Do you want to continue?"
  • Buttons:
[
{"Label": "Yes", "Style": 3, "CustomID": "dm_yes"},
{"Label": "No", "Style": 4, "CustomID": "dm_no"}
]

Result: DM with interactive buttons (use Interaction In node to handle clicks).

Use Cases

  • Welcome messages - Greet new server members privately
  • Notifications - Send personalized alerts and updates
  • Reports - Deliver generated reports or documents
  • Verification - Send verification codes or instructions
  • Moderation - Privately contact users about rule violations
  • Support - Provide one-on-one customer support
  • Reminders - Send scheduled reminders to users

Privacy Considerations

  • Respect user privacy - only DM when necessary
  • Provide opt-out options for automated DMs
  • Don't spam users with excessive messages
  • Be transparent about why the bot is DMing them
  • Consider rate limiting DMs to avoid being flagged as spam

Tips and Best Practices

  • Handle DM failures gracefully - Not all users accept DMs
  • Inform users - Let them know they'll receive a DM
  • Be concise - Keep DMs short and to the point
  • Test first - Send a test DM to yourself before automating
  • Rate limiting - Don't send too many DMs too quickly
  • Error handling - Catch errors when users have DMs disabled
  • Alternative channels - Have a fallback if DMs fail (e.g., channel ping)