channel_not_found exception while sending the message through incoming webhook

prabhakar Reddy G picture prabhakar Reddy G · Jan 8, 2017 · Viewed 14k times · Source

Am using incoming webhooks to send messages, however am overiding the channelID to send to particular channel(as mentioned in here:https://api.slack.com/incoming-webhooks) by using something like this

   {
"channel": "#my_channel",
"text": "This message will appear in #other-channel"
  } 

Am able to receive messages into slack when i give my channelID, but when i give someone else channelID(valid channel ID), am getting channel_not_found exception.

Please let me know what might went wrong.

Answer

Erik Kalkoken picture Erik Kalkoken · Jan 8, 2017

Assuming you mean by "someone else channel ID" the ID of a private channel that someone else is a member of (but you are not) this is normal Slack behavior.

You can not send a message to a private channel that you (as the user that created the incoming webhook) are not a member of. In fact all private channels that you are not a member of are invisible to you and that behavior is the same for incoming webhook and the Slack API.

A workarounds around this feature that I have used is to create the incoming webhook with a special admin user (e.g. "Slack Admin") and make sure he is invited into all relevant private channels