How to Trigger WebHooks without Events – Probot Github App

Github is a cloud-based software development website that uses Git as version control. Github is the brand ambassador of open source software development and gives developers the ability to collaborate on software development and host the source code as well. The code is hosted as the content of a repository. As the scope for Github increases, the Github apps have helped to reduce the complexity of software development, maintenance, and management.

Probot is a framework that allows to build Github Apps. It has a rich method library that can implement any GitHub event response. A webhook delivers data to other applications as it happens, in realtime. Github webhooks allows developers to build or set up integrations, which we’ll use, which subscribe to certain events on GitHub.com. When one of those events is triggered, Github sends an HTTP POST payload to the webhook’s configured URL.

Purpose: When testing and developing the app, one might want to trigger the same event multiple times to check the response. Probot provides a way to simulate these events using a probot receive command.

For this tutorial, a simple github app should be up and running. To know how to do this, check out Probot docs or article(s) on Geeksforgeeks.

Now that we have an app(or a bot, used interchangeably) up and running, we’ll see how to simulate the webhook reception.



Step 1: Run the app server locally.
npm-run-dev-initial-success-terminal

Step 2: Now, trigger an event on github that you want to simulate later on. To do this, you can make an issue(if you want to simulate this event’s webhook reception).
new-issue-opened-gh-interface

Step 3: After triggering the event, go to your app’s recent deliveries section. To navigate there, go to your app’s homepage(github.com/apps/app-name), then click on ‘Advanced’, there you will see the recent deliveries section.
recent-deliveries-page

Step 4: Click on the first delivery from the top. That is your event(a new issue opened here).
event-delivered-advanced-page

Step 5: Copy the entire ‘payload’ section and paste it into a file named issues.opened.json in test/fixtures directory.
file-saved-in-fixtures-dir

Step 6: Now, to simulate the ‘opening of an issue’ event, open a new terminal, navigate to app’s root directory.

Step 7: Run the command:

node_modules/.bin/probot receive -e issues -p test/fixtures/issues.opened.json ./index.js

command-fail-on-root-dir

Step 8: If the above command fails due to ‘not found file’ issues, go to ‘.bin’ folder and run the command from there.
went-to-node_module-bin-to-run-command

By following the above steps, you will have simulated the reception of a webhook.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.