How to send a message to Slack listening channels?

I am working on a weak application (scope, including bot and incoming webcams). I can send a message to a specific channel, but I do not know how to stop using the "& channel =" parameter and just send messages to the listening channels. Listening, I mean, when the application is installed, the user is asked where to send (channel or dm should be selected).

String postUrl = "https://slack.com/api/chat.postMessage?token=" + botAccessToken + "&as_user=false&channel=%23community&text=testing&username=CommunityQ"; 

Any hints would be helpful.

+5
source share
3 answers

I think you can’t: according to the official documentation of the official Slack API documentation, sending messages to all / several listening channels is not possible:

Incoming web recordings are output to the default channel and can only send message messages to one channel at a time. You can override the custom integrated customized channel by specifying the channel field in your JSON payload.

I interpret this as "there is always exactly one channel to which your message is sent to"

In addition, Slack restricts this channel override feature to Slack apps :

You cannot override the default username, icon, or feed for incoming webcams attached to Slack applications.

+7
source

As Michael mentioned in his answer, it is not possible to simultaneously send messages to multiple channels. You need to view them and complete a few queries.

+2
source

I think there is a little confusion here. I'm not sure if the inbound web host area makes the bot area impossible. This is how i see things

  • Or you want a small low-resolution application to be hosted on one channel and you would use the inbound area of ​​the web hosting
  • Or do you want an application that can ask questions to users, for example, which channels they would like to update, process answers, etc. Then you will use the area of ​​the bot, and the bot can post to any public channel

If you give a little more information about what you want to achieve, we may help you better.

0
source

Source: https://habr.com/ru/post/1241647/


All Articles