> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vorel.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Automation

> Around-the-brain workflow templates: post-booking confirmations, lead-nurture cadences, weekly QA digests. Operator-deployed via n8n + Vorel's public API.

Vorel splits its automation surface into two layers:

* **Per-turn dispatch** (router → sub-agent → tool) runs **in-code** as TypeScript inside the
  Vorel web app. Type-checked, version-controlled, code-reviewed. This is the synchronous AI
  brain that handles every customer message + voice turn.
* **Around-the-brain workflows** (post-booking nudges, nurture cadences, weekly digests) run
  **in n8n**: operator-editable visual workflows that consume Vorel's public API + outbound
  webhooks.

This page covers the around-the-brain layer.

<Note>
  **n8n runs in its own container, separate from the agent hot path**, behind operator-only SSO. The
  around-the-brain templates are available as importable workflow exports; the operator imports and
  builds the real workflow in the n8n UI per-tenant during onboarding. n8n consumes Vorel's public
  `/api/v1/*` API over HTTP and is never on the voice/chat dispatch path. Standing up the n8n service
  per-tenant follows the operator setup runbook.
</Note>

## The 3 v1 templates

<CardGroup cols={1}>
  <Card title="Post-booking confirmation" icon="calendar-check">
    **Trigger:** Vorel webhook on `booking.created`.

    **Flow:** When the agent books an appointment, fan out: Slack notify the assigned user, push
    to the tenant's CRM via Vorel's create-record endpoint, and schedule a 24-hour-before
    reminder via Vorel's outbound conversation send. Appointment data comes from the webhook
    payload, so no extra GET is needed.

    **Vorel API surface:** `POST /v1/crm/create-record` · `POST /v1/conversations/:id/send`

    Available as an importable workflow template (ask your Vorel operator).
  </Card>

  <Card title="Lead nurture (3-day)" icon="bell">
    **Trigger:** n8n schedule trigger, daily 09:00 cron (`0 9 * * *`).

    **Flow:** Daily, find leads stale-qualified for 3+ days, send a re-engagement WhatsApp
    template via Vorel's outbound conversation send; escalate to human handoff after 7 days. The
    lead-list filter `?stale_for_days=N` is the vendored shortcut for the cohort.

    **Vorel API surface:** `GET /v1/leads?stale_for_days=3` · `POST /v1/conversations/:id/send` ·
    `POST /v1/leads/:id/handoff` · `PATCH /v1/leads/:id`

    Available as an importable workflow template (ask your Vorel operator).
  </Card>

  <Card title="Weekly QA rollup" icon="award">
    **Trigger:** n8n schedule trigger, Monday 09:00 cron (`0 9 * * 1`).

    **Flow:** Aggregate QA scores + hallucination flags + handoff reasons from the prior 7 days;
    format the rollup; email or Slack the digest to the operator. Single-endpoint workflow
    backed by `weekly-rollup`.

    **Vorel API surface:** `GET /v1/analytics/weekly-rollup`

    Available as an importable workflow template (ask your Vorel operator).
  </Card>
</CardGroup>

All three templates are **status: ready**: every endpoint they call is shipped on the public
API. A CI test cross-references each `httpRequest` URL in every template against the live OpenAPI
spec; a renamed or removed endpoint would fail the build before the template silently breaks.

## How operator deployment works

When n8n is stood up, the operator runs through this on each new tenant:

<Steps>
  <Step title="Stand up the n8n service">
    Stand up n8n as its own container per the operator setup runbook.
  </Step>

  <Step title="Gate n8n behind operator-only SSO">
    Put the n8n domain behind SSO so only the operator team can reach it.
  </Step>

  <Step title="Issue a per-tenant Vorel API key">
    Create a per-tenant Vorel public API key from the admin console with the scopes each template
    needs (`leads:write`, `conversations:write`, `crm:write`, `read`).
  </Step>

  <Step title="Import the workflow files">
    Import each template into n8n; configure credentials (the API key) + the cron timezone (per
    tenant's local time).
  </Step>

  <Step title="Wire webhook subscriptions">
    For webhook-triggered workflows (post-booking-confirmation), wire the Vorel-side webhook
    subscription so the right event types POST into the right n8n webhook URL.
  </Step>
</Steps>

## Around-the-brain vs. in-brain: the split

Per-turn agent dispatch is **in code**, not n8n:

* The router → sub-agent → tool flow runs in-process via `runChatDispatch` / `runVoiceDispatch`.
* Each tool route at `/api/tools/*` is JWT-authed (5-min TTL) and tenant-scoped via
  `withTenantContext`.
* This stays type-checked, code-reviewed, and version-controlled; the synchronous AI brain is
  too load-bearing to live in a visual editor.

n8n handles the **asynchronous, cross-conversation, operator-editable** layer:

* Post-booking nudges, nurture cadences, weekly digests, custom escalation flows.
* Operators clone + tune templates per-tenant without a code deploy.
* Each tenant's workflows are isolated by API key.

## Custom workflows beyond the v1 templates

Tenants who want bespoke workflows go in two directions:

* **Subscribe to webhooks** at `/(dashboard)/settings/integrations/webhooks`: receive
  `lead.created` / `booking.created` / 10 other event types in your own automation system.
  HMAC-SHA256 signed; 6-attempt retry ladder.
* **Pull from the public API**: every resource (conversations, leads, appointments,
  offerings, analytics) has GET (list) + GET (id) + POST + PATCH parity. Build whatever cohort
  / cron / fan-out you need.

The n8n templates are the **starting point**, not the limit. They're deliberately small (1–4
nodes each) so the operator can fork them into tenant-specific variants.

## What's NOT supported

* **Always-on n8n, today.** Templates exist on disk; the n8n service is stood up per the operator
  runbook rather than running by default. Around-the-brain workflows aren't running until the
  runbook is executed.
* **Vorel-managed scheduling.** Crons live in n8n; Vorel doesn't run its own cron service today.
  The scheduled analytics exports/alerts are triggered by an external scheduler hitting internal
  endpoints.
* **Visual workflow editor inside Vorel's dashboard.** n8n is the editor; we don't ship a
  bespoke one.
* **End-customer-facing workflow editing.** n8n access is operator-team-only behind SSO. Tenants
  describe what they want during onboarding; the operator builds the workflow per-tenant.

## Related docs

* [API Reference](/api-reference/introduction): endpoint catalog
* [Webhooks](/api-reference/webhooks): outbound webhook contract
* [Analytics](/product/analytics): weekly-rollup endpoint
* [How it works](/getting-started/how-it-works): where the in-code dispatch fits

{/* verified-against: apps/web/src/app/admin/automation/templates.ts (around-the-brain templates) */}
