Build a slack command to fetch GitHub open PRs for the team

  • How to create a slack app and command
  • How to build a node server and deploy it to Heroku
  • How to show response in slack nicely

Create slack command

  1. In, click Create New App button.
  2. Fill out the app name and slack workspace.
  3. Select Slash Commands in Add features and functionality section.
<!doctype html>
<h1>Example Domain</h1>
<p>This domain is established to be used for illustrative examples in documents. You may use this
domain in examples without prior coordination or asking for permission.</p>
<p><a href="">More information...</a></p>

Make NodeJs Server and deploy to Heroku

  • receive request sent from slack command
  • send request to GitHub to retrieve open pull requests
  • transform the GitHub response so that it can be nicely displayed in slack
  • return response to slack
  1. Set up NodeJs server with Express. The source code can be found here:
  2. Sign up for a Heroku user, and download the Heroku command line tool. This tutorial is quite helpful:
curl -X POST -H application/json" <node-server-url>
  • The GitHub api for searching open pull requests is pretty straightforward. You can only search pull requests for a certain user with extra conditions:${user}+is:open+type:pr
  • If we want to search for all the team members, we need to send multiple requests and use Promise.all to wait until all the requests are complete before we send back the response to slack.
  • To format the response for nice display in slack, we refer to attachment which allows rich content in the message.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store