I’m an avid Hacker News consumer. It’s one of the first places I go in the morning and tend to visit it multiple times a day. It might as well be my default tab (though to be fair, I have something way cooler for that).
Recently, I noticed that YC has an open and official API for Hacker News so I set out to create a Slack bot (as a way to train myself for a product we’re working on).
This all took just a few hours and credit should all go to Slack’s great Events API that makes it so you don’t need to run a bot process at all times and enabled me to use StdLib alongside Botkit and put together a pretty decent experience.
The bot currently supports almost all the public functionality of the API (except for users). Here’s how to use them:
You can get the bot to get you multiple post types all at once by asking for the different post types right in one message!
@hackernewsbot get me jobs and top stories
Querying multiple post types
The bot cycles through all the commands that it sees and performs all of them and concatenates them in the same order. Since I asked it to get me jobs and top stories
, it’s showing the job postings first (since it showed up first in my text) and the top stories afterwards.
You can get the top stories (equivalent of going to the front page of HN).
@hackernewsbot top stories
Top Stories on Hacker News
It will show you the top stories whenever you say anything that contains the word top
.
You can get the latest posts (equivalent of posts in /newest on HN).
@hackernewsbot new stories
New Stories on Hacker News
It will show you the newest posts whenever you mention anything with the word new
in it.
You can get the latest Show HN posts (equivalent of /show on HN).
@hackernewsbot Show HNs
Show HN stories on Hacker News
It’ll get you the latest Show HNs whenever you mention the word show
.
It can show you the latest job postings on HN (equivalent of /jobs on HN)
@hackernewsbot jobs
Job postings on Hacker News
In the future, I’d like it support fetching posts by specific users (which the API supports) and potentially posting automatic notifications whenever a new post hits the front-page!
If you just want to install it to your Slack group, then go here.
If you want to read the code, here it is.