Ashima Arora
Ashima Arora

Reputation: 190

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.

Upvotes: 5

Views: 8673

Answers (2)

Anand
Anand

Reputation: 11

You can try multiple messages as attachements -> https://api.slack.com/reference/messaging/attachments

Upvotes: 1

Erik Kalkoken
Erik Kalkoken

Reputation: 32698

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.

Upvotes: 2

Related Questions