3

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 2

2

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

0

The app needs the chat:write:bot permission to post messages to other channels.

The permission can be added in Manage Apps → your app → OAuth & Permissions:

The default permission, and the permission necessary to post to other channels / users.

Reading Slack's own documentation, this was not obvious to me. (although it is mentioned under "Using the Web API" in the Intro to Messaging.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.