I want my slack bot to edit the original message (basically modify it).To trigger bot i would like to use an emoticon.
so the flow would be user post the message -> if user wants to use bot press a reaction -> once bot is triggered modify or edit the message with the custom content of bot.
for trigger i think this the API i would need https://api.slack.com/methods/reactions.get but is this even possible?
The api you have mentioned is for fetching the reactions associated with a message/post.
What you actually need is an event to be captured when a reaction is added to the message.
Here is the api that solves the purpose: https://api.slack.com/events/reaction_added
You can now implement the business logic based on the event payload.
Sample Payload:
{
"type": "reaction_added",
"user": "U024BE7LH",
"reaction": "thumbsup",
"item_user": "U0G9QF9C6",
"item": {
"type": "message",
"channel": "C0G9QF9GZ",
"ts": "1360782400.498405"
},
"event_ts": "1360782804.083113"
}
To update the message, you can use chat.update
api:
https://api.slack.com/methods/chat.update
you'll need :
token: 'bot token' or 'user token' with required chat:write
scope
channel & timestamp details : you can find in payload of 'reaction_added' payload.
Note:
You cannot edit a message sent by another user, unless you have the 'User token'. https://api.slack.com/authentication/token-types#user