question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
caronccommented, Jan 10, 2021

Closing off this issue as content has been merged into the master branch now

1reaction
caronccommented, Jan 7, 2021

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found