Setting up GitHub webhook integration with Rocket.Chat gives you the ability to
  1. 1.
    Receive event notifications from GitHub directly in your specified Rocket.Chat room (Incoming WebHook)
  2. 2.
    Send commands to GitHub and optionally receive a response (Outgoing WebHook).
These events include and are not limited to:
  • Comments
  • Issues events
  • Pull Requests
  • Merge requests
  • Deployment events
  • Comments and discussions
  • Tags, label and branch actions
  • etc.
In configuring this integration, make sure your Rocket.Chat is publicly available on a URL.

GitHub Rocket.Chat Integration

We are going to see how to create both incoming and outgoing webhook integration between Rocket.Chat and GitHub.

Rocket.Chat Incoming webhook with GitHub

To configure an incoming webhook integration between GitHub and Rocket.Chat, you need to:
The following steps explain how to do this

Creating new GitHub webhook integration

  • Go to the Administration -> Workspace -> Integrations settings on your Rocket.Chat workspace
  • Switch to the Incoming tab and create a New Integration
  • Fill in the details of your webhook including the name of the webhook, the room to post into, the user to post as and enable it
Create new GitHub incoming webhook
  • Enable Scripts and paste any of the following example code into the Scripts box.
You can customize your webhook integration script to suit your desire as explained here.
GitHub Example Script 1
GitHub Example Script 2
  • Save the settings
  • The Webhook URL and Token are generated after saving
  • Copy these credentials, they will be used later
GitHub webhook url and token

GitHub Webhook Setting

After creating the new incoming webhook integration on Rocket.Chat, it is time to link it up with the GitHub repository.
  • Go to the GitHub project repository then navigate to Settings > Webhooks
  • Add webhook and fill in the URL and token you copied from the Rocket.Chat setting
  • Select the list of events you want to be notified on and Add webhook
    GitHub webhook setting
After successful configuration, you can test the Webhook with any event trigger and see the notification in your specified Rocket.Chat room.
GitHub webhook notifications

Rocket.Chat GitHub Outgoing Webhook

Sending outgoing webhooks only works on public repositories
  • Create a new Outgoing WebHook
  • Select the channel where you will use the commands and receive the responses
  • Set URLs as like
  • Enable Scripts
  • Use this Script to listen for commands pr ls, pr list and help
/* exported Script */
/* globals Store */
class Script {
prepare_outgoing_request({ request }) {
let match;
console.log('lastCmd', Store.get('lastCmd'));
match =^pr last$/);
if (match && Store.get('lastCmd')) { = Store.get('lastCmd');
match =^pr\s(ls|list)\s*(open|closed|all)?$/);
if (match) {
let u = request.url + '/pulls';
if (match[2]) {
u += '?state='+match[2];
return {
url: u,
headers: request.headers,
method: 'GET'
match =^help$/);
if (match) {
return {
message: {
text: [
'**GitHub commands**',
' pr ls|list [open|closed|all] List Pull Requests',
process_outgoing_response({ request, response }) {
var text = [];
response.content.forEach(function(pr) {
text.push('> '+pr.state+' [#'+pr.number+']('+pr.html_url+') - '+pr.title);
return {
content: {
text: text.join('\n'),
parseUrls: false
  • Save your integration

Customizing your integration scripts

The purpose of the integration script is to transform data in one format (the format provided by your incoming service, such as GitHub) into another format (the format expected by Rocket.Chat). Therefore, should you wish to customize either of the scripts presented above, you will need two resources:
Note that data comes into your script from GitHub as the request.content object.