{"id":13479205,"url":"https://github.com/vercel-labs/slacker","last_synced_at":"2025-04-06T06:09:22.726Z","repository":{"id":49734513,"uuid":"515694353","full_name":"vercel-labs/slacker","owner":"vercel-labs","description":"A bot that notifies you on Slack whenever your company/product is mentioned on Hacker News. Powered by Vercel Functions \u0026 Upstash.","archived":false,"fork":false,"pushed_at":"2023-03-25T23:12:02.000Z","size":65383,"stargazers_count":356,"open_issues_count":5,"forks_count":43,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-30T04:11:10.510Z","etag":null,"topics":["cron","cron-jobs","hacker-news","redis","slack","upstash","vercel"],"latest_commit_sha":null,"homepage":"https://slacker.run","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vercel-labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-07-19T18:11:42.000Z","updated_at":"2025-03-03T02:35:10.000Z","dependencies_parsed_at":"2024-01-16T06:21:31.318Z","dependency_job_id":"bae17c9d-61e4-4674-8182-ce37164381fc","html_url":"https://github.com/vercel-labs/slacker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vercel-labs%2Fslacker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vercel-labs%2Fslacker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vercel-labs%2Fslacker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vercel-labs%2Fslacker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vercel-labs","download_url":"https://codeload.github.com/vercel-labs/slacker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247441052,"owners_count":20939239,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cron","cron-jobs","hacker-news","redis","slack","upstash","vercel"],"created_at":"2024-07-31T16:02:11.412Z","updated_at":"2025-04-06T06:09:22.691Z","avatar_url":"https://github.com/vercel-labs.png","language":"TypeScript","readme":"\u003cdiv align=\"center\"\u003e\n    \u003cimg alt=\"Slacker OG Image\" src=\"https://slacker.run/api/og?latest\"\u003e\n    \u003ch3 align=\"center\"\u003eSlacker\u003c/h3\u003e\n    \u003cp\u003eA bot that notifies you on Slack whenever your company/product is mentioned on Hacker News.\u003c/p\u003e\n    \u003cpicture\u003e\n        \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://user-images.githubusercontent.com/28986134/182243546-7687d077-280e-4c13-b96b-c6639c2a9e8e.png\"\u003e\n        \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://user-images.githubusercontent.com/28986134/182243511-a118223b-ebe2-4a07-a3d1-58d4a88d541e.png\"\u003e\n        \u003cimg alt=\"Demo\" src=\"https://user-images.githubusercontent.com/28986134/182243511-a118223b-ebe2-4a07-a3d1-58d4a88d541e.png\"\u003e\n    \u003c/picture\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://slack.com/oauth/v2/authorize?scope=chat:write,chat:write.public,links:read,links:write,commands,team:read\u0026client_id=12364000946.3845028209600\"\u003e\u003cimg alt=\"Add to Slack\" height=\"40\" width=\"139\" src=\"https://platform.slack-edge.com/img/add_to_slack@2x.png\" /\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"#deploy-your-own\"\u003e\u003cstrong\u003e\u003ci\u003eor deploy your own\u003c/i\u003e\u003c/strong\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cbr/\u003e\n\n## Built With\n\n1. [Vercel Functions](https://vercel.com/docs/concepts/functions) for [cron processes](https://github.com/vercel-labs/slacker/blob/main/pages/api/cron/index.ts) \u0026 [event subscriptions via webhooks](https://github.com/vercel-labs/slacker/blob/main/pages/api/event.ts)\n2. [Vercel Cron Jobs](https://vercel.com/docs/cron-jobs) for triggering cron processes.\n3. [Hacker News API](https://github.com/HackerNews/API) for [pulling data](https://github.com/vercel-labs/slacker/blob/main/lib/hn.ts)\n4. [Slack API](https://api.slack.com/docs) for [sending](https://github.com/vercel-labs/slacker/blob/main/lib/slack.ts#L47) and [unfurling](https://github.com/vercel-labs/slacker/blob/main/lib/slack.ts#L73) messages\n5. [Upstash](https://upstash.com) for key-value storage ([Redis](https://upstash.com/redis)).\n\n\u003cbr/\u003e\n\n## How It Works\n\n1. Set up a [Vercel cron job](https://vercel.com/docs/cron-jobs) that pings our [`/api/cron` endpoint](https://github.com/vercel-labs/slacker/blob/main/pages/api/cron/index.ts) once every 60 seconds.\n2. Get the last checked HN post ID ([`lastCheckedId`](https://github.com/vercel-labs/slacker/blob/main/lib/cron.ts#L11)) and the list of `keywords` to check against from Upstash.\n3. Get the `latestPostId` using HN API's [`maxitem`](https://github.com/HackerNews/API#max-item-id) endpoint. Then, perform checks against each post between `lastCheckedId` and `latestPostId` to see if they contain any of the delineated `keywords`.\n4. For each positive post, send its link to Slack using the [`chat.postMessage` method](https://api.slack.com/methods/chat.postMessage).\n5. Listen to the [`link_shared` event](https://api.slack.com/events/link_shared) at our `/api/event` endpoint. Once an event occurs, send a POST request to Slack to unfurl the link using the [chat.unfurl method](https://api.slack.com/methods/chat.unfurl).\n\n\u003cpicture\u003e\n   \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://user-images.githubusercontent.com/28986134/221011048-524226f6-b9aa-4f64-b39e-70267ed8eb37.png\"\u003e\n   \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://user-images.githubusercontent.com/28986134/221011121-c6f368b6-cbff-4b67-a0ee-ffc7986d9add.png\"\u003e\n   \u003cimg alt=\"Slacker Overview\" src=\"https://user-images.githubusercontent.com/28986134/221011121-c6f368b6-cbff-4b67-a0ee-ffc7986d9add.png\"\u003e\n\u003c/picture\u003e\n\n## One-Click Install\n\n\u003e Here's a [60s video](https://user-images.githubusercontent.com/28986134/221060512-df024fa3-594e-4e09-9d1e-656fae85f5c3.mp4) that walks you through the installation process, step-by-step.\n\nYou can click the button below to install the bot directly into your desired Slack workspace:\n\n\u003ca href=\"https://slack.com/oauth/v2/authorize?scope=chat:write,chat:write.public,links:read,links:write,commands,team:read\u0026client_id=12364000946.3845028209600\"\u003e\u003cimg alt=\"Add to Slack\" height=\"40\" width=\"139\" src=\"https://platform.slack-edge.com/img/add_to_slack@2x.png\" /\u003e\u003c/a\u003e\n\nOnce it's installed, create a channel to receive notifications in and start configuring the bot with the `/configure` command.\n\n\u003cbr/\u003e\n\n## Deploy Your Own\n\nYou 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.\n\n\u003e Prefer a video tutorial instead? Watch this [video](https://youtu.be/_F4VuVKJn0Q).\n\n### Step 1: Create Slack App + Secure Env Vars\n\n1. Navigate to [api.slack.com/apps](https://api.slack.com/apps) and click on \"Create New App\".\n2. Select \"From scratch\" and input `Hacker News Bot` as the name of your app.\n3. 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:\n   - **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.\n   - **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.\n   - **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.\n\n![CleanShot 2022-07-25 at 02 16 31](https://user-images.githubusercontent.com/28986134/180720201-816f985d-774b-41fe-8cf5-b87f730d77d2.png)\n\n### Step 2: Create Upstash Account\n\nGo to [console.upstash.com](https://console.upstash.com/login) and create an account. You'll need it for the next step.\n\n### Step 3: Deploy to Vercel\n\nYou can deploy your bot to Vercel with one-click:\n\n[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fvercel-labs%2Fslacker\u0026project-name=slacker\u0026repository-name=slacker\u0026env=NEXT_PUBLIC_SLACK_CLIENT_ID,SLACK_SIGNING_SECRET,SLACK_VERIFICATION_TOKEN\u0026envDescription=Read%20more%20about%20the%20required%20env%20vars%20here%3A\u0026envLink=https%3A%2F%2Fgithub.com%2F%2Fslacker%23deploy-your-own\u0026demo-title=Hacker%20News%20Slack%20Bot\u0026demo-description=A%20bot%20that%20monitors%20Hacker%20News%20for%20mentions%20of%20certain%20keywords%20and%20sends%20it%20to%20a%20Slack%20channel.\u0026demo-url=https%3A%2F%2Fhn-slack-bot.vercel.app%2F\u0026demo-image=https%3A%2F%2Fhn-slack-bot.vercel.app%2Fthumbnail.png\u0026integration-ids=oac_V3R1GIpkoJorr6fqyiwdhl17)\n\nBe sure to include all 5 of the env vars above in your deployment.\n\nWhen the project finishes deploying, get your project's domain (e.g. `https://slacker-eight.vercel.app/`). You'll need it for the next step.\n\n### Step 4: Configuring Slack app\n\nFor your Slack app to be able to send/unfurl messages in your Slack workspace, we will need to configure a few things:\n\n#### Step 4A: Configuring OAuth Scopes\n\n1. From your Slack app home screen, select \"OAuth \u0026 Permissions\" from the sidebar (under \"Features\").\n2. Scroll down to \"Scopes\", and add the following scopes under \"Bot Token Scopes\":\n\n   - `chat:write`\n   - `chat:write.public`\n   - `links:read`\n   - `links:write`\n\n   ![CleanShot 2022-07-25 at 13 49 18](https://user-images.githubusercontent.com/28986134/180852042-653ed883-1cb6-45fd-bb6b-1969fb3ea705.png)\n\n#### Step 4B: Configuring Event Subscriptions\n\n1. Now, select \"Event Subscriptions\" from the sidebar (under \"Features\").\n2. Toggle \"Enable Events\" to \"ON\".\n3. For the \"Request URL\" field, input your Vercel project's domain and append `/api/event` to it. The final URL should look something like `https://slacker-eight.vercel.app/api/event`.\n4. Scroll down to \"Subscribe to bot events\". Add the `link_shared` bot user event.\n5. Do the same for `Subscribe to events on behalf of users\".\n   ![Slack app configurations (1)](https://user-images.githubusercontent.com/28986134/180888217-911be4f9-be58-4f1c-a0bf-db915bbcb006.png)\n6. Under \"App unfurl domains\", add `news.ycombinator.com`.\n   ![Slack app configurations](https://user-images.githubusercontent.com/28986134/180942661-8c3821c5-d841-4d0c-b6a9-3e88e11baed7.png)\n7. Click on \"Save Changes\".\n\n#### Step 4C: Configure Slash Commands\n\nSelect \"Slash Commands\" from the sidebar (under \"Features\"). Create the following commmand with its respective Request URLs (based on your Vercel project's domain):\n\n- Command: `/configure`\n- Request URL: `https://[YOUR_VERCEL_PROJECT_DOMAIN]/api/cmd/configure`\n- Short Description: Configure your HN Slack Bot\n\n#### Step 4D: Enable Interactivity\n\n1. Now, select \"Interactivity \u0026 Shortcuts\" from the sidebar (under \"Features\").\n2. Toggle \"Interactivity\" to \"ON\".\n3. For the \"Request URL\" field, input your Vercel project's domain and append `/api/response` to it. The final URL should look something like `https://slacker-eight.vercel.app/api/response`.\n4. Click on \"Save Changes\".\n\n#### Step 4E: Install App to Slack Workspace + Get OAuth token\n\n1. Go to \"Basic Information\" (under \"Settings\").\n2. Under \"Install your app\", click on \"Install to Workspace\".\n3. You should receive a notification that your app has been installed in your Slack workspace.\n4. Go back to \"OAuth \u0026 Permissions\". Copy the value of \"Bot User OAuth Token\".\n   ![CleanShot 2022-07-25 at 18 28 46](https://user-images.githubusercontent.com/28986134/180891662-32c45dd7-18a1-4dd1-a729-e652bbdd42d6.png)\n5. Set it as the `SLACK_OAUTH_TOKEN` env var in your Vercel project. Here's a [guide](https://vercel.com/docs/concepts/projects/environment-variables) on how to do that.\n   \u003cpicture\u003e\n   \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://user-images.githubusercontent.com/28986134/180943047-59b23db2-affe-4a14-acc6-076244f68f06.png\"\u003e\n   \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://user-images.githubusercontent.com/28986134/180892017-510b87b6-5bc9-4262-ab10-32e5f7887ef9.png\"\u003e\n   \u003cimg alt=\"Add env var\" src=\"https://user-images.githubusercontent.com/28986134/180892017-510b87b6-5bc9-4262-ab10-32e5f7887ef9.png\"\u003e\n   \u003c/picture\u003e\n6. Redeploy your Vercel project for the changes to take effect.\n7. 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).\n\n\u003cbr/\u003e\n\n## Authors\n\nThis project was originally created by [Steven Tey](https://twitter.com/steventey) at [Vercel](https://vercel.com/), with contributions/feedback from:\n\n- Guillermo Rauch ([@rauchg](https://twitter.com/rauchg)) – [Vercel](https://vercel.com)\n- Justin Ridgewell ([@jridgewell](https://github.com/jridgewell)) – [Vercel](https://vercel.com)\n- Andrew Healey ([@healeycodes](https://github.com/healeycodes)) – [Vercel](https://vercel.com)\n- Drew Bredvick ([@dbredvick](https://twitter.com/dbredvick)) – [Vercel](https://vercel.com)\n- Lee Robinson ([@leeerob](https://twitter.com/leeerob)) – [Vercel](https://vercel.com)\n- Andreas Thomas ([@chronarkdotdev](https://twitter.com/chronarkdotdev)) – [Upstash](https://upstash.com)\n\n\u003cbr/\u003e\n\n## License\n\nThe MIT License.\n\n\u003cbr/\u003e\n\n\u003ca aria-label=\"Vercel logo\" href=\"https://vercel.com\"\u003e\n  \u003cimg src=\"https://badgen.net/badge/icon/Made%20by%20Vercel?icon=zeit\u0026label\u0026color=black\u0026labelColor=black\"\u003e\n\u003c/a\u003e\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvercel-labs%2Fslacker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvercel-labs%2Fslacker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvercel-labs%2Fslacker/lists"}