slack incoming webhook - send message to another channel

Viewed 3789

I am trying to post message to any channel in a slack team.

My webhook has been properly created and installed into my test team. As part of the install process, I selected "Post to #channel1"

When I review permissions, I see my app has been granted Other/Post to specific channels in Slack (#channel1).

From there, I am able to post into #channel1 with a basic JSON request:

{
    "text":"Hello, World!"
}

Now I want to validate I can use same webhook to post to any other channel of the same team. So I created a channel #channel2 and I try the following request:

{
    "channel":"#channel2",
    "text":"Hello, World!"
}

The request is accepted (HTTP Status 200) but it still publishes on #channel1.

What am I doing wrong ? Is that a syntax or permission issue ? I guess it is more a permission issue but I have not found how to grant my app access to additional channels (or all channels).

Regards.

2 Answers

I created an incoming Webhook, and I found this documentation (see image)

I followed the instructions given in that, and I found that it worked. I can send a message to a different channel than the one the Incoming Webhook was set for

Overriding Slack Channel in a webhook

Related