Skip to content

AWS Lambda function to send the highest ranked HackerNews and Product Hunt news to Slack

License

Notifications You must be signed in to change notification settings

aurimasmick/slack-news-bot

Repository files navigation

Slack News Bot

Slack bot which posts highest ranked Hacker News and/or Product Hunt articles to Slack at a specific time each day. More information and step by step tutorial how to create bot can be found in this Medium post.

Alt text

Architecture

The architecture of this bot is very straightforward. AWS EventBridge runs on cron like schedule and triggers Lambda function at a set time. The Lambda queries Hacker News and/or Product Hunt API, filters top posts, formats text, and sends to the Slack channel. All AWS resources are deployed with Terraform.

Alt text

Technologies used

  • terraform-aws-lambda Terraform module to build Lambda package and provision AWS resources.
  • Python asyncio to query large number of URLs (Hacker News).
  • Python requests to query GraphQL API (Product Hunt).
  • pytest and Github Actions to run AWS Lambda unit tests.
  • Slack blocks to format messages.

Deployment

  • set up Slack channel to get token
  • create Product Hunt account to get Product Hunt API token (Optional)
  • create S3 bucket to store Terraform state and modify state.tf file
  • export secrets
export TF_VAR_slack_bot_token=XXX
export TF_VAR_ph_api_token=XXX
  • deploy with Terraform
terraform init
terraform plan
terraform apply

Check this Medium post for step by step guide.

Modify function

python3 -m venv venv
source venv/bin/activate
pip install -r src/slacknewsbot/requirements.txt

Run tests

make tests

Makefile functions

make deploy
make deploy-with-secrets-file

About

AWS Lambda function to send the highest ranked HackerNews and Product Hunt news to Slack

Resources

License

Stars

Watchers

Forks

Packages

No packages published