7.2.3 Advanced Tutorials — Automation with Webhooks
This tutorial shows how to use webhooks to automate actions and integrate external systems with platform events. It assumes familiarity with webhooks, workflows, and basic API concepts.
Step 1: Identify Automation Events
Determine which platform events should trigger automation.
Common triggers:
Content state transitions
Survey completion
Message or conversation events
Scheduled task execution
Events should be specific and actionable.
Step 2: Configure Outbound Webhooks
Create an outbound webhook endpoint configuration with explicit subscriptions.
Configuration options:
Endpoint URL
Subscribed event types
Shared secret for verification
Only subscribed events are delivered.
Step 3: Define Payload Handling
Understand and validate the payload structure sent with each webhook.
Payload characteristics:
Event identifier
Timestamp
Versioned data object
Consumers should ignore unknown fields for forward compatibility.
Step 4: Implement Verification
Verify webhook authenticity before processing.
Verification steps:
Validate signature header
Compare against shared secret
Reject invalid requests
Example verification:
$signature = hash_hmac('sha256', $rawPayload, $secret); if (!hash_equals($signature, $request->header('X-Signature'))) { abort(401); }Step 5: Handle Idempotency
Ensure webhook consumers handle retries safely.
Idempotency practices:
Track processed event IDs
Ignore duplicate deliveries
Use deterministic handlers
Step 6: Trigger External Actions
After validation, execute the intended automation.
Examples:
Update external CRM
Trigger CI/CD pipeline
Send notifications
Automation should be non-blocking and resilient.
Step 7: Monitor and Recover
Monitor webhook deliveries and automation outcomes.
Monitoring signals:
Delivery failures
Processing latency
Error rates
Implement retry or compensation logic where appropriate.
Best Practices
Keep webhook automation focused and stateless. Avoid long-running logic in webhook handlers and always design for retries and partial failure.