Skip to main content
Webhook Actions run custom JavaScript whenever a Vitally Playbook fires. Zudo receives the webhook, executes your script, and updates account traits in Vitally — no separate integration required. Common use cases: auto-renewal date calculation, conditional trait updates, data transformations (e.g. days until renewal), and audit trail timestamps.

Setup

1

Create the action in Zudo

  1. Go to Settings → Connections.
  2. Find your Vitally connection and open it.
  3. Under Playbook Webhook Actions, click + Add Action.
  4. Fill in the fields:
    • Name — a descriptive label (e.g., “Auto-Renewal Handler”)
    • Description — what this action does (optional but recommended)
    • JavaScript Code — your custom logic (see Writing Your Script below)
    • Enabled — toggle to activate or deactivate the action
  5. Save the action.
2

Copy the webhook URL

After saving, each action gets a unique webhook URL. Click the copy button next to the action to copy it.The URL format is:
Keep this URL — you’ll paste it into Vitally in the next step.
3

Configure the Vitally Playbook

  1. In Vitally, create or open the Playbook you want to use.
  2. Add a Webhook action step.
  3. Paste your webhook URL into the URL field.
  4. Set your trigger conditions as needed.
  5. Activate the Playbook.
From this point on, every time the Playbook fires, Vitally will POST to your webhook URL and Zudo will run your script.

Writing Your Script

Your script runs in a secure JavaScript sandbox with two input objects. It must return either a trait update object or null.

Available Variables

account

The full Vitally account object, fetched fresh at the time the webhook fires. Use this for the latest trait values.

payload

The raw webhook payload sent by Vitally. It contains the playbook context and a snapshot of the account at the time of the trigger.
Important: The account object nests traits under account.traits.key, but the payload object puts traits directly on payload.match.account.key. When accessing the same trait from either source:
Use account when you need the most up-to-date value. Use payload when you need the value as it was at the moment the Playbook triggered.

Helper Functions

The sandbox includes built-in helpers for common date and interval operations.

Date Helpers

Interval Helpers

Supported interval names for addInterval and intervalToMonths:

Returning a Result

Your script must return one of two things:

Update traits

Return an object with a traits key:
Trait keys should match the trait paths in Vitally (e.g., current_contract_expiration). Values can be strings, numbers, booleans, or ISO date strings.

Skip the update

Return null when you don’t want to make any changes:
Return null when conditions aren’t met, required data is missing, or you want to skip a particular trigger.

Code Examples

Auto-Renewal: Calculate Next Expiration Date

Use this to automatically advance the contract expiration date when a subscription renews.

Set a Date Trait to Today

Use this to stamp a date trait whenever a Playbook fires — useful for audit trails.

Conditional Update

Only update a trait when a specific condition is true; skip otherwise.

Calculate Days Until Renewal

Compute a numeric trait from an existing date trait.

Troubleshooting

Debugging tips:
  • Use console.log in your script — logs appear in the execution stats view for the action.
  • Check the action card in Settings for trigger count, error count, and the last error message.
  • Start with { traits: { test_trait: today() } } to confirm the webhook fires before adding complex logic.
  • The code editor validates syntax before saving, but runtime errors only surface after a real trigger.

Best Practices

  • Validate inputs before using them — check for null or undefined before accessing nested properties.
  • Return null instead of throwing when required data is missing.
  • Prefer account.traits for the latest values; payload may be slightly stale.
  • One action per Playbook trigger is easier to debug than one script that does everything.
  • Don’t log full account objects or traits that contain PII.
  • Test in staging before activating in production.