mrkaye97 / slackr

An R package for sending messages from R to Slack
https://matthewrkaye.com/slackr/
Other
307 stars 83 forks source link

Wanted to make a group chat between a bot and 3 people. Only getting direct messages when I put usernames in channel. #176

Closed jrod20033 closed 2 years ago

jrod20033 commented 2 years ago

Is your feature request related to a problem? Please describe. slackr currently does not seem to support listing or sending messages to group DMs

Describe the solution you'd like Add a slackr_groups method, or allow slackr_ims to return group DMs in addition to person-to-person DMs

Describe alternatives you've considered N/A

jrod20033 commented 2 years ago

No issue, with the package. More of an idea. Was looking to send files to multiple people in a group message rather than in a channel.

mrkaye97 commented 2 years ago

Thanks for putting in this issue! As it stands right now, I do not believe slackr includes group DMs in either the slackr_ims or slackr_channels methods.

See here: https://github.com/mrkaye97/slackr/blob/master/R/slackr_utils.R#L16-L48

I believe that adding this functionality will be easy enough -- all it should take is passing mpim or im to list_channels. See Slack API docs on channel types

@jrod20033 if you're interested in putting in a fix for this issue, I'd gladly look it over 🙂. Otherwise, I'm happy to work on this in the next few days.

jrod20033 commented 2 years ago

I can take a look at it, but I don't think I understand enough to make a dent. Functions are not my strong suit. Let me know what you think

mrkaye97 commented 2 years ago

Sounds good. Let me know if you want to give it a shot or have any ideas, but no pressure! It should be quick enough for me to add :+1:

jrod20033 commented 2 years ago

To be more specific I'm trying to do it from the slackr_upload function.

mrkaye97 commented 2 years ago

To be more specific I'm trying to do it from the slackr_upload function.

Yep, that's fine. The underlying issue is that we need a way for you to be able to get the Slack ID for the DM group, which right now you can't access AFAICT. Then you should be able to pass that ID as the channel argument to any of the slackr functions

mrkaye97 commented 2 years ago

hey @jrod20033, circling back: You actually can accomplish what you want with slackr 3.2.0!. Here's how to do it:

  1. Invite your Slack app to your group DM with the /invite slash command. For instance, if your app is called SlackR, then you'll want to /invite and type SlackR when the text box comes up.
  2. Call slackr::list_channels(types = "mpim"), which will return a tibble of MPIM (multi-person instant messages) that your Slack app is part of.
  3. However you like (visually is fine), find the correct MPIM, and copy the channel ID (the channel column in the tibble) or save it to a variable
  4. Use the channel you just found as the channel argument in your slackr_upload call.

I'm going to close this issue out as it didn't require any changes, but let me know if you keep having issues!