Webhook
Overview
Section titled “Overview”The Webhook events provider allows your digital worker to receive HTTP webhooks from external services like GitHub, Stripe, Shopify, etc.
-
Configure Provider
answers.json {"events-webhook": {"enabled": true,"public_base_url": "https://your-domain.ngrok-free.app"}} -
Run Setup
Terminal window gtc setup --answers answers.json ./my-bundle -
Register Webhook
Use the generated webhook URL in your external service:
https://your-domain.com/events/webhook/{tenant}/{event_type}
Configuration Options
Section titled “Configuration Options”| Option | Required | Description |
|---|---|---|
enabled | Yes | Enable/disable provider |
public_base_url | Yes | Public URL for webhooks |
secret_header | No | Header name for signature validation |
secret_key | No | Secret key for signature validation |
Webhook URL Format
Section titled “Webhook URL Format”POST https://your-domain.com/events/webhook/{tenant}/{event_type}Example:
POST https://your-domain.com/events/webhook/demo/order.createdHandling Webhooks
Section titled “Handling Webhooks”Basic Handler
Section titled “Basic Handler”name: handle_webhookversion: "1.0"
nodes: - id: process type: script config: script: | let data = event.payload; // Process webhook data data next: respond
- id: respond type: http_response config: status: 200 body: success: true
triggers: - type: event event_type: "order.created" target: processGitHub Webhook
Section titled “GitHub Webhook”nodes: - id: check_event type: branch config: conditions: - expression: "headers['x-github-event'] == 'push'" next: handle_push - expression: "headers['x-github-event'] == 'pull_request'" next: handle_pr default: ignore
- id: handle_push type: script config: script: | let commits = event.payload.commits; format!("Received {} commits", commits.len())
triggers: - type: event event_type: "github" target: check_eventStripe Webhook
Section titled “Stripe Webhook”nodes: - id: handle_stripe type: branch config: conditions: - expression: "event.payload.type == 'payment_intent.succeeded'" next: payment_success - expression: "event.payload.type == 'payment_intent.failed'" next: payment_failed
triggers: - type: event event_type: "stripe" target: handle_stripeSignature Validation
Section titled “Signature Validation”HMAC Validation
Section titled “HMAC Validation”{ "events-webhook": { "enabled": true, "public_base_url": "https://your-domain.com", "signatures": { "github": { "header": "X-Hub-Signature-256", "algorithm": "sha256", "secret": "your-github-secret" }, "stripe": { "header": "Stripe-Signature", "algorithm": "stripe", "secret": "whsec_xxx" } } }}Response Handling
Section titled “Response Handling”Immediate Response
Section titled “Immediate Response”Most webhook providers expect a quick response:
- id: ack type: http_response config: status: 200 next: async_process # Process async after respondingAsync Processing
Section titled “Async Processing”For long-running tasks, acknowledge first:
nodes: - id: acknowledge type: http_response config: status: 202 body: message: "Processing" next: process_async
- id: process_async type: async config: flow: "process_webhook_data" payload: "{{event.payload}}"Testing Webhooks
Section titled “Testing Webhooks”Using curl
Section titled “Using curl”curl -X POST https://your-domain.com/events/webhook/demo/test \ -H "Content-Type: application/json" \ -d '{"message": "Hello from webhook"}'Using ngrok inspector
Section titled “Using ngrok inspector”ngrok http 8080# Visit http://localhost:4040 to inspect requestsTroubleshooting
Section titled “Troubleshooting”Webhook Not Received
Section titled “Webhook Not Received”- Check URL is correct
- Verify public URL is accessible
- Check firewall/security groups
- Review external service logs
Signature Validation Failed
Section titled “Signature Validation Failed”- Verify secret key matches
- Check header name is correct
- Ensure raw body is used for validation