It doesn’t take many lines to do something cool with Slack and AWS Lambda.
Simply put, you can generate an incoming webhook into Slack very easily (their documentation is straight forwards)
Incoming Webhooks are a simple way to post messages from external sources into Slack. They make use of normal HTTP…
In fact, they even end up giving you a curl command to test posting to slack.
This should tell you something.
It’s just an HTTP call.
And you can easily do that from AWS Lambda.
I’m trying to decide whether to share code, but to be honest, it’s relatively simple to do in pseudo code.
Pseudo code is:
- Get the data you want to use (could pass in as an event)
- Create the JSON payload
- Send the payload via HTTPS to the details given by slack (the https module is included in node of course)
- that’s it!
It can be done in a curl command as well, which means it’s simple.
It can be done in around 30 lines (50 lines is more readable with comments though)
What could you use it for?
We use it for reporting.
Simple, basic reporting.
We don’t have a reporting website.
We just report into a slack channel, and retrieve data if we need it based upon that information.
Easiest way to implement?
We implement from a DynamoDB Trigger.
On a Dynamo change (Insert, Update) you can trigger a Lambda function to run. Every time we receive a specific piece of data into the table, we run the function, and send that data into Slack.
You could do this with error reporting, support queries, high revenue moments…
We have found it’s really nice to know that our app is adding value to our users and are adapting the data we receive based upon that information.
No need to build a complex reporting system
And because you can provide buttons as part of the payload, you can provide opportunities to download the data you’ve just sent them.
I know this sounds odd, but I am all about simplicity and keeping down maintenance.
Maintaining a single slackbot and providing certain data from it to Slack with the ability to download the data from S3 (or however it’s done) if needs be, is remarkably simple.