slacker
slacker copied to clipboard
A bot that notifies you on Slack whenever your company/product is mentioned on Hacker News. Powered by Vercel Functions & Upstash.

Hacker News Slack Bot
A bot that notifies you on Slack whenever your company/product is mentioned on Hacker News.

or deploy your own
Built With
- Vercel Functions for cron processes & event subscriptions via webhooks
- Hacker News API for pulling data
- Slack API for sending and unfurling messages
- Upstash for key-value storage (Redis) and cron scheduling (qStash).
How It Works
- Set up a cron schedule in Upstash (qStash) that pings our
/api/cron
endpoint once every 60 seconds. - Get the last checked HN post ID (
lastCheckedId
) and the list ofkeywords
to check against from Upstash. - Get the
latestPostId
using HN API'smaxitem
endpoint. Then, perform checks against each post betweenlastCheckedId
andlatestPostId
to see if they contain any of the delineatedkeywords
. - For each positive post, send its link to Slack using the
chat.postMessage
method. - Listen to the
link_shared
event at our/api/event
endpoint. Once an event occurs, send a POST request to Slack to unfurl the link using the chat.unfurl method.

One-Click Install
Here's a 90s video that walks you through the installation process, step-by-step.
You can click the button below to install the bot directly into your desired Slack workspace:
Once it's installed, create a channel to receive notifications in and start configuring the bot with the /configure
command.
Deploy Your Own
You can also deploy your own version of this bot using Vercel and Upstash. Note that while this is in early-access, some of these processes might change.
Prefer a video tutorial instead? Watch this video.
Step 1: Create Slack App + Secure Env Vars
- Navigate to api.slack.com/apps and click on "Create New App".
- Select "From scratch" and input
Hacker News Bot
as the name of your app. - Voilà! You've just created your Slack app. Here, you'll receive 3 values that will be used for your Vercel deployment in the next step:
-
Client ID: This is your App's unique public-facing ID that will be the value for the
NEXT_PUBLIC_SLACK_CLIENT_ID
env var. -
Signing Secret: This is the signing secret used to validate that requests are genuinely coming from Slack. It will be the value for the
SLACK_SIGNING_SECRET
env var. -
Verification Token: This is the verification token used to validate that requests are genuinely coming from Slack. It will be the value for the
SLACK_VERIFICATION_TOKEN
env var.
-
Client ID: This is your App's unique public-facing ID that will be the value for the
Step 2: Create Upstash Account
Go to console.upstash.com and create an account. You'll need it for the next step.
Afterwards copy the QSTASH_CURRENT_SIGNING_KEY
and QSTASH_NEXT_SIGNING_KEY
secrets from console.upstash.com/qstash. You'll need them in the next step.
Similar to the slack signing secret, these are used to verify the authenticity of scheduled requests coming from Upstash.
Step 3: Deploy to Vercel
You can deploy your bot to Vercel with one-click:
Be sure to include all 5 of the env vars above in your deployment.
When the project finishes deploying, get your project's domain (e.g. https://hacker-news-slack-bot-eight.vercel.app/
). You'll need it for the next step.
Step 4: Configuring Slack app
For your Slack app to be able to send/unfurl messages in your Slack workspace, we will need to configure a few things:
Step 4A: Configuring OAuth Scopes
-
From your Slack app home screen, select "OAuth & Permissions" from the sidebar (under "Features").
-
Scroll down to "Scopes", and add the following scopes under "Bot Token Scopes":
-
chat:write
-
chat:write.public
-
links:read
-
links:write
-
Step 4B: Configuring Event Subscriptions
- Now, select "Event Subscriptions" from the sidebar (under "Features").
- Toggle "Enable Events" to "ON".
- For the "Request URL" field, input your Vercel project's domain and append
/api/event
to it. The final URL should look something likehttps://hacker-news-slack-bot-eight.vercel.app/api/event
. - Scroll down to "Subscribe to bot events". Add the
link_shared
bot user event. - Do the same for `Subscribe to events on behalf of users".
- Under "App unfurl domains", add
news.ycombinator.com
. - Click on "Save Changes".
Step 4C: Configure Slash Commands
Select "Slash Commands" from the sidebar (under "Features"). Create the following commmand with its respective Request URLs (based on your Vercel project's domain):
- Command:
/configure
- Request URL:
https://[YOUR_VERCEL_PROJECT_DOMAIN]/api/cmd/configure
- Short Description: Configure your HN Slack Bot
Step 4D: Enable Interactivity
- Now, select "Interactivity & Shortcuts" from the sidebar (under "Features").
- Toggle "Interactivity" to "ON".
- For the "Request URL" field, input your Vercel project's domain and append
/api/response
to it. The final URL should look something likehttps://hacker-news-slack-bot-eight.vercel.app/api/response
. - Click on "Save Changes".
Step 4E: Install App to Slack Workspace + Get OAuth token
- Go to "Basic Information" (under "Settings").
- Under "Install your app", click on "Install to Workspace".
- You should receive a notification that your app has been installed in your Slack workspace.
- Go back to "OAuth & Permissions". Copy the value of "Bot User OAuth Token".
- Set it as the
SLACK_OAUTH_TOKEN
env var in your Vercel project. Here's a guide on how to do that. - Redeploy your Vercel project for the changes to take effect.
- To verify that this worked, go to any channel on your Slack workspace and send a Hacker News link. The link should now unfurl and show a nice preview (like the one above).
Step 5: Set Up Cron Processes in qStash
- Go to console.upstash.com/qstash and scroll down to the
Request Builder
. - Configure the endpoint URL as
https://[YOUR_VERCEL_PROJECT_DOMAIN]/api/cron
. - Select the type as
Scheduled
. - Configure the cron schedule as
* * * * *
(select the "day" dropdown and change it to "minute"). - Click on
Schedule
. - Go back to Slack and use the
/configure
slash command that you set up earlier to add keyewords to track + set the channel to receive notifications in. - You should now start receiving notifications whenever your keywords are mentioned on Hacker News.
Authors
This project was originally created by Steven Tey at Vercel, with contributions/feedback from:
- Guillermo Rauch (@rauchg) – Vercel
- Justin Ridgewell (@jridgewell) – Vercel
- Andrew Healey (@healeycodes) – Vercel
- Drew Bredvick (@dbredvick) – Vercel
- Lee Robinson (@leeerob) – Vercel
- Andreas Thomas (@chronark_) – Upstash
License
The MIT License.