Read Discord Bot DMs in n8n

How can I the Discord node in n8n to Read DMs that were sent to a bot?

1 Like

Hi @leoschaa Welcome!
For reading DMs you cannot use discord node you need to use HTTP node like:

As you are aware that built in node does not have a native DMs working trigger.

@leoschaa Right, the Discord node only handles things like sending messages and reacting to server events. For DMs to your bot, you need the HTTP Request node hitting Discord’s API directly.

Here’s how to set it up:

To read DMs (get DM channel messages):

First you need the DM channel ID. Discord doesn’t let you poll “all DMs” – you either already know the user’s ID, or you’re receiving events via a webhook.

Option 1: Trigger-based (recommended)

Set up a Discord bot with a message intent and use n8n’s Webhook trigger node. When someone sends your bot a DM, Discord pushes an event to your webhook. This is the only reliable real-time approach.

  • In your Discord Developer Portal, enable “Message Content Intent” and “Direct Messages” gateway intents
  • Set your bot’s interactions endpoint URL to your n8n webhook URL
  • n8n receives the event payload with channel_id, author, content, etc.

Option 2: Polling (manual)

If you already know the channel ID of a DM conversation:

HTTP Request node:

  • Method: GET
  • URL: https://discord.com/api/v10/channels/CHANNEL_ID/messages
  • Header: Authorization: Bot YOUR_BOT_TOKEN
  • Query param: limit: 10

The tricky part is getting the DM channel ID. You can open it via POST /users/@me/channels with the target user’s ID if you have it.

What’s your use case – are you trying to receive DMs reactively, or poll them on a schedule?

I basically wanna post a request in a channel, then wait a set time and read out all dms with a specific key word (which i guess is not a problem its just about reading all dms not from a specific person).

thanks!

@leoschaa for that you need to setup a discord node to send a message to channel, then a wait node for some buffer, then an HTTP request node for “GET https://discord.com/api/v10/channels/{dm_channel_id}/messages” to fetch all direct messages, then you need to filter those by some keywords.

Yeah, but i dont know the users than will write me, so i cant use a specific ID no?

@leoschaa in that case where you cannot specify which user can message, we need to consider using the Triggers, so now enable “Message Content Intent” and “Direct Messages” gateway intents in your discord developer portal , so now you can point your main bot’s interaction end point to a n8n webhook so that your flow can get triggered, and from there just filter what you need to process further, like this is a pattern which i think would work the best you can also directly route those users to the webhook also.

Could you provide an example for me maybe? Im quite new to this, I also would use the incoming message as a trigger, i hope that would work too

1 Like

Yeah, that approach makes sense. You’ll post the message, wait, then hit the Discord API via HTTP Request to fetch DMs matching your keyword. Just make sure the HTTP node’s Authorization header has your bot token and you’re hitting the right dm channel ID. Should work fine with the workflow @Anshul_Namdev outlined.

1 Like

Hi @leoschaa I cannot find the exact example but some of these below could help you:

This sadly does not help me - it goes through every user if i understand correctly. The flows dont read out dms that have been received

@leoschaa as i said there is no perfect template, you gotta be the first one to build that, you can start trying to build it yourself and if you need help community is for you!

Okay so I got it to work through a node.js running through render.com. It reads Out all dms received - for my purposes I only need to reply instantly so its fine. For other purposes I thought about appending the data to a google sheet. This sheets can then be called in other workflows, and the dms can be sorted via timeframes or content

1 Like

Nice, that’s a solid workaround! Using a Node.js service on Render as a proxy to capture the DMs makes sense when the native bot integration isn’t cutting it. The Google Sheets buffer pattern is clever too — keeps ingestion separate from processing and makes the data reusable across different workflows. Thanks for sharing how you solved it!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.