Slack POST multiple messages to a channel at once

此生再无相见时 提交于 2019-12-18 07:05:56

问题


I need to post multiple bot replies (responses determined dynamically) to the same channel. The obvious way seems to be to do an HTTP POST for each message in succession using this API method: https://api.slack.com/methods/chat.postMessage

Is there a way to send messages to Slack in bulk to post to the same channel? The order in which the messages get rendered need not be important for me.


回答1:


No, there is no bulk variant. So you basically need to build your own bulk message sender.

Keep in mind that there is a request limit of 1 message per second or your API requests will fail.

There also is a 3 seconds request time-out for many requests between Slack and your app. (e.g. for direct response to slash commands). So if your bot needs to send many messages you want to use an approach that allows you to send them asynchronously.

One solution to this problem that works very well for me is to use a messaging queue for all Slack messages sent from my bots.



来源:https://stackoverflow.com/questions/47892056/slack-post-multiple-messages-to-a-channel-at-once

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