1

I am trying to implement the edit message functionality in slack using the Custom Bot App. If the user edits the message, the custom bot also edits its response. I am able to detect the message change event for user along with the ts of user's message but was not able to get the ts of bot's message which has to be edited.

Ishan
  • 81
  • 1
  • 1
  • 5
  • Could you please edit your question and add some of the code you've tried so far? – Adil B Jun 29 '18 at 18:05
  • I have not implemented any code for now. What I have is JSON of user's message from where i can get ts of user and when message change event occurs this ts is available as part of previous message JSON but there is no information available of the reply to this message. Is it needs to be done on our side like the user ts and bot ts be stored in db and then fetched accordingly or is there any other way to do this? – Ishan Jul 01 '18 at 14:44

1 Answers1

0

You can attempt to find your bot user's reply to an edited message by using the channels.history or conversations.history API methods to filter down messages by their timestamps and users.

Set the oldest API parameter to equal the ts of the edited user message and set the latest parameter to capture the time window when your bot replied to the non-threaded message. When you get the results back from this API call, search for the closest ts message from your bot by looking at the user field in the results.

This approach should work after you've experimented with the time window for the API call. However, for 100% accuracy you'll definitely want to store the user's ts and your bot's reply ts in a database.

Adil B
  • 14,635
  • 11
  • 60
  • 78
  • Thanks for the response Adil, In our case we will have a messaging queue that will be feeding messages to the Bot and Bot will be responding to the messages sent by multiple users. So storing the storing and retrieving data from db as well as making the api calls to get the data will add to Bot's response time. Is this the only option available? – Ishan Jul 09 '18 at 11:27
  • Since users can only edit their messages for 30 minutes after sending them, you'll at least have a good time bound for a potential message edit and should be able to regularly delete db rows that are older than 30 minutes, correct? How regularly will users be editing their own messages that the bot replied to? – Adil B Jul 09 '18 at 16:45