Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Direct messages #51

Closed
knagode opened this issue Jan 15, 2016 · 9 comments
Closed

Direct messages #51

knagode opened this issue Jan 15, 2016 · 9 comments

Comments

@knagode
Copy link

knagode commented Jan 15, 2016

Is it possible to send direct message as well with slack-notifier?

@stevenosloan
Copy link
Member

Yep! Just set the channel name w/ @ before the username. For example to notify me:

notifier.ping "ohaiii", channel: "@stevenosloan"

@knagode
Copy link
Author

knagode commented Jan 15, 2016

wow. Awesome. Thanks!

@ranle
Copy link

ranle commented Aug 19, 2018

Is this feature still working?
I tried sending a direct message to an existing username, but I'm getting this:

Slack::Notifier::APIError: The slack API returned an error: channel_not_found (HTTP Code 404)

This is the code I use:

slack = Slack::Notifier.new ENV['SLACK_WEBHOOK_URL'], username: 'Notifier'
slack.ping 'test', channel: '@ran'

@ranle
Copy link

ranle commented Aug 19, 2018

Ok, figured it out.
Each user has a unique member id.
Sending the message to @member-id works.
Sending it to @username does not work anymore.

See image.
image

@siegy22
Copy link
Contributor

siegy22 commented Aug 20, 2018

I can agree on the statement from @ranle, apparently with users which exist since beginning of 2017 or earlier, it works with the display name. With newer ones it doesn't work anymore.

@stevenosloan
Copy link
Member

Added a quick summary to the channel docs 4bf6582, please PR if that's unclear or missing anything 😅

@siegy22
Copy link
Contributor

siegy22 commented Sep 10, 2018

Thanks! @stevenosloan

@leandropessoa30
Copy link

leandropessoa30 commented Sep 10, 2018

@stevenosloan
Incredible, it would be even better if it were possible to read "slack" messages.

Thanks for sharing!

@krsyoung
Copy link

krsyoung commented Oct 18, 2018

Hi folks, thanks for documenting this update. Very helpful!

One clarification, when I created my Incoming WebHook I had to specify the channel it posts to. So when I try the above, no matter what uid I reference it posts to #general. @ranle did you do something special to create a webhook that can DM any user?

UPDATE
Ok, I think I am just confused.

I cannot get this to work if I'm using a WebHook associated with a App / Bot. No matter what I specify it ends up in #general (but sent as my Bot user). I think in this case the RTM API is needed.

I can get this to work if I add the "Incoming WebHooks" App to my workspace (provided by Slack). With this App I can override the default channel and specify a user with @uid but all messages come from "Slackbot".

Here is the SO post that helped me sort it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants