Skip to main content

Webhooks

UniPulse handles both incoming webhooks (from external services) and outgoing webhooks (triggered by workflows).


Incoming Webhooks​

Sources​

SourceEventsVerificationProcessing Queue
Facebook/InstagramNew comments, messages, account updatesApp secret HMACwebhook-process -> ice-process
TikTokNew comments, account eventsSignature headerwebhook-process -> ice-process
StripePayment events (invoice.paid, subscription changes)Stripe signaturepayment-webhook
PaymobPayment result callbacksHMAC verificationpayment-webhook
ShopifyOrder created/updated, product changesShopify HMACwebhook-process -> ecommerce-sync / order-sync

Processing Flow​

Webhook Endpoint Pattern​

// apps/api/src/routes/webhook.routes.ts
router.post('/webhooks/stripe',
express.raw({ type: 'application/json' }), // Raw body for signature verification
webhookController.handleStripe
);

router.post('/webhooks/facebook',
webhookController.handleFacebook
);

router.post('/webhooks/shopify',
webhookController.handleShopify
);

Security: Signature Verification​

Every incoming webhook is verified using provider-specific signature validation before processing:

// Stripe
const event = stripe.webhooks.constructEvent(body, signature, STRIPE_WEBHOOK_SECRET);

// Facebook
const expectedSignature = crypto.createHmac('sha256', APP_SECRET).update(body).digest('hex');
if (signature !== `sha256=${expectedSignature}`) throw new Error('Invalid signature');

// Shopify
const generatedHash = crypto.createHmac('sha256', SHOPIFY_SECRET).update(body).digest('base64');
if (generatedHash !== shopifyHmac) throw new Error('Invalid signature');

Outgoing Webhooks​

Workflow Webhook Action​

Workflows can trigger outgoing HTTP requests to external services as one of the action node types:

Configuration​

In the workflow builder, users configure webhook action nodes with:

SettingDescription
URLTarget endpoint URL
MethodHTTP method (POST, PUT, PATCH)
HeadersCustom headers (for authentication)
Payload templateJSON template with variable interpolation
TimeoutRequest timeout in seconds
RetryNumber of retries on failure

Payload Template​

{
"event": "{{trigger.event}}",
"post": {
"id": "{{post.id}}",
"caption": "{{post.caption}}",
"platform": "{{post.platform}}",
"metrics": {
"likes": "{{post.metrics.likes}}",
"reach": "{{post.metrics.reach}}"
}
},
"workspace": "{{workspace.name}}",
"timestamp": "{{now}}"
}

Webhook Management API​

EndpointMethodDescription
/api/v1/webhooksGETList configured webhooks
/api/v1/webhooksPOSTCreate webhook configuration
/api/v1/webhooks/:idPATCHUpdate webhook
/api/v1/webhooks/:idDELETEDelete webhook

Webhook Logging​

All webhook activity is logged for debugging:

Incoming WebhooksOutgoing Webhooks
Logged in WebhookConversation modelLogged in WorkflowRun logs
Source, payload, processing statusURL, payload, response code, latency
Available in audit trailAvailable in workflow run history

Retry Strategy​

TypeStrategyMax Retries
Incoming (processing failure)Exponential backoff via BullMQ3
Outgoing (delivery failure)Exponential backoff3 (configurable per webhook)

Cross-Reference