Uncategorized

Webhook Manager – Dead Simple & Light Web Server to Trigger Actions on Your PC

Screenshot of Webhook Manager Main Menu

The Webhook Manager by IT Command is a simple, light, fast, and powerful tool.

Webhook Manager – Introduction

Being able to control your PC from other devices on, and even outside your network is a powerful tool for any power user. While services like Unified Remote and TriggerCMD can give you some options, they’re not quite as powerful and customizable as many of us would like.

Late last year, I stumbled across a lightweight tool by GitHub user Adnanh that allows one to host a simple server that listens for basic webbooks. This was exactly what I was looking for. It quickly launches a server written in go that can be accessed from within the network. It uses a negligible amount of resources, at least on my setup, which makes it a great alternative to a full web server.

However, I quickly found the config cumbersome and confusing. The documentation, although well made, is thick, and the lack of a simple GUI to see the server’s status and change settings on the fly kept me from recommending the tool to other users.

In my own quest for automation, I started working on a GUI written in batch that could manage webhook.exe for me. As it came along, I realized that it might be a helpful tool for other users if I added configuration options within the GUI. 2 months later and I had written my own code to add and remove JSON configuration.

Some Possible Uses

So what can you do with the tool? Well, quite a lot actually, and you don’t need to have any programming experience. A webhook is simply a URL you can visit which will perform an action. Lot’s of programs let you trigger webhooks; for example, if you use motioneye or motioneye-os to make home security cameras, you can optionally set the software to trigger a webhook whenever motion is detected. You could give it a webhook from this tool to run a program on your pc when this happens!

Webhook Manager webhook setup

Right now we’re looking at the webhook creation tool. We’ve chosen to give the webhook an ID of “example01” so this means whenever you visit http://localhost:944/hooks/example01 it will trigger whatever you set it to do. You can launch a file/program, and you can send any command-line output back to the browser that triggered it. You can also launch a program with custom parameters, or even just read a text file (such as a log) back to the browser that triggered the webhook. If you so desired, you could use this to host a dead-simple text only website.

By default, you have to launch the server manually via the main menu of the manager, but you can set it to launch on startup too!

Editing Launch Parameters

In the “Edit Parameters” menu you can change some awesome settings:

Hooks File – This file is the .json file that the webhooks are written in. See the examples above for help on that.
HTTPS – Set this to true if you want to use https when connecting to the webhooks. This will encrypt your data, however unless you have a valid https key file, most browsers will provide a warning that the connection is not secure. This is less important if you are using IOT devices or calling the webhook from a script.
HTTPS Key File – Set this to the location of the https key file. Only do so if you are using https.
Port – Here you can set the port the program listens on. The default is 9444, but you can set it to any port you would like.
Hot Reload – This option will tell the webhook host to automatically reload the webhooks when there is a change in the webhooks json file. Otherwise, when you change, remove, or add a webhook to the json file, you would have to stop and start the webhook program. This uses more resources, however, so only use this while testing things.

Webhook Manager – Testing and Self-Diagnostics

If you plan on calling webhooks from outside your local network, you will need to open ports in your router’s settings and forward them to your computer. Make sure your computer has a static IP address too! Webhook Manager works with both ipv4 and ipv6 external IP addresses.

When setting up outside access, it can be helpful to test it to make sure it is working. Webhook manager can run a test to see if you’re server is running properly. It also allows you to check a domain-based web address if you have a domain that forwards to your computer (you can set up one for free using dynu, which also has a super helpful program that checks if your provider has changed your external IP address and updates it for you, which they often do).

If, when you run the test, it looks like you do not have the ports forwarded, The webhook manager will provide a link to your router’s settings as well as instructions on how to set it up (note that you will need the administrator username and password for your router. In most homes, these are still set to the default, which you can look up online, and then you should change them).

The manager also performs some basic tests when you start and stop the server to make sure everything is working properly. It makes sure whatever ports you use aren’t blocked by your firewall, and the tool even tells you when an update is available!

Manually Writing Webhooks in JSON

While you don’t have to, you can also edit the webhooks directly with notepad or notepad++.

Adnanh/webhooks (the server itself) uses a .json config file. Here is an example file:

  
[
{
"id": "example-launcher",
"execute-command": "example.bat",
"command-working-directory": "G:\\Example\\Path\\To\\Files\\Folder",
"response-message": "Example Triggered.",
},
{
"id": "PassToBatch",
"execute-command": "example.bat",
"command-working-directory": "G:\\Example\\Path\\To\\Files\\Folder",
"response-message": "Passed Parameter.",
"pass-arguments-to-command": [
{
"source": "url",
"name": "parameter",
},
],
},
{
"id": "Internal-Ping",
"response-message": "Pong OK.",
"execute-command": "DummyCommand.bat",
},
]

Let’s look at these pieces individually.

First, look at this chunk:

{
"id": "example-launcher",
"execute-command": "example.bat",
"command-working-directory": "G:\\Example\\Path\\To\\Files\\Folder",
"response-message": "Example Triggered.",
},

This is a very simple webhook. When you go to the url http://localhost:944/hooks/example-launcher it will run the file example.bat located in G:\Example\Path\To\Files\Folder. It will also display the text Example Triggered on the web browser it was triggered with.


{
"id": "PassToBatch",
"execute-command": "example.bat",
"command-working-directory": "G:\\Example\\Path\\To\\Files\\Folder",
"response-message": "Passed Parameter.",
"pass-arguments-to-command": [
{
"source": "url",
"name": "parameter",
},
],
},

This Chunk does something very similar. However, this webhook also accepts parameters. In this example, you can go to the url http://localhost:9444/hooks/PassToBatch?parameter=12345 and the batch file example.bat would receive the parameter 1234. This is where the webhook program gets really powerful.


Also note:

{
"id": "Internal-Ping",
"response-message": "Pong OK.",
"execute-command": "DummyCommand.bat",
},

The Internal-Ping webhook MUST be included in any webhook json file you use (where you create the webhooks) or the Webhook-Manager program will not work properly. This is because the Webhook Manager tool tests its status by using the internal-ping webhook.

Don’t worry, the included editor wont let you remove it, so unless youre editing the code yourself you can ignore this fact!

And That’s Webhook Manager!

The webhooks server is a really powerful tool, and it’s my hope that my GUI wrapper will help make it more accessible to the average user. Download it and check it out! It’s 100% open source, free, and portable. It does not require an installation or admin access unless you use it to open firewall ports.

Thanks for reading! Star it on GitHub and leave a comment! Got any issues? Please let me know by creating a new issue on GitHub

One thought on “Webhook Manager – Dead Simple & Light Web Server to Trigger Actions on Your PC

  1. To anyone who downloaded this before 7:09 PM, there was a bug that made it crash when trying to stop the server. It still stopped it, but didnt stop the log window. This was because of some issues with the implimentation of CMDS, since it uses the window title which is overrridden by webhook.exe while its running (so CMDS must close the log window AFTER webhook.exe is stopped)

    Anyways, all fixed with v1.8.9 now so enjoy

Leave a Reply