Here is my code for setting topic channel and I receive {"ok":false,"error":"channel_not_found"}
while the channel exists and I tried to use channelId instead of using #channelName . but no difference. And the permissions are set correct.
JavaScript
x
21
21
1
function setTopic1() {
2
var topic = 'testing'
3
var url = 'https://xxxx.slack.com/api/conversations.setTopic'
4
var payload = {
5
'channel': '#temp-w',
6
'token': token,
7
'topic': topic,
8
};
9
10
var options = {
11
'method': 'post',
12
'payload': payload,
13
};
14
15
if (topic.length > 250) {
16
Logger.log("Topic is too long, API request might fail")
17
}
18
var response = UrlFetchApp.fetch(url,options);
19
Logger.log(response)
20
}`
21
Advertisement
Answer
I found what was the issue. First as we integrate bot to channel ,I also needed to invite @channelName. And in payload it would be correct instead of using #channelName to channelID. It didn’t work for me with channelName, it works with channelName when I posted message in channel but for set channel it works with channelId in payload