gpt4 book ai didi

javascript - Slack API Channel.history

转载 作者:行者123 更新时间:2023-11-30 12:03:45 24 4
gpt4 key购买 nike

我有两个从 NodeJS 文件到 slack 的 API 调用,通过 api 发布消息效果很好,但尝试获取 channel 历史记录返回 JSON { error: "channel_not_found", ok: false }

token 是硬编码的。

chat.js

Chat.sendMessage = function (text, callback) {
slack.api('chat.postMessage', {
text:text,
as_user:true,
channel:'#webhooksapi'
}, function(err, response){
callback(null,response);
});
}

//Getting error on this function
Chat.getMessage = function (channel, callback){
slack.api('channels.history', {
token:apiToken,
channel:'#webhooksapi'
}, function(err, response){
callback(null, response);
});
}

最佳答案

从 slack 运行 channels.history api 时,您需要传递 channel ID 而不是名称。所以在我的例子中 channel: 'C1234567890'

关于javascript - Slack API Channel.history,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35913542/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com