VirtuousAI

Webhook Integration

Receive and process webhooks from external services

Webhook Integration

Webhooks allow external services to notify VirtuousAI when events occur. This enables real-time integrations without polling.

Prerequisites

  • VirtuousAI account with CLI installed
  • Understanding of Automations
  • An external service that supports webhooks (Shopify, Stripe, etc.)

How Webhooks Work

  1. External service sends HTTP POST to your webhook URL
  2. VirtuousAI verifies the request signature
  3. The associated automation is triggered
  4. Actions execute with the webhook payload as input
  5. VirtuousAI responds with success/failure

Creating a Webhook Endpoint

Create an automation with a webhook trigger:

vai automations create \
  --name "Shopify Order Webhook" \
  --trigger-type webhook \
  --config '{
    "path": "shopify/orders",
    "secret": "whsec_your_secret_here",
    "action": {
      "kind": "insight_delegate",
      "definition": {
        "prompt": "Process this new order: {{payload}}"
      }
    }
  }'
curl -X POST https://vai-dev.virtuousai.com/api/v1/automations \
  -H "Authorization: Bearer $VAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Shopify Order Webhook",
    "triggerType": "webhook",
    "config": {
      "path": "shopify/orders",
      "secret": "whsec_your_secret_here",
      "action": {
        "kind": "insight_delegate",
        "definition": {
          "prompt": "Process this new order: {{payload}}"
        }
      }
    }
  }'

This creates a webhook endpoint at:

https://vai-dev.virtuousai.com/webhooks/{org_id}/shopify/orders

Configuring External Services

Shopify

  1. Go to SettingsNotificationsWebhooks
  2. Click Create webhook
  3. Select the event (e.g., Order creation)
  4. Enter your VirtuousAI webhook URL
  5. Set format to JSON

Stripe

stripe webhooks create \
  --url "https://vai-dev.virtuousai.com/webhooks/org_abc123/stripe/events" \
  --events checkout.session.completed,payment_intent.succeeded

GitHub

  1. Go to Repository SettingsWebhooks
  2. Click Add webhook
  3. Enter your VirtuousAI webhook URL
  4. Set content type to application/json
  5. Enter your webhook secret
  6. Select events to trigger

Webhook Security

Signature Verification

VirtuousAI verifies webhook signatures to ensure requests are authentic.

Configure the secret when creating the automation:

{
  "config": {
    "secret": "whsec_your_secret_here",
    "signatureHeader": "X-Shopify-Hmac-SHA256",
    "signatureAlgorithm": "sha256"
  }
}

IP Allowlisting

Restrict webhooks to specific IP addresses:

{
  "config": {
    "allowedIps": [
      "35.200.0.0/16",
      "13.225.0.0/16"
    ]
  }
}

Accessing Webhook Payload

The webhook payload is available in your action definition using template variables:

{
  "action": {
    "kind": "dlt_extract",
    "definition": {
      "source": "shopify",
      "resources": ["orders"],
      "filters": {
        "order_id": "{{payload.id}}"
      }
    }
  }
}

Available variables:

VariableDescription
{{payload}}Full webhook body (JSON)
{{payload.field}}Specific field from payload
{{headers.X-Header}}Request header value
{{query.param}}Query string parameter

Testing Webhooks

Local Testing

Use the CLI to simulate a webhook:

vai webhooks test auto_abc123 \
  --payload '{"id": "order_123", "total": 99.99}'

Debug Mode

Enable debug logging for webhook processing:

vai automations update auto_abc123 \
  --config '{"debug": true}'

View webhook logs:

vai events list \
  --resource-type automation \
  --resource-id auto_abc123 \
  --event-type webhook.*

Handling Failures

Retry Configuration

Configure automatic retries for failed webhook processing:

{
  "config": {
    "retries": {
      "enabled": true,
      "maxAttempts": 3,
      "backoffSeconds": [60, 300, 900]
    }
  }
}

Response Codes

CodeMeaningVirtuousAI Behavior
200SuccessMark as processed
202AcceptedMark as processing
4xxClient errorNo retry
5xxServer errorRetry if configured
TimeoutNo responseRetry if configured

Dead Letter Queue

Failed webhooks after all retries are sent to a dead letter queue:

vai webhooks dead-letter list --automation auto_abc123
# ID              RECEIVED           ERROR
# wh_abc123       2026-01-22 10:00   Action timeout
# wh_def456       2026-01-22 09:30   Rate limited

Replay a failed webhook:

vai webhooks replay wh_abc123

Rate Limiting

VirtuousAI applies rate limits to webhook endpoints:

TierRequests/minuteBurst
Free6010
Pro30050
EnterpriseCustomCustom

If you exceed rate limits, webhooks return 429 Too Many Requests. Configure your source to handle retries.

Monitoring

Webhook Metrics

View webhook statistics:

vai webhooks stats auto_abc123 --period 24h
# Total received: 1,234
# Successful: 1,200 (97.2%)
# Failed: 34 (2.8%)
# Avg latency: 245ms

Alerting

Set up alerts for webhook issues:

{
  "config": {
    "alerts": {
      "failureThreshold": 10,
      "failureWindow": "5m",
      "notifyUrl": "https://hooks.slack.com/..."
    }
  }
}

Next Steps

On this page