AutomationFlowsAI & RAG › Eu Clara – Funil Kiwify Completo

Eu Clara – Funil Kiwify Completo

Eu Clara – Funil Kiwify Completo. Uses postgres, openAi, httpRequest, gmail. Webhook trigger; 70 nodes.

Webhook trigger★★★★★ complexityAI-powered70 nodesPostgresOpenAIHTTP RequestGmail
AI & RAG Trigger: Webhook Nodes: 70 Complexity: ★★★★★ AI nodes: yes Added:

This workflow follows the Gmail → HTTP Request recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "Eu Clara \u2013 Funil Kiwify Completo",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "KiwifyTodosEventos",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "node-webhook",
      "name": "Webhook Kiwify",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        240,
        400
      ]
    },
    {
      "parameters": {
        "respondWith": "text",
        "responseBody": "OK",
        "options": {}
      },
      "id": "node-respond",
      "name": "Responder OK",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        460,
        200
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a1",
              "name": "evento",
              "value": "={{ $json.body.webhook_event_type }}",
              "type": "string"
            },
            {
              "id": "a2",
              "name": "order_id",
              "value": "={{ $json.body.order_id }}",
              "type": "string"
            },
            {
              "id": "a3",
              "name": "order_status",
              "value": "={{ $json.body.order_status }}",
              "type": "string"
            },
            {
              "id": "a4",
              "name": "nome",
              "value": "={{ $json.body.Customer.first_name }}",
              "type": "string"
            },
            {
              "id": "a5",
              "name": "nome_completo",
              "value": "={{ $json.body.Customer.full_name }}",
              "type": "string"
            },
            {
              "id": "a6",
              "name": "email",
              "value": "={{ $json.body.Customer.email.toLowerCase() }}",
              "type": "string"
            },
            {
              "id": "a7",
              "name": "telefone",
              "value": "={{ $json.body.Customer.mobile.replace('+', '').replace(/\\s/g, '') }}",
              "type": "string"
            },
            {
              "id": "a8",
              "name": "produto_id",
              "value": "={{ $json.body.Product.product_id }}",
              "type": "string"
            },
            {
              "id": "a9",
              "name": "produto_nome",
              "value": "={{ $json.body.Product.product_name }}",
              "type": "string"
            },
            {
              "id": "a10",
              "name": "pix_code",
              "value": "={{ $json.body.pix_code || '' }}",
              "type": "string"
            },
            {
              "id": "a11",
              "name": "pix_expiration",
              "value": "={{ $json.body.pix_expiration || '' }}",
              "type": "string"
            },
            {
              "id": "a12",
              "name": "boleto_url",
              "value": "={{ $json.body.boleto_barcode || '' }}",
              "type": "string"
            },
            {
              "id": "a13",
              "name": "boleto_expiry",
              "value": "={{ $json.body.boleto_expiry_date || '' }}",
              "type": "string"
            },
            {
              "id": "a14",
              "name": "checkout_link",
              "value": "=https://pay.kiwify.com.br/{{ $json.body.checkout_link }}",
              "type": "string"
            },
            {
              "id": "a15",
              "name": "access_url",
              "value": "={{ $json.body.access_url || '' }}",
              "type": "string"
            },
            {
              "id": "a16",
              "name": "payment_method",
              "value": "={{ $json.body.payment_method }}",
              "type": "string"
            },
            {
              "id": "a17",
              "name": "evento_hash",
              "value": "={{ $json.body.order_id + '_' + $json.body.webhook_event_type }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "node-normalize",
      "name": "Normalizar Payload",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        460,
        400
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "SELECT produto_id, produto_nome, produto_tipo, checkout_link_proprio, link_acesso FROM tbl_euclara_produtos WHERE produto_id = '{{ $json.produto_id }}' LIMIT 1",
        "options": {}
      },
      "id": "node-busca-produto",
      "name": "Buscar Produto no Supabase",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        680,
        400
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "c1",
              "leftValue": "={{ $('Buscar Produto no Supabase').item.json.produto_id }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "isEmpty"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "node-check-produto",
      "name": "Produto Mapeado?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        900,
        400
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "INSERT INTO tbl_euclara_produtos_pendentes (produto_id, produto_nome, primeiro_evento, email_cliente, created_at) VALUES ('{{ $('Normalizar Payload').item.json.produto_id }}', '{{ $('Normalizar Payload').item.json.produto_nome }}', '{{ $('Normalizar Payload').item.json.evento }}', '{{ $('Normalizar Payload').item.json.email }}', NOW()) ON CONFLICT (produto_id) DO UPDATE SET ultimo_evento = NOW(), contagem = tbl_euclara_produtos_pendentes.contagem + 1",
        "options": {}
      },
      "id": "node-produto-desconhecido",
      "name": "Registrar Produto Desconhecido",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        1120,
        240
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "b1",
              "name": "produto_tipo",
              "value": "={{ $('Buscar Produto no Supabase').item.json.produto_tipo || 'ebook' }}",
              "type": "string"
            },
            {
              "id": "b2",
              "name": "link_acesso",
              "value": "={{ $('Buscar Produto no Supabase').item.json.link_acesso || '' }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "node-enrich-produto",
      "name": "Enriquecer com Dados do Produto",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1120,
        480
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "INSERT INTO tbl_euclara_funil (email, nome, telefone, produto_id, produto_nome, produto_tipo, evento_atual, status_pagamento, pix_code, boleto_url, boleto_expiry, checkout_link, followup_bloqueado, ultimo_evento_hash, updated_at) VALUES ('{{ $('Normalizar Payload').item.json.email }}', '{{ $('Normalizar Payload').item.json.nome }}', '{{ $('Normalizar Payload').item.json.telefone }}', '{{ $('Normalizar Payload').item.json.produto_id }}', '{{ $('Normalizar Payload').item.json.produto_nome }}', '{{ $('Enriquecer com Dados do Produto').item.json.produto_tipo }}', '{{ $('Normalizar Payload').item.json.evento }}', CASE WHEN '{{ $('Normalizar Payload').item.json.evento }}' = 'paid' THEN 'pago' WHEN '{{ $('Normalizar Payload').item.json.evento }}' IN ('refunded','subscription_canceled') THEN 'cancelado' ELSE 'pendente' END, '{{ $('Normalizar Payload').item.json.pix_code }}', '{{ $('Normalizar Payload').item.json.boleto_url }}', '{{ $('Normalizar Payload').item.json.boleto_expiry }}', '{{ $('Normalizar Payload').item.json.checkout_link }}', CASE WHEN '{{ $('Normalizar Payload').item.json.evento }}' = 'paid' THEN true ELSE false END, '{{ $('Normalizar Payload').item.json.evento_hash }}', NOW()) ON CONFLICT (email, produto_id) DO UPDATE SET evento_atual = EXCLUDED.evento_atual, status_pagamento = EXCLUDED.status_pagamento, followup_bloqueado = CASE WHEN EXCLUDED.evento_atual = 'paid' THEN true WHEN EXCLUDED.evento_atual IN ('refunded','subscription_canceled') THEN true ELSE tbl_euclara_funil.followup_bloqueado END, followup_bloqueado_at = CASE WHEN EXCLUDED.evento_atual = 'paid' THEN NOW() ELSE tbl_euclara_funil.followup_bloqueado_at END, pix_code = EXCLUDED.pix_code, boleto_url = EXCLUDED.boleto_url, ultimo_evento_hash = EXCLUDED.ultimo_evento_hash, updated_at = NOW() WHERE tbl_euclara_funil.ultimo_evento_hash != EXCLUDED.ultimo_evento_hash RETURNING *",
        "options": {}
      },
      "id": "node-upsert-funil",
      "name": "Upsert no tbl_euclara_funil",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        1340,
        480
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "d1",
              "leftValue": "={{ $json.length }}",
              "rightValue": 0,
              "operator": {
                "type": "number",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "node-check-idempotencia",
      "name": "Evento Duplicado?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        1560,
        480
      ]
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "node-stop-duplicado",
      "name": "Ignorar Duplicado",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1780,
        320
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "SELECT d.peso_ansiedade, d.peso_dependencia, d.peso_autoestima, d.resposta, d.pergunta FROM tbl_beatriz_diagnostico d INNER JOIN tbl_DadosCadastro c ON c.id::text = d.user_id::text WHERE LOWER(c.\"Email\") = LOWER('{{ $('Normalizar Payload').item.json.email }}') ORDER BY d.created_at DESC LIMIT 12",
        "options": {}
      },
      "id": "node-busca-diagnostico",
      "name": "Buscar Diagn\u00f3stico da Usu\u00e1ria",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        1780,
        560
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const diagnostico = $input.all();\nconst normalizado = $('Normalizar Payload').item.json;\n\nlet totalAnsiedade = 0, totalAutoestima = 0, totalDependencia = 0;\nlet respostasTexto = [];\n\ndiagnostico.forEach(row => {\n  totalAnsiedade += row.json.peso_ansiedade || 0;\n  totalAutoestima += row.json.peso_autoestima || 0;\n  totalDependencia += row.json.peso_dependencia || 0;\n  if (row.json.pergunta && row.json.resposta) {\n    respostasTexto.push(`${row.json.pergunta}: ${row.json.resposta}`);\n  }\n});\n\nconst classificar = (v) => {\n  if (v <= 8) return 'Baixo';\n  if (v <= 16) return 'M\u00e9dio';\n  return 'Alto';\n};\n\nconst nivelAnsiedade = classificar(totalAnsiedade);\nconst nivelAutoestima = classificar(totalAutoestima);\nconst nivelDependencia = classificar(totalDependencia);\n\nconst resumoDiagnostico = `N\u00edvel de Ansiedade: ${nivelAnsiedade} (${totalAnsiedade} pts). N\u00edvel de Autoestima: ${nivelAutoestima} (${totalAutoestima} pts). N\u00edvel de Depend\u00eancia Emocional: ${nivelDependencia} (${totalDependencia} pts). Respostas da usu\u00e1ria: ${respostasTexto.slice(0, 6).join(' | ')}`;\n\nreturn [{\n  json: {\n    ...normalizado,\n    nivel_ansiedade: nivelAnsiedade,\n    nivel_autoestima: nivelAutoestima,\n    nivel_dependencia: nivelDependencia,\n    total_ansiedade: totalAnsiedade,\n    total_autoestima: totalAutoestima,\n    resumo_diagnostico: resumoDiagnostico,\n    tem_diagnostico: diagnostico.length > 0\n  }\n}];"
      },
      "id": "node-processa-diagnostico",
      "name": "Processar Scores do Diagn\u00f3stico",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2000,
        560
      ]
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": false,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "id": "e1",
                    "leftValue": "={{ $json.evento }}",
                    "rightValue": "pix_created",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "PIX"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": false,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "id": "e2",
                    "leftValue": "={{ $json.evento }}",
                    "rightValue": "billet_created",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "BOLETO"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": false,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "id": "e3",
                    "leftValue": "={{ $json.evento }}",
                    "rightValue": "abandoned",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "ABANDONO"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": false,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "id": "e4",
                    "leftValue": "={{ $json.evento }}",
                    "rightValue": "order_rejected",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "CARTAO_RECUSADO"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": false,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "id": "e5",
                    "leftValue": "={{ $json.evento }}",
                    "rightValue": "paid",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "PAGO"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": false,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "id": "e6",
                    "leftValue": "={{ $json.evento }}",
                    "rightValue": "subscription_renewed",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "RENOVACAO"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": false,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "id": "e7",
                    "leftValue": "={{ $json.evento }}",
                    "rightValue": "refunded",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "REEMBOLSO"
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "id": "node-switch-evento",
      "name": "Switch por Evento",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3,
      "position": [
        2220,
        560
      ]
    },
    {
      "parameters": {
        "amount": 10,
        "unit": "minutes"
      },
      "id": "node-pix-wait-1",
      "name": "PIX \u2013 Aguardar 10min",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        2460,
        320
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "SELECT followup_bloqueado, status_pagamento FROM tbl_euclara_funil WHERE email = '{{ $('Processar Scores do Diagn\u00f3stico').item.json.email }}' AND produto_id = '{{ $('Processar Scores do Diagn\u00f3stico').item.json.produto_id }}' LIMIT 1",
        "options": {}
      },
      "id": "node-pix-check-1",
      "name": "PIX \u2013 Verificar Status 1",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        2680,
        320
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "f1",
              "leftValue": "={{ $json.followup_bloqueado }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "true"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "node-pix-gate-1",
      "name": "PIX \u2013 Bloqueado? 1",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        2900,
        320
      ]
    },
    {
      "parameters": {
        "model": "gpt-4o-mini",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "Voc\u00ea \u00e9 a Clara, a voz emp\u00e1tica e acolhedora do m\u00e9todo Eu Clara. Escreva mensagens curtas para WhatsApp (m\u00e1ximo 3 par\u00e1grafos, sem formata\u00e7\u00e3o markdown, linguagem feminina e acolhedora). Use os dados do diagn\u00f3stico da usu\u00e1ria para personalizar. Nunca mencione n\u00fameros ou pontua\u00e7\u00f5es t\u00e9cnicas diretamente \u2013 traduza em sentimentos. O produto \u00e9 o M\u00e9todo Eu Clara \u2013 21 Dias para Clareza Emocional. Fale como uma amiga pr\u00f3xima, n\u00e3o como vendedora."
            },
            {
              "role": "user",
              "content": "=Evento: PIX_CRIADO \u2013 Follow-up 1 (10 minutos)\nNome: {{ $('Processar Scores do Diagn\u00f3stico').item.json.nome }}\nDiagn\u00f3stico: {{ $('Processar Scores do Diagn\u00f3stico').item.json.resumo_diagnostico }}\nTem diagn\u00f3stico: {{ $('Processar Scores do Diagn\u00f3stico').item.json.tem_diagnostico }}\nProduto escolhido: {{ $('Processar Scores do Diagn\u00f3stico').item.json.produto_nome }}\nLink do PIX: C\u00f3pie o c\u00f3digo abaixo para pagar\nC\u00f3digo PIX: {{ $('Processar Scores do Diagn\u00f3stico').item.json.pix_code }}\nVencimento: {{ $('Processar Scores do Diagn\u00f3stico').item.json.pix_expiration }}\n\nEscreva uma mensagem lembrando do PIX pendente. Seja gentil, mencione a transforma\u00e7\u00e3o poss\u00edvel com base no diagn\u00f3stico dela. Inclua o c\u00f3digo PIX no final da mensagem."
            }
          ]
        },
        "options": {}
      },
      "id": "node-pix-ia-1",
      "name": "PIX \u2013 IA Gera Mensagem 1",
      "type": "n8n-nodes-base.openAi",
      "typeVersion": 1.4,
      "position": [
        3120,
        240
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://evolution.becomehub.com.br/message/sendText/SUA_INSTANCIA_AQUI",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "apikey",
              "value": "SUA_KEY_DO_EVOLUTION_AQUI"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "number",
              "value": "={{ $('Processar Scores do Diagn\u00f3stico').item.json.telefone }}"
            },
            {
              "name": "text",
              "value": "={{ $('PIX \u2013 IA Gera Mensagem 1').item.json.message.content }}"
            },
            {
              "name": "delay",
              "value": 1200
            }
          ]
        },
        "options": {}
      },
      "id": "node-pix-wpp-1",
      "name": "PIX \u2013 Enviar WhatsApp 1",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        3340,
        240
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "INSERT INTO tbl_euclara_funil_log (email, evento, acao, canal, followup_seq, detalhes, sucesso, created_at) VALUES ('{{ $('Processar Scores do Diagn\u00f3stico').item.json.email }}', 'pix_created', 'whatsapp_enviado', 'whatsapp', 1, 'Follow-up PIX 10min enviado', true, NOW())",
        "options": {}
      },
      "id": "node-log-pix-1",
      "name": "Log \u2013 PIX Follow-up 1",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        3560,
        240
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "amount": 2,
        "unit": "hours"
      },
      "id": "node-pix-wait-2",
      "name": "PIX \u2013 Aguardar 2h",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        3560,
        320
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "SELECT followup_bloqueado, status_pagamento FROM tbl_euclara_funil WHERE email = '{{ $('Processar Scores do Diagn\u00f3stico').item.json.email }}' AND produto_id = '{{ $('Processar Scores do Diagn\u00f3stico').item.json.produto_id }}' LIMIT 1",
        "options": {}
      },
      "id": "node-pix-check-2",
      "name": "PIX \u2013 Verificar Status 2",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        3780,
        320
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "f2",
              "leftValue": "={{ $json.followup_bloqueado }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "true"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "node-pix-gate-2",
      "name": "PIX \u2013 Bloqueado? 2",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        4000,
        320
      ]
    },
    {
      "parameters": {
        "model": "gpt-4o-mini",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "Voc\u00ea \u00e9 a Clara, a voz emp\u00e1tica e acolhedora do m\u00e9todo Eu Clara. Escreva mensagens curtas para WhatsApp (m\u00e1ximo 3 par\u00e1grafos, sem formata\u00e7\u00e3o markdown, linguagem feminina e acolhedora). Use os dados do diagn\u00f3stico para personalizar. O produto \u00e9 o M\u00e9todo Eu Clara \u2013 21 Dias para Clareza Emocional."
            },
            {
              "role": "user",
              "content": "=Evento: PIX_CRIADO \u2013 Follow-up 2 (2 horas)\nNome: {{ $('Processar Scores do Diagn\u00f3stico').item.json.nome }}\nDiagn\u00f3stico: {{ $('Processar Scores do Diagn\u00f3stico').item.json.resumo_diagnostico }}\nProduto: {{ $('Processar Scores do Diagn\u00f3stico').item.json.produto_nome }}\nLink de checkout: {{ $('Processar Scores do Diagn\u00f3stico').item.json.checkout_link }}\nC\u00f3digo PIX: {{ $('Processar Scores do Diagn\u00f3stico').item.json.pix_code }}\n\nEscreva um follow-up de 2 horas. Crie urg\u00eancia emocional (n\u00e3o agressiva). Lembre que o diagn\u00f3stico mostrou pontos de aten\u00e7\u00e3o. Ofere\u00e7a o link caso o PIX tenha expirado."
            }
          ]
        },
        "options": {}
      },
      "id": "node-pix-ia-2",
      "name": "PIX \u2013 IA Gera Mensagem 2",
      "type": "n8n-nodes-base.openAi",
      "typeVersion": 1.4,
      "position": [
        4220,
        240
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://evolution.becomehub.com.br/message/sendText/SUA_INSTANCIA_AQUI",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "apikey",
              "value": "SUA_KEY_DO_EVOLUTION_AQUI"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "number",
              "value": "={{ $('Processar Scores do Diagn\u00f3stico').item.json.telefone }}"
            },
            {
              "name": "text",
              "value": "={{ $('PIX \u2013 IA Gera Mensagem 2').item.json.message.content }}"
            },
            {
              "name": "delay",
              "value": 1200
            }
          ]
        },
        "options": {}
      },
      "id": "node-pix-wpp-2",
      "name": "PIX \u2013 Enviar WhatsApp 2",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        4440,
        240
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "INSERT INTO tbl_euclara_funil_log (email, evento, acao, canal, followup_seq, detalhes, sucesso, created_at) VALUES ('{{ $('Processar Scores do Diagn\u00f3stico').item.json.email }}', 'pix_created', 'whatsapp_enviado', 'whatsapp', 2, 'Follow-up PIX 2h enviado', true, NOW())",
        "options": {}
      },
      "id": "node-log-pix-2",
      "name": "Log \u2013 PIX Follow-up 2",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        4660,
        240
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "amount": 24,
        "unit": "hours"
      },
      "id": "node-pix-wait-3",
      "name": "PIX \u2013 Aguardar 24h",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        4660,
        320
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "SELECT followup_bloqueado, status_pagamento FROM tbl_euclara_funil WHERE email = '{{ $('Processar Scores do Diagn\u00f3stico').item.json.email }}' AND produto_id = '{{ $('Processar Scores do Diagn\u00f3stico').item.json.produto_id }}' LIMIT 1",
        "options": {}
      },
      "id": "node-pix-check-3",
      "name": "PIX \u2013 Verificar Status 3",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        4880,
        320
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "f3",
              "leftValue": "={{ $json.followup_bloqueado }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "true"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "node-pix-gate-3",
      "name": "PIX \u2013 Bloqueado? 3",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        5100,
        320
      ]
    },
    {
      "parameters": {
        "model": "gpt-4o-mini",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "Voc\u00ea \u00e9 a Clara. Escreva a \u00faltima mensagem de recupera\u00e7\u00e3o de PIX para WhatsApp. Tom: \u00faltimo convite carinhoso, sem press\u00e3o, com honestidade emocional. M\u00e1ximo 3 par\u00e1grafos."
            },
            {
              "role": "user",
              "content": "=Evento: PIX_CRIADO \u2013 Follow-up 3 (24 horas \u2013 \u00faltimo)\nNome: {{ $('Processar Scores do Diagn\u00f3stico').item.json.nome }}\nDiagn\u00f3stico: {{ $('Processar Scores do Diagn\u00f3stico').item.json.resumo_diagnostico }}\nProduto: {{ $('Processar Scores do Diagn\u00f3stico').item.json.produto_nome }}\nLink de checkout: {{ $('Processar Scores do Diagn\u00f3stico').item.json.checkout_link }}\n\nEsta \u00e9 a \u00faltima mensagem. Seja honesta e calorosa. Diga que essa \u00e9 a \u00faltima vez que vai aparecer. Convide de verdade, sem manipula\u00e7\u00e3o."
            }
          ]
        },
        "options": {}
      },
      "id": "node-pix-ia-3",
      "name": "PIX \u2013 IA Gera Mensagem 3",
      "type": "n8n-nodes-base.openAi",
      "typeVersion": 1.4,
      "position": [
        5320,
        240
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://evolution.becomehub.com.br/message/sendText/SUA_INSTANCIA_AQUI",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "apikey",
              "value": "SUA_KEY_DO_EVOLUTION_AQUI"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "number",
              "value": "={{ $('Processar Scores do Diagn\u00f3stico').item.json.telefone }}"
            },
            {
              "name": "text",
              "value": "={{ $('PIX \u2013 IA Gera Mensagem 3').item.json.message.content }}"
            },
            {
              "name": "delay",
              "value": 1200
            }
          ]
        },
        "options": {}
      },
      "id": "node-pix-wpp-3",
      "name": "PIX \u2013 Enviar WhatsApp 3",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        5540,
        240
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "INSERT INTO tbl_euclara_funil_log (email, evento, acao, canal, followup_seq, detalhes, sucesso, created_at) VALUES ('{{ $('Processar Scores do Diagn\u00f3stico').item.json.email }}', 'pix_created', 'whatsapp_enviado', 'whatsapp', 3, 'Follow-up PIX 24h enviado', true, NOW())",
        "options": {}
      },
      "id": "node-log-pix-3",
      "name": "Log \u2013 PIX Follow-up 3",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        5760,
        240
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "amount": 6,
        "unit": "hours"
      },
      "id": "node-boleto-wait-1",
      "name": "BOLETO \u2013 Aguardar 6h",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        2460,
        560
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "SELECT followup_bloqueado FROM tbl_euclara_funil WHERE email = '{{ $('Processar Scores do Diagn\u00f3stico').item.json.email }}' AND produto_id = '{{ $('Processar Scores do Diagn\u00f3stico').item.json.produto_id }}' LIMIT 1",
        "options": {}
      },
      "id": "node-boleto-check-1",
      "name": "BOLETO \u2013 Verificar Status 1",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        2680,
        560
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "g1",
              "leftValue": "={{ $json.followup_bloqueado }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "true"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "node-boleto-gate-1",
      "name": "BOLETO \u2013 Bloqueado? 1",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        2900,
        560
      ]
    },
    {
      "parameters": {
        "model": "gpt-4o-mini",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "Voc\u00ea \u00e9 a Clara. Escreva mensagem para WhatsApp sobre boleto pendente. Tom acolhedor, feminino, sem press\u00e3o. M\u00e1ximo 3 par\u00e1grafos."
            },
            {
              "role": "user",
              "content": "=Evento: BOLETO \u2013 Follow-up 1 (6 horas)\nNome: {{ $('Processar Scores do Diagn\u00f3stico').item.json.nome }}\nDiagn\u00f3stico: {{ $('Processar Scores do Diagn\u00f3stico').item.json.resumo_diagnostico }}\nProduto: {{ $('Processar Scores do Diagn\u00f3stico').item.json.produto_nome }}\nURL do Boleto: {{ $('Processar Scores do Diagn\u00f3stico').item.json.boleto_url }}\nVencimento: {{ $('Processar Scores do Diagn\u00f3stico').item.json.boleto_expiry }}\n\nLembre do boleto gerado. Conecte com a dor emocional do diagn\u00f3stico. Diga que o boleto ainda est\u00e1 dispon\u00edvel."
            }
          ]
        },
        "options": {}
      },
      "id": "node-boleto-ia-1",
      "name": "BOLETO \u2013 IA Gera Mensagem 1",
      "type": "n8n-nodes-base.openAi",
      "typeVersion": 1.4,
      "position": [
        3120,
        480
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://evolution.becomehub.com.br/message/sendText/SUA_INSTANCIA_AQUI",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "apikey",
              "value": "SUA_KEY_DO_EVOLUTION_AQUI"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "number",
              "value": "={{ $('Processar Scores do Diagn\u00f3stico').item.json.telefone }}"
            },
            {
              "name": "text",
              "value": "={{ $('BOLETO \u2013 IA Gera Mensagem 1').item.json.message.content }}"
            },
            {
              "name": "delay",
              "value": 1200
            }
          ]
        },
        "options": {}
      },
      "id": "node-boleto-wpp-1",
      "name": "BOLETO \u2013 Enviar WhatsApp 1",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        3340,
        480
      ]
    },
    {
      "parameters": {
        "amount": 24,
        "unit": "hours"
      },
      "id": "node-boleto-wait-2",
      "name": "BOLETO \u2013 Aguardar 24h",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        3560,
        560
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "SELECT followup_bloqueado FROM tbl_euclara_funil WHERE email = '{{ $('Processar Scores do Diagn\u00f3stico').item.json.email }}' AND produto_id = '{{ $('Processar Scores do Diagn\u00f3stico').item.json.produto_id }}' LIMIT 1",
        "options": {}
      },
      "id": "node-boleto-check-2",
      "name": "BOLETO \u2013 Verificar Status 2",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        3780,
        560
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "g2",
              "leftValue": "={{ $json.followup_bloqueado }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "true"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "node-boleto-gate-2",
      "name": "BOLETO \u2013 Bloqueado? 2",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        4000,
        560
      ]
    },
    {
      "parameters": {
        "model": "gpt-4o-mini",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "Voc\u00ea \u00e9 a Clara. Escreva mensagem final de boleto. Tom: carinhoso, \u00faltima chance sem press\u00e3o."
            },
            {
              "role": "user",
              "content": "=Evento: BOLETO \u2013 Follow-up 2 (24h \u2013 pr\u00f3ximo ao vencimento)\nNome: {{ $('Processar Scores do Diagn\u00f3stico').item.json.nome }}\nDiagn\u00f3stico: {{ $('Processar Scores do Diagn\u00f3stico').item.json.resumo_diagnostico }}\nLink checkout: {{ $('Processar Scores do Diagn\u00f3stico').item.json.checkout_link }}\nVencimento boleto: {{ $('Processar Scores do Diagn\u00f3stico').item.json.boleto_expiry }}\n\nAlerte sobre vencimento pr\u00f3ximo. Ofere\u00e7a o link de checkout como alternativa (pode pagar de outro jeito). Tom de cuidado genu\u00edno."
            }
          ]
        },
        "options": {}
      },
      "id": "node-boleto-ia-2",
      "name": "BOLETO \u2013 IA Gera Mensagem 2",
      "type": "n8n-nodes-base.openAi",
      "typeVersion": 1.4,
      "position": [
        4220,
        480
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://evolution.becomehub.com.br/message/sendText/SUA_INSTANCIA_AQUI",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "apikey",
              "value": "SUA_KEY_DO_EVOLUTION_AQUI"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "number",
              "value": "={{ $('Processar Scores do Diagn\u00f3stico').item.json.telefone }}"
            },
            {
              "name": "text",
              "value": "={{ $('BOLETO \u2013 IA Gera Mensagem 2').item.json.message.content }}"
            },
            {
              "name": "delay",
              "value": 1200
            }
          ]
        },
        "options": {}
      },
      "id": "node-boleto-wpp-2",
      "name": "BOLETO \u2013 Enviar WhatsApp 2",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        4440,
        480
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "INSERT INTO tbl_euclara_funil_log (email, evento, acao, canal, followup_seq, detalhes, sucesso, created_at) VALUES ('{{ $('Processar Scores do Diagn\u00f3stico').item.json.email }}', 'billet_created', 'whatsapp_enviado', 'whatsapp', 2, 'Follow-up Boleto 24h enviado', true, NOW())",
        "options": {}
      },
      "id": "node-log-boleto-2",
      "name": "Log \u2013 BOLETO Follow-up 2",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        4660,
        480
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "model": "gpt-4o-mini",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "Voc\u00ea \u00e9 a Clara. Escreva mensagem imediata de recupera\u00e7\u00e3o de carrinho abandonado para WhatsApp. Tom: surpresa positiva, como se a Clara tivesse visto que a usu\u00e1ria quase foi embora. M\u00e1ximo 3 par\u00e1grafos. Linguagem feminina e acolhedora."
            },
            {
              "role": "user",
              "content": "=Evento: ABANDONO DE CARRINHO \u2013 Imediato\nNome: {{ $('Processar Scores do Diagn\u00f3stico').item.json.nome }}\nDiagn\u00f3stico: {{ $('Processar Scores do Diagn\u00f3stico').item.json.resumo_diagnostico }}\nProduto: {{ $('Processar Scores do Diagn\u00f3stico').item.json.produto_nome }}\nLink checkout: {{ $('Processar Scores do Diagn\u00f3stico').item.json.checkout_link }}\n\nEla abandonou o carrinho. Conecte com a dor emocional do diagn\u00f3stico. Mostre que o m\u00e9todo foi feito para exatamente o que ela est\u00e1 sentindo. Inclua o link no final."
            }
          ]
        },
        "options": {}
      },
      "id": "node-abandono-ia-1",
      "name": "ABANDONO \u2013 IA Gera Mensagem 1",
      "type": "n8n-nodes-base.openAi",
      "typeVersion": 1.4,
      "position": [
        2460,
        800
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://evolution.becomehub.com.br/message/sendText/SUA_INSTANCIA_AQUI",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "apikey",
              "value": "SUA_KEY_DO_EVOLUTION_AQUI"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "number",
              "value": "={{ $('Processar Scores do Diagn\u00f3stico').item.json.telefone }}"
            },
            {
              "name": "text",
              "value": "={{ $('ABANDONO \u2013 IA Gera Mensagem 1').item.json.message.content }}"
            },
            {
              "name": "delay",
              "value": 1200
            }
          ]
        },
        "options": {}
      },
      "id": "node-abandono-wpp-1",
      "name": "ABANDONO \u2013 Enviar WhatsApp 1",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2680,
        800
      ]
    },
    {
      "parameters": {
        "amount": 24,
        "unit": "hours"
      },
      "id": "node-abandono-wait-2",
      "name": "ABANDONO \u2013 Aguardar 24h",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        2900,
        800
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "SELECT followup_bloqueado FROM tbl_euclara_funil WHERE email = '{{ $('Processar Scores do Diagn\u00f3stico').item.json.email }}' AND produto_id = '{{ $('Processar Scores do Diagn\u00f3stico').item.json.produto_id }}' LIMIT 1",
        "options": {}
      },
      "id": "node-abandono-check-2",
      "name": "ABANDONO \u2013 Verificar Status 2",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        3120,
        800
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "h1",
              "leftValue": "={{ $json.followup_bloqueado }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "true"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "node-abandono-gate-2",
      "name": "ABANDONO \u2013 Bloqueado? 2",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        3340,
        800
      ]
    },
    {
      "parameters": {
        "model": "gpt-4o-mini",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "Voc\u00ea \u00e9 a Clara. Escreva follow-up de 24h de abandono. Use prova social sutil e refor\u00e7o da transforma\u00e7\u00e3o. M\u00e1ximo 3 par\u00e1grafos."
            },
            {
              "role": "user",
              "content": "=Evento: ABANDONO \u2013 Follow-up 2 (24 horas)\nNome: {{ $('Processar Scores do Diagn\u00f3stico').item.json.nome }}\nDiagn\u00f3stico: {{ $('Processar Scores do Diagn\u00f3stico').item.json.resumo_diagnostico }}\nLink checkout: {{ $('Processar Scores do Diagn\u00f3stico').item.json.checkout_link }}\n\nMencione que outras mulheres com perfil parecido j\u00e1 est\u00e3o no m\u00e9todo. Seja espec\u00edfica nas dores do diagn\u00f3stico. Termine com o link."
            }
          ]
        },
        "options": {}
      },
      "id": "node-abandono-ia-2",
      "name": "ABANDONO \u2013 IA Gera Mensagem 2",
      "type": "n8n-nodes-base.openAi",
      "typeVersion": 1.4,
      "position": [
        3560,
        720
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://evolution.becomehub.com.br/message/sendText/SUA_INSTANCIA_AQUI",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "apikey",
              "value": "SUA_KEY_DO_EVOLUTION_AQUI"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "number",
              "value": "={{ $('Processar Scores do Diagn\u00f3stico').item.json.telefone }}"
            },
            {
              "name": "text",
              "value": "={{ $('ABANDONO \u2013 IA Gera Mensagem 2').item.json.message.content }}"
            },
            {
              "name": "delay",
              "value": 1200
            }
          ]
        },
        "options": {}
      },
      "id": "node-abandono-wpp-2",
      "name": "ABANDONO \u2013 Enviar WhatsApp 2",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        3780,
        720
      ]
    },
    {
      "parameters": {
        "amount": 48,
        "unit": "hours"
      },
      "id": "node-abandono-wait-3",
      "name": "ABANDONO \u2013 Aguardar 48h",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        4000,
        800
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "SELECT followup_bloqueado FROM tbl_euclara_funil WHERE email = '{{ $('Processar Scores do Diagn\u00f3stico').item.json.email }}' AND produto_id = '{{ $('Processar Scores do Diagn\u00f3stico').item.json.produto_id }}' LIMIT 1",
        "options": {}
      },
      "id": "node-abandono-check-3",
      "name": "ABANDONO \u2013 Verificar Status 3",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        4220,
        800
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "h2",
              "leftValue": "={{ $json.followup_bloqueado }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "true"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "node-abandono-gate-3",
      "name": "ABANDONO \u2013 Bloqueado? 3",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        4440,
        800
      ]
    },
    {
      "parameters": {
        "model": "gpt-4o-mini",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "Voc\u00ea \u00e9 a Clara. \u00daltima mensagem de abandono. Tom: despedida genu\u00edna, sem rancor. Deixe a porta aberta."
            },
            {
              "role": "user",
              "content": "=Evento: ABANDONO \u2013 Follow-up 3 (48h \u2013 \u00faltimo)\nNome: {{ $('Processar Scores do Diagn\u00f3stico').item.json.nome }}\nDiagn\u00f3stico: {{ $('Processar Scores do Diagn\u00f3stico').item.json.resumo_diagnostico }}\nLink checkout: {{ $('Processar Scores do Diagn\u00f3stico').item.json.checkout_link }}\n\nDiga que n\u00e3o vai mais enviar mensagens. Deixe o link dispon\u00edvel. Termine com uma frase de encorajamento genu\u00edno, independente da compra."
            }
          ]
        },
        "options": {}
      },
      "id": "node-abandono-ia-3",
      "name": "ABANDONO \u2013 IA Gera Mensagem 3",
      "type": "n8n-nodes-base.openAi",
      "typeVersion": 1.4,
      "position": [
        4660,
        720
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://evolution.becomehub.com.br/message/sendText/SUA_INSTANCIA_AQUI",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "apikey",
              "value": "SUA_KEY_DO_EVOLUTION_AQUI"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "number",
              "value": "={{ $('Processar Scores do Diagn\u00f3stico').item.json.telefone }}"
            },
            {
              "name": "text",
              "value": "={{ $('ABANDONO \u2013 IA Gera Mensagem 3').item.json.message.content }}"
            },
            {
              "name": "delay",
              "value": 1200
            }
          ]
        },
        "options": {}
      },
      "id": "node-abandono-wpp-3",
      "name": "ABANDONO \u2013 Enviar WhatsApp 3",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        4880,
        720
      ]
    },
    {
      "parameters": {
        "model": "gpt-4o-mini",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "Voc\u00ea \u00e9 a Clara. Cart\u00e3o recusado. Tom: acolhedor, sem constrangimento. Ofere\u00e7a alternativas de pagamento. M\u00e1ximo 2 par\u00e1grafos."
            },
            {
              "role": "user",
              "content": "=Evento: CART\u00c3O RECUSADO \u2013 Imediato\nNome: {{ $('Processar Scores do Diagn\u00f3stico').item.json.nome }}\nLink checkout: {{ $('Processar Scores do Diagn\u00f3stico').item.json.checkout_link }}\n\nO pagamento foi recusado. N\u00e3o \u00e9 culpa dela. Ofere\u00e7a tentar novamente ou usar PIX/boleto. Seja r\u00e1pida e gentil."
            }
          ]
        },
        "options": {}
      },
      "id": "node-cartao-ia-1",
      "name": "CART\u00c3O \u2013 IA Gera Mensagem 1",
      "type": "n8n-nodes-base.openAi",
      "typeVersion": 1.4,
      "position": [
        2460,
        1040
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://evolution.becomehub.com.br/message/sendText/SUA_INSTANCIA_AQUI",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "apikey",
              "value": "SUA_KEY_DO_EVOLUTION_AQUI"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "number",
              "value": "={{ $('Processar Scores do Diagn\u00f3stico').item.json.telefone }}"
            },
            {
              "name": "text",
              "value": "={{ $('CART\u00c3O \u2013 IA Gera Mensagem 1').item.json.message.content }}"
            },
            {
              "name": "delay",
              "value": 1200
            }
          ]
        },
        "options": {}
      },
      "id": "node-cartao-wpp-1",
      "name": "CART\u00c3O \u2013 Enviar WhatsApp 1",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2680,
        1040
      ]
    },
    {
      "parameters": {
        "amount": 2,
        "unit": "hours"
      },
      "id": "node-cartao-wait-2",
      "name": "CART\u00c3O \u2013 Aguardar 2h",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        2900,
        1040
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "SELECT followup_bloqueado FROM tbl_euclara_funil WHERE email = '{{ $('Processar Scores do Diagn\u00f3stico').item.json.email }}' AND produto_id = '{{ $('Processar Scores do Diagn\u00f3stico').item.json.produto_id }}' LIMIT 1",
        "options": {}
      },
      "id": "node-cartao-check-2",
      "name": "CART\u00c3O \u2013 Verificar Status 2",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        3120,
        1040
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "i1",
              "leftValue": "={{ $json.followup_bloqueado }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "true"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "node-cartao-gate-2",
      "name": "CART\u00c3O \u2013 Bloqueado? 2",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        3340,
        1040
      ]
    },
    {
      "parameters": {
        "model": "gpt-4o-mini",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "Voc\u00ea \u00e9 a Clara. Segundo follow-up de cart\u00e3o recusado. Lem

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Eu Clara – Funil Kiwify Completo. Uses postgres, openAi, httpRequest, gmail. Webhook trigger; 70 nodes.

Source: https://gist.github.com/odiogeneslucas/196c6c2ebff9d7b5a40c4bb22355dcea — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

User Signup & Verification: The workflow starts when a user signs up. It generates a verification code and sends it via SMS using Twilio. Code Validation: The user replies with the code. The workflow

Postgres, HTTP Request, OpenAI +2
AI & RAG

Lua Nova - Sistema Completo. Uses postgres, httpRequest, openAi. Webhook trigger; 55 nodes.

Postgres, HTTP Request, OpenAI
AI & RAG

A scheduled process aggregates content from eight distinct data sources and standardizes all inputs into a unified format. AI models perform sentiment scoring, detect conspiracy or misinformation sign

HTTP Request, OpenAI, Postgres +2
AI & RAG

Instantly map all internal URLs, perform AI-powered (ChatGPT) analysis, and deliver results in HTML via webhook, Google Sheets, or email. All from your own n8n instance!

OpenAI, HTTP Request, XML +3
AI & RAG

Watch on Youtube▶️

HTTP Request, Email Send, Google Sheets +3