Slack slash 命令在 public 频道中不起作用,除非手动添加到它们
Slack slash command is not working in public channels unless manually added to them
我不确定要提供多少细节,但我会尽量把我认为相关的所有内容都放在一起。
我有一个斜线命令,我通过 AWS Lambda 和 API 网关执行一些逻辑。我正在使用 python slackclient module 并通过它使用 WebClient 将消息发送回松弛状态。澄清一下,我使用的是 Slack 提出的新机器人令牌系统,而不是 classic bot
那个。
据我了解,使用 webhook 在工作区的所有通道中发送消息非常痛苦,因为每个通道都提供了一个 webhook。因此,我使用 WebClient 与 Slack 交互并在 public 频道中发送消息。我面临的问题是,除非我将我的应用程序添加到频道,否则该命令不起作用。 Cloudwatch 日志显示事件进展顺利,正如我所看到的那样。我还使用 sys.exc_info()
:
看到了以下日志
(<class 'slack.errors.SlackApiError'>, SlackApiError("The request to the Slack API failed.\nThe server responded with: {'ok': False, 'error': 'not_in_channel'}"), <traceback object at 0x7ff4a0dc32c0>)
基于此,在我看来,将消息发送回我未添加此应用程序的频道似乎不起作用,但我不确定 OAuth permissions/scopes 会是什么为此需要。我为机器人令牌启用了以下范围:
channels:read
chat:write
commands
根据我的理解,我不需要添加任何用户范围,因为我希望我的 app/bot 本身响应,而不是代表用户响应。
简而言之,我想要的行为是将此应用程序添加到我的工作区并立即让它回复斜杠命令,而不管斜杠命令是从哪个 public 频道调用的。
当前的行为是,当从任何通道调用斜杠命令时,应用程序能够从所有 public 通道获取事件数据,但它无法在调用命令的通道中发送消息,除非它在频道。
如有任何帮助,我们将不胜感激!
我向 Slack 发送了帮助消息,结果发现此功能尚不适用于新的精细机器人权限。根据 this Slack documentation:
Currently, your app must be a member of any channel it wishes to post messages to. To join a channel, request the channels:join scope and call the conversations.join method. However, apps will soon be able to post in any public channel, without gaining additional access to the channel, by requesting a new scope.
当 Slack 添加该功能时,这似乎不会成为问题。
对于从已弃用的 :bot 范围迁移应用程序的人,新范围现已准备就绪。
将 chat:write.public
添加到您的 Bot Token Scopes
,public 个频道将不再返回错误 not_in_channel
。
Good news: with two special scopes, you can gain those abilities by asking for them explicitly. Request the chat:write.public scope and chat:write.customize scope, respectively, to gain the ability post in all public channels and adjust your app's message authorship.
我不确定要提供多少细节,但我会尽量把我认为相关的所有内容都放在一起。
我有一个斜线命令,我通过 AWS Lambda 和 API 网关执行一些逻辑。我正在使用 python slackclient module 并通过它使用 WebClient 将消息发送回松弛状态。澄清一下,我使用的是 Slack 提出的新机器人令牌系统,而不是 classic bot
那个。
据我了解,使用 webhook 在工作区的所有通道中发送消息非常痛苦,因为每个通道都提供了一个 webhook。因此,我使用 WebClient 与 Slack 交互并在 public 频道中发送消息。我面临的问题是,除非我将我的应用程序添加到频道,否则该命令不起作用。 Cloudwatch 日志显示事件进展顺利,正如我所看到的那样。我还使用 sys.exc_info()
:
看到了以下日志
(<class 'slack.errors.SlackApiError'>, SlackApiError("The request to the Slack API failed.\nThe server responded with: {'ok': False, 'error': 'not_in_channel'}"), <traceback object at 0x7ff4a0dc32c0>)
基于此,在我看来,将消息发送回我未添加此应用程序的频道似乎不起作用,但我不确定 OAuth permissions/scopes 会是什么为此需要。我为机器人令牌启用了以下范围:
channels:read
chat:write
commands
根据我的理解,我不需要添加任何用户范围,因为我希望我的 app/bot 本身响应,而不是代表用户响应。
简而言之,我想要的行为是将此应用程序添加到我的工作区并立即让它回复斜杠命令,而不管斜杠命令是从哪个 public 频道调用的。
当前的行为是,当从任何通道调用斜杠命令时,应用程序能够从所有 public 通道获取事件数据,但它无法在调用命令的通道中发送消息,除非它在频道。
如有任何帮助,我们将不胜感激!
我向 Slack 发送了帮助消息,结果发现此功能尚不适用于新的精细机器人权限。根据 this Slack documentation:
Currently, your app must be a member of any channel it wishes to post messages to. To join a channel, request the channels:join scope and call the conversations.join method. However, apps will soon be able to post in any public channel, without gaining additional access to the channel, by requesting a new scope.
当 Slack 添加该功能时,这似乎不会成为问题。
对于从已弃用的 :bot 范围迁移应用程序的人,新范围现已准备就绪。
将 chat:write.public
添加到您的 Bot Token Scopes
,public 个频道将不再返回错误 not_in_channel
。
Good news: with two special scopes, you can gain those abilities by asking for them explicitly. Request the chat:write.public scope and chat:write.customize scope, respectively, to gain the ability post in all public channels and adjust your app's message authorship.