简体   繁体   English

Slack API - 检索斜杠命令的队列

[英]Slack API - queue for retrieving slash commands

I am tasked with building a Slack slash command app in Python which will respond to incoming slash commands.我的任务是在 Python 中构建一个 Slack 斜线命令应用程序,它将响应传入的斜线命令。 However, for security reasons, I am not allowed to open the firewall for incoming webhooks from Slack.但是,出于安全原因,我不允许为来自 Slack 的传入 Webhook 打开防火墙。 Is there instead a way to check a queue of sent slash commands?有没有办法检查发送的斜杠命令队列?

For example, a user types "/myslashapp" in a specific channel.例如,用户在特定频道中键入“/myslashapp”。 My app will need to do something like call an endpoint every 30 seconds and check if the "/myslashapp" command was sent.我的应用程序需要执行一些操作,例如每 30 秒调用一次端点并检查是否发送了“/myslashapp”命令。 If it was, my app should trigger a Lambda function in AWS.如果是,我的应用程序应该在 AWS 中触发 Lambda 函数。

Based on reading the Slack API docs, I haven't found any way to do this other than perhaps the RTM API, though it seems like overkill and still requires an open socket.基于阅读 Slack API 文档,除了 RTM API 之外,我还没有找到任何方法可以做到这一点,尽管它看起来有点矫枉过正并且仍然需要一个打开的套接字。

No. The Slack API has no build-in support that allows you to pull requests after-the-fact from a queue instead of receiving them from Slack when they happen.不可以。Slack API 没有内置支持,允许您事后从队列中拉取请求,而不是在请求发生时从 Slack 接收它们。

The RTM API might work for you, because the connection to Slack is initiated from your side. RTM API 可能适合您,因为与 Slack 的连接是从您这边发起的。 So - provided you firewall allows it - would also work from within an intranet.所以 - 如果你的防火墙允许 - 也可以在内部网中工作。 However, you can not do slash commands with the RTM API or any of the other interesting interactive Slack features like buttons.但是,您不能使用 RTM API 或任何其他有趣的交互式 Slack 功能(如按钮)执行斜杠命令。 Only simple messages and events.只有简单的消息和事件。

You could implement your own bridging solution and pull from it.您可以实施自己的桥接解决方案并从中提取。 But I don't think that a pulling solution would work, because it creates a lot of latency for your app.但我不认为拉动解决方案会起作用,因为它会为您的应用程序带来很多延迟。 Users expect an immediate response to their slash command, not a delay of 30 secs or more.用户希望对他们的斜杠命令立即做出响应,而不是 30 秒或更长时间的延迟。

So in summary I think you only have two valid options:所以总而言之,我认为您只有两个有效的选择:

  • Host your app internally and use a secure VPN like ngrok to expose a public URL to your app.在内部托管您的应用程序并使用像ngrok这样的安全 VPN 向您的应用程序公开一个公共 URL。

  • Run your app on the Internet and let it have a secure connection to your Intranet for accessing internal data.在 Internet 上运行您的应用程序,并让它安全连接到您的 Intranet 以访问内部数据。 (similar to eg a shopping web site would work, that has a public app on the Internet, but also can transmit orders to the business applications on the companies Intranet.) (类似于例如一个购物网站,它在互联网上有一个公共应用程序,但也可以将订单传输到公司 Intranet 上的业务应用程序。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM