slack incoming webhook - send message to another channel

人盡茶涼 提交于 2019-12-31 02:01:44

问题


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.


回答1:


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:

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.)



来源:https://stackoverflow.com/questions/44225066/slack-incoming-webhook-send-message-to-another-channel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!