Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slack POST multiple messages to a channel at once

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.

like image 417
Ashima Arora Avatar asked Oct 28 '22 21:10

Ashima Arora


1 Answers

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.

like image 142
Erik Kalkoken Avatar answered Nov 15 '22 06:11

Erik Kalkoken