Slack Botkit - How to get message content from 'react_added' event

I use the botkit framework to respond when a response is added to the message, but I'm not sure how to extract the contents of the message when the event fires. Below is what I have:

controller.on('reaction_added',function(bot, event) { if (event.reaction == 'x') { // bot reply with the message text } }); 

According to the Slack API, I can get data like event.item which has type, channel and ts messages. Does anyone know how to do this?

+6
source share
1 answer

Figured it out. Given the timestamp and the channel, I was able to manually find 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 }); } 
+6
source

All Articles