slackapi / node-slack-sdk

Slack Developer Kit for Node.js
https://tools.slack.dev/node-slack-sdk/
MIT License
3.28k stars 662 forks source link

Q: What determines which users are populated in dms? #21

Closed chrismo closed 9 years ago

chrismo commented 9 years ago

https://github.com/slackhq/node-slack-client/blob/master/src/client.coffee#L77-L79 I'm only seeing a few users in this list for a bot I'm working with. How are users added to this list?

chrismo commented 9 years ago

Through experimentation, it seems the user has to have DMed the bot first.

paulhammond commented 9 years ago

This is not well documented on our side - but yes, the dms list contains a list of existing DM channels - which in almost all cases are created when the user DMs the bot.

If there's no existing channel and the bot would like to create a DM with a user it can call the im.open web API method. In fact, they could even call this method when there is an existing DM, it'll do the right thing.

I'm closing this issue as I think you have all the information you need. If my description wasn't clear enough or I've missed something please feel free to reopen it!

chrismo commented 9 years ago

cool - hacking on a texas hold 'em game, where the bot deals the hole cards via DM, and since the player has to request a deal, would be nice if the bot could just DM them directly without the user having to have first established a dm channel.

(https://github.com/chrismo/hubot-poker/blob/master/js/card-poker/README.md)

paulhammond commented 9 years ago

Amazing! Please tell us (feedback@slack.com or @slackapi) when it's all working...

chrismo commented 9 years ago

it's working now :) needs a little love, have some open issues and needs more play testing - our LivingSocial team is too work focused (whatever) to help me suss out bugs, though a lot of the internals have been around for a while already and are fairly solid. i don't have an npm published package as I'm hoping the current owner of hubot-poker will lemme have that name - but a git reference in package.json for your bot will bring it in just fine.