Quick Start Guide

This guide will walk you through setting up and running your first webhook in just a few minutes using Docker Compose.

Step 1: Create a Scripts Directory

Webhookd executes scripts from a specified directory. First, create a directory to hold your webhook scripts.

mkdir -p scripts

Now, create a simple "Hello World" script inside this directory. Let's call it hello.sh.

File: scripts/hello.sh

#!/bin/bash

# Get the 'name' parameter from the query string, with a default value.
NAME=${name:-World}

echo "Hello, $NAME!"
echo "This webhook was triggered with method: $hook_method"
echo "The unique hook ID is: $hook_id"

Make sure the script is executable:

chmod +x scripts/hello.sh

Step 2: Create a docker-compose.yml File

Docker Compose is the easiest way to run webhookd locally. Create a docker-compose.yml file in the same directory where you created the scripts folder.

File: docker-compose.yml

version: "3.6"

services:
  webhookd:
    image: ncarlier/webhookd:latest
    container_name: webhookd
    restart: always
    ports:
      - "8080:8080"
    # This environment variable tells webhookd where to find the scripts.
    environment:
      - WHD_HOOK_SCRIPTS=/scripts
    # This volume mounts your local scripts directory into the container.
    volumes:
      - ./scripts:/scripts

Step 3: Start Webhookd

With the docker-compose.yml file in place, start the server:

docker-compose up -d

Webhookd is now running and listening for requests on port 8080.

Step 4: Trigger Your Webhook

Your script scripts/hello.sh is now available at the URL http://localhost:8080/hello.

You can trigger it using curl:

Basic Call:

curl http://localhost:8080/hello

Expected Output:

Hello, World!
This webhook was triggered with method: GET
The unique hook ID is: 1

Call with a Parameter:

Let's pass a name parameter in the URL query string.

curl "http://localhost:8080/hello?name=Alice"

Expected Output:

Hello, Alice!
This webhook was triggered with method: GET
The unique hook ID is: 2

Congratulations! You have successfully set up and triggered your first webhook with Webhookd.