There's not really much to understand:
1. Alertmanager makes a HTTP connection to your webhook. The only mandatory configuration is "url", which is the URL where to send the webhook request to.
2. The documentation then shows the format of the webhook payload (body) which your webhook server will receive.
Therefore, all you need to do is to write a small web server in any language of your choice, which receives the webhook request, and acts on it however you want.
If you google for "alertmanager webhook run script" then you'll get the following as the first three hits:
which in turn will link you to some ready-made solutions: