Skip to main content

Webhook Handler Template

Receive webhooks from external services, process the data, and send immediate responses. Perfect for integrating with third-party platforms like Stripe, GitHub, or Shopify.

Time to build: 10 minutes Difficulty: Beginner Perfect for: API integrations, event processing, external notifications


What It Does

External service sends webhook → Process data → Validate → Send response

Handles real-time events from external services with validation and error handling.


Step-by-Step

1. Create Workflow with Webhook Trigger

  • New workflow → Name it "Webhook Handler"
  • Set trigger to Webhook
  • Copy webhook URL (you'll need this)

2. Add Condition for Validation

  • Drag Condition Block
  • Connect Webhook to Condition
Condition: <webhook.headers.authorization> == "Bearer your-secret-key"

If True: Continue processing
If False: Send error response

3. Add Agent for Processing

  • Drag Agent Block on True path
  • Connect Condition (True) to Agent
Model: GPT-4o-mini (fast and cheap)

System Prompt:
"Extract key information from this webhook payload and summarize it."

User Prompt: <webhook.body>

4. Add Response (Success)

  • Drag Response Block
  • Connect Agent to Response
{
"status": "success",
"processed": true,
"summary": "<agent.content>",
"timestamp": "<webhook.timestamp>"
}

5. Add Response (Error)

  • Drag another Response Block on False path
  • Connect Condition (False) to Response
{
"status": "error",
"message": "Unauthorized request",
"timestamp": "<webhook.timestamp>"
}

6. Test

  • Use Postman or curl to send test webhook
curl -X POST https://your-workflow-url \
-H "Authorization: Bearer your-secret-key" \
-H "Content-Type: application/json" \
-d '{"event": "test", "data": "sample"}'

Real-World Use Cases

E-commerce Order Processing

  • Shopify webhook → Validate order → Send to fulfillment system

Payment Processing

  • Stripe webhook → Verify payment → Update user account → Send receipt

GitHub Integration

  • Push event → Analyze changes → Post summary comment → Notify Slack

Enhancements

Add Database Logging

  • Add Database Query block to log all webhooks
  • Store payload, timestamp, processing status

Add Retry Logic

  • Use HTTP Request block to send to backup endpoint if primary fails
  • Store failed webhooks for manual review

Add Filtering

  • Add multiple Condition blocks to route different event types
  • Process payments differently than refunds

Cost

Per 1,000 webhooks:

  • GPT-4o-mini: ~$0.20-0.40
  • GPT-4o: ~$2-3
  • Claude 3.7 Haiku: ~$0.50-1.00
Next Step

Try the API Gateway template to add rate limiting and authentication!