feat(slack): direct message via email, instead of id
See original GitHub issue💡 The Idea
Its possible to send dm via email:
msg='the text yall want to send'
user_id="$(curl -X GET -H "Authorization: Bearer $SLACK_TOKEN" \
-H 'Content-type: application/x-www-form-urlencoded' \
"https://slack.com/api/users.lookupByEmail?email=$EMAIL" | jq -r .user.id)"
channel_id="$(curl -X POST -H "Authorization: Bearer $SLACK_TOKEN" \
-H 'Content-type: application/x-www-form-urlencoded' \
"https://slack.com/api/im.open?user=$user_id" | jq -r .channel.id)"
curl -X POST -H "Authorization: Bearer $SLACK_TOKEN" \
-H 'Content-type: application/json' \
--data "$(jq -c -n --arg msg "${msg}" --arg channel "${channel_id}" '{"channel":$channel,"text": $msg}')" \
https://slack.com/api/chat.postMessage
Credit: https://stackoverflow.com/a/56975663/3797368
This is much more convenient way how to select users, instead of manually finding user`s id…
Thanks
🔨 Breaking Feature
breaking char @
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Send emails to Slack
Create an email address for a channel or direct message (DM), Set up a dedicated email address to send emails to that conversation,...
Read more >Understand direct messages - Slack
Direct messages (DMs) are smaller conversations in Slack that happen outside of channels. DMs work well for one-off conversations that don't require an...
Read more >Use Slack Connect to start a DM with someone at another ...
Click Start a DM. Enter the email address for the person you'd like to invite. Click Send Invitation. ; Select DM someone from...
Read more >chat.postMessage method - Slack API
This method posts a message to a public channel, private channel, or direct message/IM channel. Consider reviewing our message guidelines, especially if ...
Read more >Move from email to Slack
Step 3: Move communication into Slack · Work together on documents · Call attention to urgent items · Notify specific members · Craft...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Closing off this issue as content has been merged into the master branch now
I think this is a fantastic idea. It won’t have a breaking feature at all. It’s really easy to detect the difference between an email and a slack user id and an email. so the
@
wouldn’t cause an issue at all.However, it does create a little bit of overhead (as long as you’re aware of it). Slack limits your requests, so depending on how many notifications you’re sending, you’re generating an extra hit to the server unnecessarily each time. I can cache the lookups (after they’re made), but if you’re using the CLI or some kind of web/API service, the instance is destroyed once the message is sent.
Perhaps i could put to the console a Warning message (or INFO) message letting the user know the looked up ID and suggest they consider updating the URL to reflect that? Do you know what I mean?