Discord Direct Messages

Hello all! First off, HA is amazing so far!

My question is around the Discord notification component. I have it all setup and working fine, posting to a #general in my server. What I’d really like is to the bot just DM me directly instead of posting in the channel ant [@] mentioning me so I get notified. I’ve tried all sorts of different channel IDs that I thought would work, including the channel ID for a DM between me and the bot, but no go. Anyone know if this is or isn’t possible, or have any suggestions on what else to try?

Thanks!

Hey there, did you find and answer to this one? Setting the target to a user id doesn’t seem to work.

I know this is an old thread, but has anyone ever figured this out? The documentation says:

This channel or user ID has to be used as the target when calling the notification service. Multiple channel or user IDs can be specified, across multiple servers or direct messages.

Yet when I supply a user ID as a target, the user does not receive the message and the HA log shows a warning:
2021-08-19 02:27:17 WARNING (MainThread) [homeassistant.components.discord.notify] Channel not found for ID: xxxxxxxxxxxxxxxxxx

I was finally able to figure it out by watching a discord coding example (How to make your Discord Bot tag people and roles | Two Minute Snippet - YouTube at 0:58) outside of HA and connected the dots.

Basically here is the code:

                  service_data:
                    message: 'Please come here <@UserID>'
                    target: 'ChannelID'

What got me was I needed to put the entire message string in single quotes. After you do this, HA does not show you the single quotes but it still works like a charm.

Hope this helps.

1 Like

You need to use the userid int from discord and target it the same as a channel. You can get userids by right clicking on a user with dev mode on in discord and clicking copy user id.