{
  "name": "Pluggou: responder mensagem do WhatsApp",
  "nodes": [
    {
      "parameters": {
        "content": "## Pluggou + n8n\n\n1. Ative este fluxo e copie o endereço de **produção** do nó **Mensagem recebida**.\n2. No painel do Pluggou, em **Integração → Outros destinos de aviso**, clique em **Adicionar destino**, cole o endereço e escolha só **Mensagem recebida**.\n3. Em **Responder pelo WhatsApp**, crie a credencial **Header Auth**: nome `Authorization`, valor `Bearer` + a sua chave de API (`dc_…`).\n4. Mande uma mensagem para o seu número. O aviso de teste do painel chega com `test: true` e não é respondido.\n\nTroque o texto da resposta pelo que quiser: um agente de IA, uma planilha, o seu CRM.",
        "height": 380,
        "width": 420
      },
      "id": "0f5c2b0e-1d8a-4a51-9a4e-1b7a9f0d0a01",
      "name": "Como usar",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-520, -140]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "digiconnect-whatsapp",
        "options": {}
      },
      "id": "3a7e1c52-5b9e-4f0b-8c2d-2b8f6e1a0b02",
      "name": "Mensagem recebida",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [0, 0],
      "webhookId": "6b1f0c9e-7d3a-4e8b-9f2c-3c9a7e2b1c03"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "a1c4e7f0-2b5d-4c8e-9a1b-4d0b8f3c2d04",
              "leftValue": "={{ $json.body.type }}",
              "rightValue": "message.received",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            },
            {
              "id": "b2d5f8a1-3c6e-4d9f-8b2c-5e1c9a4d3e05",
              "leftValue": "={{ $json.body.data.type }}",
              "rightValue": "text",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            },
            {
              "id": "c3e6a9b2-4d7f-4e0a-9c3d-6f2d0b5e4f06",
              "leftValue": "={{ $json.body.test === true }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "4b8f2d63-6cae-4a1c-9d3e-7a0e1c6f5a07",
      "name": "É texto de cliente?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [240, 0]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://conecta.digitalautomation.com.br/v1/numbers/{{ $json.body.number.id }}/messages",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Idempotency-Key",
              "value": "={{ 'resposta-' + $json.body.data.message_id }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ to: $json.body.data.from, type: 'text', text: 'Oi, ' + ($json.body.data.profile_name || '') + '! Recebemos a sua mensagem: ' + $json.body.data.text, reply_to: $json.body.data.message_id }) }}",
        "options": {}
      },
      "id": "5c9a3e74-7dbf-4b2d-8e4f-8b1f2d7a6b08",
      "name": "Responder pelo WhatsApp",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [480, -100]
    }
  ],
  "connections": {
    "Mensagem recebida": {
      "main": [[{ "node": "É texto de cliente?", "type": "main", "index": 0 }]]
    },
    "É texto de cliente?": {
      "main": [[{ "node": "Responder pelo WhatsApp", "type": "main", "index": 0 }], []]
    }
  },
  "settings": { "executionOrder": "v1" },
  "pinData": {}
}
