在Slack中获取DM消息的接收者
我有一个Slack应用程序,可以使用适当的用户和机器人示波器来听消息
事件(应用具有IM:read
and im:history
permissions im:除其他外,代表用户)。事件有效负载看起来像这样:
{"client_msg_id": "...",
"type": "message",
"text": "...",
"user": "<sender id>",
"ts": "...",
"team": "...",
"blocks": [...],
"channel": "D012345678 <example direct channel id>",
"event_ts": "...",
"channel_type": "im"}
有没有办法识别此消息的收件人ID?
- 我已经研究了
对话_members
api,并使用了事件有效载荷提供的channel_id。它抛出channel_not_found
错误。我尝试了使用该应用程序用户所在的实际私人频道进行的硬编码测试,并返回了预期的用户ID列表。因此,这个问题似乎与DM渠道有关。 - 尝试使用用户-ID代替频道ID 正如此评论所建议的。也没有工作。
任何帮助都将受到赞赏。
附加信息:
pip冻结| grep slack
slack-bolt==1.13.2
slack-sdk==3.16.1
I have a Slack App that listens to message
events with the appropriate user and bot scopes (The app has im:read
and im:history
permissions among others, on behalf of the user). The event payload looks like this:
{"client_msg_id": "...",
"type": "message",
"text": "...",
"user": "<sender id>",
"ts": "...",
"team": "...",
"blocks": [...],
"channel": "D012345678 <example direct channel id>",
"event_ts": "...",
"channel_type": "im"}
Is there a way to identify the recipient id of this message?
- I have looked into
conversations_members
API and used the channel_id provided by the event payload. It throws achannel_not_found
error. I tried a hardcoded test with an actual private channel that the user of the app is in, and it returned the list of user-ids as expected. So it seems like the issue is related to DM channels. - Tried to use the user-id instead of the channel id as this comment suggested. Didn't work either.
Any help is appreciated.
Additional info:
pip freeze | grep slack
slack-bolt==1.13.2
slack-sdk==3.16.1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于任何面临同一问题的人,我都要求Slackbolt Devs投入并这是他们的答案。。总而言之,
converty_members
Questuon中提到的是正确的起点。但是,如果您的用户和机器人令牌都具有im:读取
权限,则优先级是对机器人令牌。用用户令牌替换它,您应该没问题。在讨论链接中,更详细的答案。For anyone who is facing the same issue, I asked the SlackBolt devs to pitch in and here's their answer. . In summary,
conversation_members
mentioned in the questuon is the correct starting point. But if both your user and bot tokens haveim:read
permissions, the priority is to the bot token. Replace it with user token and you should be fine. More elaborate answer is in the discussion link.