This is a simple POST endpoint the will send a message to slack if the posted object is for an email bounced because it violated spam protection.
This runs as an AWS Lambda function written in NodeJS triggered by an API Gateway POST request.
In order to deploy and run this you will require:
- An AWS account see: https://aws.amazon.com/premiumsupport/knowledge-center/create-and-activate-aws-account/
- NodeJS installed see: https://nodejs.org/en/download/
- Serverless framework installed see: https://www.serverless.com/framework/docs/getting-started
- A slack webhook URL see: https://api.slack.com/messaging/webhooks
After cloning or unzipping the application run npm install
and run the unit test: npm test
to make sure everything is installed ok.
To deploy the endpoint to AWS:
- Set the environment variable SLACK_WEBHOOK_URL with the URL of your Slack channel webhook.
- Run the serverless deployment command
serverless deploy --stage dev
which will return the AWS assigned URL for the POST request.
Use Postman, Insomnia or curl to test the endpoint, only messages with the Type SpamNotification should trigger the slack message.
- There is only one unit test that covers the simplest of cases, more tests need to be added to give close to complete coverage and test as many outcomes and problems as possible.
- Add some tidier input parsing and validation like Joi or other.
- Make the Slack message prettier.
- Map the API gateway URL domain with a custom branded domain. The URL would look something like(ish): https://api.honeybadger.com/slackSpamNotify