我有一个尝试发布到频道的节点应用程序,现在它曾经使用节点的slack库提供的WebClient来工作,现在却无法使用WebClient或RTM API来工作,因为两者都说令牌未经身份验证,但我添加了必需的范围。
// Initialize client-api using token from environment variables
const { WebClient } = require('@slack/client');
const token = process.env.SLACK_TOKEN;
const web = new WebClient(token);
web.chat.postMessage({
channel: conversationId,
text: "Some Messge",
"attachments": [
{
"text": "Hello World"
}
]
})
.then((res) => {
console.log('Message sent: ', res.ts);
})
.catch(console.error);