0

I have a slack bot that is sending direct messages to users. I want to add a functionality that will delete the message automatically 10 minutes after it has been sent. Please help.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

1

There is an api that is used to delete chat messages :

https://api.slack.com/methods/chat.delete

For your use case, you need to capture the channel & timestamp details from the response of message that was sent. Once the message is sent, wait for required time and then call 'chat.delete' api to delete the message.

Suyash Gaur
  • 2,481
  • 2
  • 9
  • 22
  • I am using AWS lambda so how could I wait and use the chat.delete in AWS lambda as everything is instantaneous in aws lambda. – VIKAS DALAL Jun 27 '21 at 11:01
  • Can you use SQS queues ? you can add the message timestamp and channel id to the queue and execute it after scheduled time using another lambda. Check this : https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-delay-queues.html – Suyash Gaur Jun 27 '21 at 13:45
  • The maximum time limit to delay messages on sqs is 15 minutes only. What if I need to delay it by one hour? – VIKAS DALAL Jun 28 '21 at 04:42
  • Your question states 10 mins and I gave you an answer for that. Please mark it as ‘accepted answer’ if you find it useful. – Suyash Gaur Jun 28 '21 at 19:50