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

# Integrações No-Code

> Templates prontos para conectar a Cordialy ao n8n, Zapier e Make sem escrever código

Use ferramentas de automação visual para conectar a Cordialy com centenas de outros sistemas — CRMs, planilhas, Slack, e-mail e muito mais.

<CardGroup cols={2}>
  <Card title="n8n" icon="code" href="#n8n">
    Self-hosted ou cloud. Template JSON importável.
  </Card>

  <Card title="Zapier" icon="bolt" href="#zapier">
    Mais de 6.000 apps conectados. Setup guiado.
  </Card>
</CardGroup>

***

## n8n

### Como importar um template

1. No n8n, clique em **+** para criar um novo workflow
2. Clique nos três pontos (**⋮**) no canto superior direito → **Import from JSON**
3. Cole o JSON do template abaixo e clique em **Import**
4. Substitua os valores marcados com `SEU_*` pelas suas credenciais
5. Ative o workflow com o toggle no topo

<Info>
  Os templates usam apenas o node **HTTP Request**, compatível com todas as versões do n8n. Não dependem de credenciais nativas da plataforma.
</Info>

***

### Template 1 — Lead convertido → notificar no Slack

Recebe o evento `lead.status_changed`, filtra apenas conversões, busca os dados do lead na Cordialy e envia uma mensagem no Slack via Incoming Webhook.

<Accordion title="Ver JSON para importar">
  ```json theme={null}
  {
    "name": "Cordialy → Slack (lead convertido)",
    "nodes": [
      {
        "parameters": {
          "httpMethod": "POST",
          "path": "cordialy-eventos",
          "responseMode": "immediatelyOnReceive",
          "options": {}
        },
        "id": "1",
        "name": "Receber Webhook",
        "type": "n8n-nodes-base.webhook",
        "typeVersion": 2,
        "position": [200, 300]
      },
      {
        "parameters": {
          "conditions": {
            "combinator": "and",
            "conditions": [
              {
                "leftValue": "={{ $json.body.event }}",
                "rightValue": "lead.status_changed",
                "operator": { "type": "string", "operation": "equals" }
              },
              {
                "leftValue": "={{ $json.body.data.new_status }}",
                "rightValue": "converted",
                "operator": { "type": "string", "operation": "equals" }
              }
            ]
          }
        },
        "id": "2",
        "name": "Filtrar conversões",
        "type": "n8n-nodes-base.filter",
        "typeVersion": 2,
        "position": [420, 300]
      },
      {
        "parameters": {
          "method": "GET",
          "url": "=https://api.cordialy.ai/integrations/v1/leads/{{ $json.body.data.lead_id }}",
          "sendHeaders": true,
          "headerParameters": {
            "parameters": [
              { "name": "X-API-Key", "value": "SUA_API_KEY_CORDIALY" }
            ]
          },
          "options": {}
        },
        "id": "3",
        "name": "Buscar lead na Cordialy",
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4,
        "position": [640, 300]
      },
      {
        "parameters": {
          "method": "POST",
          "url": "SEU_SLACK_WEBHOOK_URL",
          "sendBody": true,
          "contentType": "json",
          "body": "={\n  \"text\": \"🎉 *Lead convertido!*\\n\\n*Nome:* {{ $json.name || 'Sem nome' }}\\n*Telefone:* {{ $json.customer_phone }}\\n*ID:* {{ $json.id }}\"\n}",
          "options": {}
        },
        "id": "4",
        "name": "Enviar para Slack",
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4,
        "position": [860, 300]
      }
    ],
    "connections": {
      "Receber Webhook": {
        "main": [[{ "node": "Filtrar conversões", "type": "main", "index": 0 }]]
      },
      "Filtrar conversões": {
        "main": [[{ "node": "Buscar lead na Cordialy", "type": "main", "index": 0 }]]
      },
      "Buscar lead na Cordialy": {
        "main": [[{ "node": "Enviar para Slack", "type": "main", "index": 0 }]]
      }
    },
    "settings": { "executionOrder": "v1" }
  }
  ```
</Accordion>

**O que substituir após importar:**

* `SUA_API_KEY_CORDIALY` → sua chave da Cordialy (Integrações → API Keys)
* `SEU_SLACK_WEBHOOK_URL` → URL do Incoming Webhook do Slack

**Fluxo:**

```
Webhook → Filtro (converted) → GET /leads/:id → POST Slack
```

***

### Template 2 — Nova mensagem recebida → salvar no Google Sheets

Recebe o evento `message.received` e adiciona uma linha na planilha com o conteúdo da mensagem via Google Sheets API.

<Accordion title="Ver JSON para importar">
  ```json theme={null}
  {
    "name": "Cordialy → Google Sheets (nova mensagem)",
    "nodes": [
      {
        "parameters": {
          "httpMethod": "POST",
          "path": "cordialy-mensagens",
          "responseMode": "immediatelyOnReceive",
          "options": {}
        },
        "id": "1",
        "name": "Receber Webhook",
        "type": "n8n-nodes-base.webhook",
        "typeVersion": 2,
        "position": [200, 300]
      },
      {
        "parameters": {
          "conditions": {
            "combinator": "and",
            "conditions": [
              {
                "leftValue": "={{ $json.body.event }}",
                "rightValue": "message.received",
                "operator": { "type": "string", "operation": "equals" }
              }
            ]
          }
        },
        "id": "2",
        "name": "Filtrar mensagens recebidas",
        "type": "n8n-nodes-base.filter",
        "typeVersion": 2,
        "position": [420, 300]
      },
      {
        "parameters": {
          "method": "POST",
          "url": "=https://sheets.googleapis.com/v4/spreadsheets/SEU_SPREADSHEET_ID/values/Sheet1!A1:append?valueInputOption=USER_ENTERED",
          "sendHeaders": true,
          "headerParameters": {
            "parameters": [
              { "name": "Authorization", "value": "Bearer SEU_GOOGLE_ACCESS_TOKEN" },
              { "name": "Content-Type", "value": "application/json" }
            ]
          },
          "sendBody": true,
          "contentType": "json",
          "body": "={\n  \"values\": [[\n    \"{{ $json.body.timestamp }}\",\n    \"{{ $json.body.data.lead_id }}\",\n    \"{{ $json.body.data.content }}\",\n    \"{{ $json.body.data.session_id }}\"\n  ]]\n}",
          "options": {}
        },
        "id": "3",
        "name": "Adicionar linha no Sheets",
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4,
        "position": [640, 300]
      }
    ],
    "connections": {
      "Receber Webhook": {
        "main": [[{ "node": "Filtrar mensagens recebidas", "type": "main", "index": 0 }]]
      },
      "Filtrar mensagens recebidas": {
        "main": [[{ "node": "Adicionar linha no Sheets", "type": "main", "index": 0 }]]
      }
    },
    "settings": { "executionOrder": "v1" }
  }
  ```
</Accordion>

**O que substituir após importar:**

* `SEU_SPREADSHEET_ID` → ID da sua planilha (está na URL do Google Sheets)
* `SEU_GOOGLE_ACCESS_TOKEN` → use o node **Google Sheets** nativo do n8n para autenticação OAuth simplificada

<Tip>
  Para autenticação com Google no n8n, substitua o node HTTP Request por um node **Google Sheets** nativo e mapeie os valores manualmente — é mais simples que gerenciar tokens OAuth manualmente.
</Tip>

### Configurar o webhook no n8n

Após ativar o workflow, o n8n mostra a URL do webhook na aba **Webhook URLs**. Copie e cole em **Plataforma → Integrações → Webhooks**.

***

## Zapier

O Zapier não tem integração nativa com a Cordialy, mas você conecta usando **Webhooks by Zapier** como trigger e qualquer app como ação.

### Cenário: Lead convertido → linha no Google Sheets

**1. Criar o Zap**

Acesse [zapier.com](https://zapier.com) → **Create Zap**

**2. Trigger — Webhooks by Zapier**

* App: **Webhooks by Zapier**
* Evento: **Catch Hook**
* Copie a URL gerada (ex: `https://hooks.zapier.com/hooks/catch/123456/abcdef/`)
* Cole em **Plataforma → Integrações → Webhooks**
* Dispare qualquer evento na plataforma para o Zapier detectar a estrutura do payload

**3. Filter — Apenas conversões**

* App: **Filter by Zapier**
* Condição 1: `body__event` **Exactly matches** `lead.status_changed`
* Condição 2: `body__data__new_status` **Exactly matches** `converted`

**4. Action — Google Sheets**

* App: **Google Sheets**
* Evento: **Create Spreadsheet Row**
* Planilha: selecione sua planilha
* Mapeie os campos:
  * Data/hora → `body__timestamp`
  * Lead ID → `body__data__lead_id`
  * Status anterior → `body__data__previous_status`

**5. Publicar**

Teste cada step e clique em **Publish Zap**.

***

### Outros cenários úteis

| Trigger Cordialy                  | App           | Ação                     |
| --------------------------------- | ------------- | ------------------------ |
| `lead.created`                    | HubSpot       | Criar contato            |
| `lead.created`                    | Pipedrive     | Criar negócio            |
| `lead.status_changed → converted` | Google Sheets | Adicionar linha          |
| `message.received`                | Gmail         | Enviar alerta por e-mail |
| `session.ended`                   | Airtable      | Registrar sessão         |
| `followup.sent`                   | Slack         | Notificar canal          |
