【发布时间】:2017-09-27 19:10:51
【问题描述】:
我正在使用“slack-node”npm 包为我的团队构建一个简单的 Slack 应用程序。到目前为止,机器人的初始化效果很好。在使用自定义斜杠命令后,我让它向频道发布消息。此消息包含一个交互式按钮,用户按下该按钮后,消息应更新。
来自我的日志:
// User uses /event slash command
18:48:50 UTC - - Received [POST] to path [/event]
// API response after posting the message
{ ok: true, message_ts: '1506538130.000343' }
// Incoming request after user pressed the button
18:49:32 UTC - - Received [POST] to path [/button_reply]
// Extracted channel id and message ts
C3PEQESP5 1506538130.000343
// respond after using chat.update
{ ok: false, error: 'message_not_found' }
我确保我传递了正确的通道 ID 和消息 ts,我 100% 确定这些参数是正确的,因为您只需比较响应(对象)。
这是我正在使用的包:https://www.npmjs.com/package/slack-node
这是我正在使用的代码 sn-p:
module.exports = {
postEphemeral : function(text, body, callback) {
slack.api('chat.postEphemeral', {
attachments:JSON.stringify(text.attachments) ,
channel:body.channel_id,
user:body.user_id
}, function(err, response){
console.log(response);
return callback(null);
});
},
updateMessage : function(text, body, callback) {
console.log(body.channel.id, body.message_ts)
slack.api('chat.update', {
attachments:JSON.stringify(text.attachments) ,
channel:body.channel.id,
ts:body.message_ts
}, function(err, response){
console.log(response);
return callback(null);
});
}
}
我认为 slack-node 包使用来自 slack 的 web-api 但不确定。根据 Slack 'message_not_found' 意味着不存在具有请求时间戳的消息,这是不正确的,消息就在那里。
以前有没有人遇到过同样/类似的问题? 感谢您的任何建议。
【问题讨论】: