You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The script uses a JSON configuration file (default: `webhook_config.json`). If the file doesn't exist, a default one will be created automatically with these settings:
52
51
53
-
### Examples
54
-
55
-
Listen on port 9000:
56
-
```bash
57
-
python webhook_tester.py --port 9000
52
+
```json
53
+
{
54
+
"host": "localhost",
55
+
"port": 7999,
56
+
"secret": null,
57
+
"output_file": "webhooks.json",
58
+
"truncate_output": false,
59
+
"log_level": "INFO"
60
+
}
58
61
```
59
62
60
-
Listen on all interfaces:
61
-
```bash
62
-
python webhook_tester.py --host 0.0.0.0
63
-
```
63
+
You can customize:
64
+
-`host`: Host address to bind to
65
+
-`port`: Port to listen on
66
+
-`secret`: Shared secret for signature verification
67
+
-`output_file`: Path to save received webhooks
68
+
-`truncate_output`: Whether to clear the output file on startup
69
+
-`log_level`: Logging level (INFO, DEBUG, ERROR)
70
+
71
+
### Using a Custom Configuration
64
72
65
-
Configure a shared secret for signature verification:
To receive webhooks from external services, you'll need to expose your local server to the internet. You can use a tool like [ngrok](https://ngrok.com/):
79
+
To receive webhooks from external services, you'll need to expose your local server to the internet. You can use a tool like [localtunnel](https://theboroer.github.io/localtunnel-www/):
73
80
74
81
```bash
75
-
# Install ngrok if you haven't already
82
+
# Install localtunnel if you haven't already
83
+
npm install -g localtunnel
84
+
76
85
# Then expose your webhook tester
77
-
ngrok http 8000
86
+
lt --port 7999
78
87
```
79
88
80
-
Use the URL provided by ngrok as your webhook endpoint in the external service.
89
+
Use the URL provided by localtunnel as your webhook endpoint in the external service.
81
90
82
91
## Signature Verification
83
92
84
93
The webhook tester supports signature verification using HMAC-SHA256. To verify signatures:
85
94
86
-
1.Start the tester with the `--secret`option
95
+
1.Add a `secret`value in your configuration file
87
96
2. Ensure your webhook source is sending the following headers:
When a webhook is received, the following information is displayed (if verbose mode is enabled):
107
+
When a webhook is received, the following information is displayed:
99
108
109
+
- Webhook number and event type
100
110
- Timestamp when the webhook was received
111
+
- Signature verification result (if a secret is configured)
112
+
113
+
In DEBUG mode, additional information is shown:
101
114
- Request path
102
-
- Event type (from the `x-voltage-event` header)
103
115
- All request headers
104
116
- Full JSON payload
105
-
- Signature verification result (if applicable)
106
117
107
118
## Saving Webhook Data
108
119
109
-
When you stop the webhook tester (by pressing Ctrl+C), you'll see a summary of all received webhooks and be prompted to save them to a JSON file. This file can be used for later analysis or debugging.
110
-
111
-
## Example Output
112
-
113
-

114
-
115
-
120
+
Received webhooks are automatically saved to the configured output file in JSON format. Each webhook entry includes:
121
+
- Timestamp
122
+
- Path
123
+
- Headers
124
+
- Payload
125
+
- Signature details
126
+
- Event type
116
127
128
+
When you stop the webhook tester (by pressing Ctrl+C), you'll see a summary of all received webhooks during that session.
117
129
118
130
## Troubleshooting
119
131
120
-
-**No webhooks being displayed**: Make sure verbose mode is enabled
132
+
-**Need more detailed information**: Set `log_level` to `"DEBUG"` in your configuration
121
133
-**Signature verification fails**: Check that the shared secret matches between sender and receiver
122
-
-**Can't receive external webhooks**: Ensure your server is accessible from the internet (e.g., using ngrok)
134
+
-**Can't receive external webhooks**: Ensure your server is accessible from the internet (e.g., using localtunnel)
123
135
-**JSON parsing errors**: Ensure the webhook payload is valid JSON
136
+
-**Need to start fresh**: Set `truncate_output` to `true` in your configuration
0 commit comments