GitHub
Setting up GitHub webhook integration with Rocket.Chat gives you the ability to
Receive event notifications from GitHub directly in your specified Rocket.Chat room (Incoming WebHook)
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

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
This script will generate notifications for the following repository events:
Issue events (create, edit, close, reopen, assign, label, etc)
Issue comment events
Push events (singular and multiple commits)
GitHub Example Script 2
This script will generate notifications for the following repository events:
New and closed issue events
Comment events (issues only)
Push events (singular and multiple commits)
Save the settings
The Webhook URL and Token are generated after saving
Copy these credentials, they will be used later

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
URLandtokenyou copied from the Rocket.Chat settingSelect 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.

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
https://api.github.com/repos/User-Or-Org-Name/Repo-Namelikehttps://api.github.com/repos/RocketChat/Rocket.ChatEnable Scripts
Use this Script to listen for commands
pr ls,pr listandhelp
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.
Last updated