I'm using the botkit framework to respond when a reaction is added to a message but I'm not sure how to extract the message's content when the event is triggered. Below is what I currently have:
controller.on('reaction_added',function(bot, event) {
if (event.reaction == 'x') {
// bot reply with the message's text
}
});
According to the Slack API, I can only get data like event.item which has the type, channel, and ts of the message. Does anyone know how to accomplish this?
Figured it out. Given the timestamp and the channel, I was able to manually search for the message in the channel history and extract the data I needed.
function getTaskID(channel_id, timestamp, callback) {
slack.api("channels.history", {
channel: channel_id,
latest: timestamp,
count: 1,
inclusive: 1
}, function(err, response) {
// do something with the response
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With