2

My company has an internal Slack bot for creating and sending reports between departments. Currently, someone can create a report and then manually send it out to a department whenever they're ready. Both of these actions are handled through a simple Lambda function. However, we're running into issues with people forgetting to send reports later on.

I'm looking into a way to allow a user to pre-select a time they'd like a report to be sent out. I've looked at just creating a CloudWatch cron expression dynamically for each report based on that selected time, but that doesn't seem very scalable - what if multiple users want a report sent out at the same time?

Is something like polling an SQS queue more sustainable* or is there a better solution for handling dynamic scheduling of events?

*I'd hate to have to run the Lambda function every minute just to poll for messages.

Any suggestions are greatly appreciated!

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
Brady
  • 355
  • 1
  • 4
  • 10

1 Answers1

0

Here is a broad sketch of how to implement your requirement with Slack:

  • Add function to your Slack bot so user can enter due date for sending the report. e.g. with a Slack Dialog or drop down list of common options
  • Store the report infos with due date for sending in a database
  • Have a batch run over the database on a regular basis and send due reports

The batch can be a lambda function. And I would assume that you can also store persistent data with your lambda function, e.g. database.

To have your batch running on a regular basis, e.g. every 5 minutes you will need a CRON scheduler. A good one that I am using myself is cron-job.org. Works great for triggering apps via http request and they have a free plan.

I would not use a queue, since the reports will most likely not be in successive order for sending. So a database table, where you can query to only get the due ones works much better.

Erik Kalkoken
  • 30,467
  • 8
  • 79
  • 114