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

# n8n

> Import a ready workflow that checks each AI draft with DataVibe before n8n sends it.

The gate goes after your AI step and before the send step:

```text theme={null}
trigger → contact data → AI draft → DataVibe gate → branch → Smartlead / Gmail / CRM
```

## Import the workflow

1. Download [datavibe-pre-send-gate.workflow.json](https://datavibe.cc/integrations/n8n/datavibe-pre-send-gate.workflow.json).
2. In n8n, open **Workflows → Import from file** and choose the file.
3. Set `DATAVIBE_API_KEY` as an environment variable on your n8n instance. Create a key at
   [app.datavibe.cc/security/api-keys](https://app.datavibe.cc/security/api-keys).
4. Replace the sample trigger and "Contact + AI draft" node with your own. Keep the field names
   (`email`, `subject`, `generated_opener`, `first_name`, `company`, `role`, `contact_id`,
   `draft_version`) or edit the gate node body to match.
5. Replace the three placeholder outputs with your send, hold, and log steps.

> [!WARNING]
>
> Do not paste the API key into the HTTP node. Read it from the environment so it never ends up in an
> exported workflow.

## What the gate node sends

```json theme={null}
{
  "recipient": "{{ $json.email }}",
  "subject": "{{ $json.subject }}",
  "body_html": "<p>{{ $json.generated_opener }}</p>",
  "body_text": "{{ $json.generated_opener }}",
  "idempotency_key": "n8n-{{ $json.contact_id }}-{{ $json.draft_version }}",
  "metadata": {
    "integration": "n8n",
    "recipient_first_name": "{{ $json.first_name }}",
    "company": "{{ $json.company }}",
    "role": "{{ $json.role }}"
  }
}
```

Passing `recipient_first_name`, `company`, and `role` turns on the wrong-name, wrong-company, and
wrong-role checks.

## Branches

| Branch | Status | What to do |
| - | - | - |
| Proceed | `APPROVED`, `SENT` | Send the exact draft that was checked. Save `action_id`. |
| Review | `QUEUED` | Do not send yet. Resume on the `gate.review.approved` webhook. |
| Blocked | `BLOCKED`, `FAILED`, anything else | Do not send. Log `policy_violations[].rule`. |
| Gate error | HTTP error or timeout | Fail closed. Retry with the same `idempotency_key`. |

Retrying with the same `idempotency_key` returns the original `action_id` and is not billed twice.

## WhatsApp, SMS, and other channels

For non-email sends, call `POST https://api.datavibe.cc/v2/gate/outbound` with `channel`
(`whatsapp`, `sms`, `telegram`, `linkedin`, or `slack`), `recipient`, and `body_text`. `subject`
and `body_html` are only needed for email.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.