Slack DM to a user not in `im.list`

孤者浪人 提交于 2019-12-07 01:48:43

问题


I'm implementing a slack ops bot that will notify users of job completion on a build server. It needs to be able to DM users on job completion.

I've setup a bot user as per the instructions @ https://api.slack.com/bot-users. To send a DM to a particular user, chat.postMessage takes the first argument (channel) as either a @username or a IM channel's ID as per the documentation @ https://api.slack.com/methods/chat.postMessage#channels . To get the IM channel ID of a user, im.list can be used. But im.list only gives the IM channel IDs of the users the bot has previously interacted with (or the user has pinged the bot or the bot and the user are part of any channel).

So it seems the bot cannot DM any user it hasn't previously interacted with. Is my understanding of the bot behavior correct ?

Is there any workaround for this use case ?


回答1:


I think you're looking for im.open. Pass in a user ID, and you'll get back a channel ID for the direct message conversation with that user.



来源:https://stackoverflow.com/questions/37598354/slack-dm-to-a-user-not-in-im-list

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!