I'm using the 'slack-node' npm package to build a simple Slack App for my team. The initialization of the bot works great so far. I got it to post a message to a channel after using a custom slash command. This message contains an interactive button, which after the user pressed on it, the message should update.
From my log:
// 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' }
I made sure I am passing the correct channel ID and message ts, i am 100% sure these parameters are correct since you only have to compare the response (objects).
This is the package I am using: https://www.npmjs.com/package/slack-node
Here is the code snippet I am using:
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);
});
}
}
I think the slack-node package uses the web-api from slack but not sure. According to Slack 'message_not_found' means No message exists with the requested timestamp, which is not true, the message is right there.
Does anyone had the same/similar problem before ? Thanks for any advice.