Build a Slack App to Assign GitHub Issues in 4 Steps with Node.js and StandardLibrary

GitHub issues are a fantastic tool to help manage software projects. Whether your repository is public or private, issues provide a great way to track tasks, enhancements, and of course, bugs. But, as we all know, Slack , is Where Work Happens. So it would be great if we could bring some of the functionality of GitHub issues into Slack, where many people are spending a lot of their time anyway.

This guide will walk you through setting up an API on Standard Library that receives messages from GitHub, when issues are created or closed. Those messages then get sent to Slack, where people in the channel can stay up to date on what’s happening, or assign a maintainer to the issue.


Build a Slack App to Assign GitHub Issues in 4 Steps with Node.js and Standard L ...

If you’re not familiar with Standard Library , we’re a serverless platform that enables everyone to build, ship, and integrate scalable APIs in a matter of seconds. With the help of our online development environment, Code on Standard Library, you build and deploy right from your browser.

Step 1: Create a SlackApp

Navigate to your Slack app dashboard , and click “ Create New App ” in the top-right corner of the screen. You should be redirected to a page labeled “ Basic Information ” shortly. On the left side of the screen, you’ll see “ Incoming Webhooks ” under the “ Features ” category.


Build a Slack App to Assign GitHub Issues in 4 Steps with Node.js and Standard L ...

Incoming webhooks are the easiest way to post messages into Slack, on a per channel basis. They give you a unique URL that can post messages on behalf of your bot into a specific channel. Outside of creating them, there is no authentication needed to post messages, so make sure you keep it a secret.


Build a Slack App to Assign GitHub Issues in 4 Steps with Node.js and Standard L ...

Enable incoming webhooks by clicking the toggle on the next screen. Scroll down to the section titled “ Webhook URLs for Your Workspace ” and click “ Add New Webhook to Workspace ”. Choose a channel and click “ Authorize ”.


Build a Slack App to Assign GitHub Issues in 4 Steps with Node.js and Standard L ...

Note the “ Webhook URL ”, because it will be needed in just a moment.

Step 2: Deploy the Issue BotAPI
Build a Slack App to Assign GitHub Issues in 4 Steps with Node.js and Standard L ...

With Slack all squared away, open up Code on Standard Library . If you click that link, a template for the issue-bot API will automatically open. If not, navigate to the “ Community API Sources ” tab and search for “ steve/issue-bot ”. Open to the env.json file, and you’ll find three variables. Enter the Slack webhook URL from Step 1 into SLACK_WEBHOOK_URL under the dev section.


Build a Slack App to Assign GitHub Issues in 4 Steps with Node.js and Standard L ...

Now hit cmd/ctrl + R to deploy your API. You’ll be greeted with a “ Parameter Error ”, because your functions/__main__.js endpoint requires three parameters. The three parameters, action , issue and, repository , will be provided by GitHub (for more on those, check out these docs ). Speaking of GitHub, you’ll want to take note of the “ API Endpoint URL ” for your API, which you’ll give to GitHub.


Build a Slack App to Assign GitHub Issues in 4 Steps with Node.js and Standard L ...
Step 3: Configure the GitHubWebhook

Head over to the GitHub repo that you want to forward issues from, and click the “ Settings ” tab on the far right of the screen. Once there, click the “ Webhooks ” section on the left side of the screen.


Build a Slack App to Assign GitHub Issues in 4 Steps with Node.js and Standard L ...

After clicking “ Add webhook ” in the top right, you’ll be prompted to fill out a form. For the first part, enter the “ API Endpoint URL ” from Step 2 as the “ Payload URL ”, and select “ application/json ” as the content type.


Build a Slack App to Assign GitHub Issues in 4 Steps with Node.js and Standard L ...

After scrolling down a bit, you can choose which events to forward to your webhook. Opt to select individual events, and make sure to check “ Issues ”.


Build a Slack App to Assign GitHub Issues in 4 Steps with Node.js and Standard L ...

Double check that the webhook is marked as “ Active” and click “ Add webhook ”. Now to test it out: head over to your GitHub repo and open an issue!


Build a Slack App to Assign GitHub Issues in 4 Steps with Node.js and Standard L ...

The user, repository, and issue elements are all links that will open their respective pages in the browser. As it stands, your API is also configured to forward when an issue is closed. Go back to GitHub and close the issue you just opened.


Build a Slack App to Assign GitHub Issues in 4 Steps with Node.js and Standard L ...
Step 4: Assigning Issues

So now your team is up to date with the happenings of one of your repos. The next logical step would be assigning a maintainer to that issue, from Slack. In order to enable interactive messages in Slack, you need to go back to the app dashboard and navigate to the section titled “ Interactive Components ”, under the “ Features ” category. Once enabled you need to configure the “ Request URL ”. This will be the same as the “ API Endpoint URL ” from Step 2, but with /assign/ added to the end. This will be the API endpoint that gets hit when a user assigns a maintainer.


Build a Slack App to Assign GitHub Issues in 4 Steps with Node.js and Standard L ...

The final step in Slack is to enable dynamic content. This will let the bot pre-populate a drop-down with a list of people eligible to be assigned to an issue. Scroll to the bottom of the “ Interactive Components ” page, to a section titled “ Message Menus ”. As the “ Options Load URL ” enter the “ API Endpoint URL ” from Step 2, with /assign/list/ added to the end.


Build a Slack App to Assign GitHub Issues in 4 Steps with Node.js and Standard L ...
With interactive components set up, there is still some work to do on GitHub’s end. Assigning an issue to someone will require making an authenticated API call to GitHub, so you need

本文前端(javascript)相关术语:javascript是什么意思 javascript下载 javascript权威指南 javascript基础教程 javascript 正则表达式 javascript设计模式 javascript高级程序设计 精通javascript javascript教程

代码区博客精选文章
分页:12
转载请注明
本文标题:Build a Slack App to Assign GitHub Issues in 4 Steps with Node.js and Standard L ...
本站链接:https://www.codesec.net/view/610881.html


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 前端(javascript) | 评论(0) | 阅读(59)