{
  "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. Lembre da transforma\u00e7\u00e3o que ela estava buscando. Ofere\u00e7a PIX como sa\u00edda mais f\u00e1cil."
            },
            {
              "role": "user",
              "content": "=Evento: CART\u00c3O RECUSADO \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 }}\nLink checkout: {{ $('Processar Scores do Diagn\u00f3stico').item.json.checkout_link }}\n\nLembre que o PIX \u00e9 instant\u00e2neo e mais simples. Use a dor do diagn\u00f3stico para refor\u00e7ar o desejo. Seja breve."
            }
          ]
        },
        "options": {}
      },
      "id": "node-cartao-ia-2",
      "name": "CART\u00c3O \u2013 IA Gera Mensagem 2",
      "type": "n8n-nodes-base.openAi",
      "typeVersion": 1.4,
      "position": [
        3560,
        960
      ],
      "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 2').item.json.message.content }}"
            },
            {
              "name": "delay",
              "value": 1200
            }
          ]
        },
        "options": {}
      },
      "id": "node-cartao-wpp-2",
      "name": "CART\u00c3O \u2013 Enviar WhatsApp 2",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        3780,
        960
      ]
    },
    {
      "parameters": {
        "jsCode": "const dados = $input.first().json;\nconst produtoTipo = dados.produto_tipo || 'ebook';\n\nconst mensagens = {\n  ebook: `Ol\u00e1 ${dados.nome}! Seu acesso ao M\u00e9todo Eu Clara est\u00e1 pronto. Acesse agora: ${dados.link_acesso || dados.access_url}`,\n  ebook_pro: `Ol\u00e1 ${dados.nome}! Seu acesso ao M\u00e9todo Eu Clara + Plano Pro est\u00e1 liberado! Acesse: ${dados.link_acesso || dados.access_url}`,\n  ebook_vip: `Ol\u00e1 ${dados.nome}! Bem-vinda ao M\u00e9todo Eu Clara VIP! Seu acesso completo est\u00e1 dispon\u00edvel: ${dados.link_acesso || dados.access_url}`\n};\n\nreturn [{ json: { ...dados, mensagem_onboarding: mensagens[produtoTipo] || mensagens.ebook } }];"
      },
      "id": "node-pago-onboarding",
      "name": "PAGO \u2013 Montar Onboarding",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2460,
        1280
      ]
    },
    {
      "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": "={{ $json.mensagem_onboarding }}"
            },
            {
              "name": "delay",
              "value": 1000
            }
          ]
        },
        "options": {}
      },
      "id": "node-pago-wpp",
      "name": "PAGO \u2013 Enviar WhatsApp Onboarding",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2680,
        1280
      ]
    },
    {
      "parameters": {
        "fromEmail": "contato@euclara.com.br",
        "toEmail": "={{ $('Processar Scores do Diagn\u00f3stico').item.json.email }}",
        "subject": "={{ $('Processar Scores do Diagn\u00f3stico').item.json.nome }}, seu acesso ao M\u00e9todo Eu Clara est\u00e1 pronto \ud83c\udf3f",
        "emailType": "html",
        "message": "=<!DOCTYPE html><html lang=\"pt-BR\"><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"></head><body style=\"margin:0;padding:0;background-color:#F5F1EA;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;\"><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"background-color:#F5F1EA;padding:20px 0;\"><tr><td align=\"center\"><table width=\"600\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"background:#ffffff;border-radius:15px;overflow:hidden;box-shadow:0 10px 25px rgba(0,0,0,0.05);max-width:600px;width:100%;\"><tr><td align=\"center\" style=\"padding:30px 20px 10px 20px;\"><img src=\"https://static-public.pages.hotmart.com/uploads/media/file/10557612/eu_clara_fundo_trans.png\" alt=\"Eu Clara\" width=\"150\" style=\"display:block;max-width:100%;height:auto;\"></td></tr><tr><td style=\"padding:20px 40px 10px 40px;color:#4A4A4A;font-size:16px;line-height:1.6;\"><h1 style=\"margin:0 0 10px 0;font-size:22px;color:#3E6B61;\">Ol\u00e1, {{ $('Processar Scores do Diagn\u00f3stico').item.json.nome }} \ud83c\udf3f</h1><p style=\"margin:0 0 15px 0;\">Voc\u00ea deu o passo mais importante. Seu acesso ao <strong>M\u00e9todo Eu Clara \u2013 21 Dias para Clareza Emocional</strong> est\u00e1 liberado.</p><div style=\"text-align:center;margin:25px 0;\"><a href=\"{{ $('PAGO \u2013 Montar Onboarding').item.json.mensagem_onboarding }}\" style=\"background:#3E6B61;color:#ffffff;padding:18px 40px;border-radius:50px;text-decoration:none;font-weight:bold;font-size:17px;display:inline-block;\">Acessar Meu M\u00e9todo Agora</a></div></td></tr><tr><td style=\"background:#3E6B61;padding:30px;text-align:center;font-size:12px;color:#A8D5BA;\"><p style=\"margin:0;\">Com carinho, Equipe Eu Clara.</p></td></tr></table></td></tr></table></body></html>",
        "options": {}
      },
      "id": "node-pago-email",
      "name": "PAGO \u2013 Enviar Email Onboarding",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        2900,
        1280
      ],
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "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 }}', 'paid', 'onboarding_enviado', 'whatsapp+email', 1, 'Onboarding p\u00f3s-pagamento enviado', true, NOW())",
        "options": {}
      },
      "id": "node-log-pago",
      "name": "Log \u2013 PAGO Onboarding",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.5,
      "position": [
        3120,
        1280
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "model": "gpt-4o-mini",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "Voc\u00ea \u00e9 a Clara. Mensagem de renova\u00e7\u00e3o de assinatura. Tom: celebra\u00e7\u00e3o e gratid\u00e3o. M\u00e1ximo 2 par\u00e1grafos."
            },
            {
              "role": "user",
              "content": "=Evento: RENOVA\u00c7\u00c3O DE ASSINATURA\nNome: {{ $('Processar Scores do Diagn\u00f3stico').item.json.nome }}\nProduto: {{ $('Processar Scores do Diagn\u00f3stico').item.json.produto_nome }}\n\nCelebre a renova\u00e7\u00e3o. Reforce o quanto ela avan\u00e7ou e o que ainda vem pela frente."
            }
          ]
        },
        "options": {}
      },
      "id": "node-renovacao-ia",
      "name": "RENOVA\u00c7\u00c3O \u2013 IA Gera Mensagem",
      "type": "n8n-nodes-base.openAi",
      "typeVersion": 1.4,
      "position": [
        2460,
        1480
      ],
      "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": "={{ $('RENOVA\u00c7\u00c3O \u2013 IA Gera Mensagem').item.json.message.content }}"
            },
            {
              "name": "delay",
              "value": 1000
            }
          ]
        },
        "options": {}
      },
      "id": "node-renovacao-wpp",
      "name": "RENOVA\u00c7\u00c3O \u2013 Enviar WhatsApp",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2680,
        1480
      ]
    },
    {
      "parameters": {
        "model": "gpt-4o-mini",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "Voc\u00ea \u00e9 a Clara. Mensagem p\u00f3s-reembolso. Tom: acolhedor, sem julgamento. Pedido gentil de feedback."
            },
            {
              "role": "user",
              "content": "=Evento: REEMBOLSO\nNome: {{ $('Processar Scores do Diagn\u00f3stico').item.json.nome }}\nProduto: {{ $('Processar Scores do Diagn\u00f3stico').item.json.produto_nome }}\n\nEla pediu reembolso. Agrade\u00e7a pela chance. Pergunte gentilmente o que n\u00e3o funcionou. Deixe a porta aberta para retorno futuro."
            }
          ]
        },
        "options": {}
      },
      "id": "node-reembolso-ia",
      "name": "REEMBOLSO \u2013 IA Gera Mensagem",
      "type": "n8n-nodes-base.openAi",
      "typeVersion": 1.4,
      "position": [
        2460,
        1640
      ],
      "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": "={{ $('REEMBOLSO \u2013 IA Gera Mensagem').item.json.message.content }}"
            },
            {
              "name": "delay",
              "value": 1000
            }
          ]
        },
        "options": {}
      },
      "id": "node-reembolso-wpp",
      "name": "REEMBOLSO \u2013 Enviar WhatsApp",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2680,
        1640
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.deepseek.com/v1/chat/completions",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer SUA_KEY_DEEPSEEK_AQUI"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"model\": \"deepseek-chat\",\n  \"messages\": [\n    {\n      \"role\": \"system\",\n      \"content\": \"Voc\u00ea \u00e9 a Clara, voz emp\u00e1tica do M\u00e9todo Eu Clara. Escreva mensagem curta para WhatsApp (m\u00e1ximo 3 par\u00e1grafos). Tom feminino e acolhedor.\"\n    },\n    {\n      \"role\": \"user\",\n      \"content\": \"{{ $('Processar Scores do Diagn\u00f3stico').item.json.resumo_diagnostico }}. Evento: {{ $('Processar Scores do Diagn\u00f3stico').item.json.evento }}. Nome: {{ $('Processar Scores do Diagn\u00f3stico').item.json.nome }}. Produto: {{ $('Processar Scores do Diagn\u00f3stico').item.json.produto_nome }}. Link: {{ $('Processar Scores do Diagn\u00f3stico').item.json.checkout_link }}\"\n    }\n  ],\n  \"max_tokens\": 400\n}",
        "options": {}
      },
      "id": "node-deepseek-fallback",
      "name": "DeepSeek \u2013 Fallback IA",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        3120,
        1640
      ],
      "notes": "FALLBACK: Conecte a sa\u00edda de erro dos nodes OpenAI aqui. Configure como onError: continueErrorOutput em cada node OpenAI e ligue o output de erro neste node."
    }
  ],
  "connections": {
    "Webhook Kiwify": {
      "main": [
        [
          {
            "node": "Responder OK",
            "type": "main",
            "index": 0
          },
          {
            "node": "Normalizar Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalizar Payload": {
      "main": [
        [
          {
            "node": "Buscar Produto no Supabase",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Buscar Produto no Supabase": {
      "main": [
        [
          {
            "node": "Produto Mapeado?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Produto Mapeado?": {
      "main": [
        [
          {
            "node": "Registrar Produto Desconhecido",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Enriquecer com Dados do Produto",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enriquecer com Dados do Produto": {
      "main": [
        [
          {
            "node": "Upsert no tbl_euclara_funil",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upsert no tbl_euclara_funil": {
      "main": [
        [
          {
            "node": "Evento Duplicado?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Evento Duplicado?": {
      "main": [
        [
          {
            "node": "Ignorar Duplicado",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Buscar Diagn\u00f3stico da Usu\u00e1ria",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Buscar Diagn\u00f3stico da Usu\u00e1ria": {
      "main": [
        [
          {
            "node": "Processar Scores do Diagn\u00f3stico",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Processar Scores do Diagn\u00f3stico": {
      "main": [
        [
          {
            "node": "Switch por Evento",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch por Evento": {
      "main": [
        [
          {
            "node": "PIX \u2013 Aguardar 10min",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "BOLETO \u2013 Aguardar 6h",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "ABANDONO \u2013 IA Gera Mensagem 1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "CART\u00c3O \u2013 IA Gera Mensagem 1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "PAGO \u2013 Montar Onboarding",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "RENOVA\u00c7\u00c3O \u2013 IA Gera Mensagem",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "REEMBOLSO \u2013 IA Gera Mensagem",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PIX \u2013 Aguardar 10min": {
      "main": [
        [
          {
            "node": "PIX \u2013 Verificar Status 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PIX \u2013 Verificar Status 1": {
      "main": [
        [
          {
            "node": "PIX \u2013 Bloqueado? 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PIX \u2013 Bloqueado? 1": {
      "main": [
        [
          {
            "node": "Ignorar Duplicado",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "PIX \u2013 IA Gera Mensagem 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PIX \u2013 IA Gera Mensagem 1": {
      "main": [
        [
          {
            "node": "PIX \u2013 Enviar WhatsApp 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PIX \u2013 Enviar WhatsApp 1": {
      "main": [
        [
          {
            "node": "Log \u2013 PIX Follow-up 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log \u2013 PIX Follow-up 1": {
      "main": [
        [
          {
            "node": "PIX \u2013 Aguardar 2h",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PIX \u2013 Aguardar 2h": {
      "main": [
        [
          {
            "node": "PIX \u2013 Verificar Status 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PIX \u2013 Verificar Status 2": {
      "main": [
        [
          {
            "node": "PIX \u2013 Bloqueado? 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PIX \u2013 Bloqueado? 2": {
      "main": [
        [
          {
            "node": "Ignorar Duplicado",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "PIX \u2013 IA Gera Mensagem 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PIX \u2013 IA Gera Mensagem 2": {
      "main": [
        [
          {
            "node": "PIX \u2013 Enviar WhatsApp 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PIX \u2013 Enviar WhatsApp 2": {
      "main": [
        [
          {
            "node": "Log \u2013 PIX Follow-up 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log \u2013 PIX Follow-up 2": {
      "main": [
        [
          {
            "node": "PIX \u2013 Aguardar 24h",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PIX \u2013 Aguardar 24h": {
      "main": [
        [
          {
            "node": "PIX \u2013 Verificar Status 3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PIX \u2013 Verificar Status 3": {
      "main": [
        [
          {
            "node": "PIX \u2013 Bloqueado? 3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PIX \u2013 Bloqueado? 3": {
      "main": [
        [
          {
            "node": "Ignorar Duplicado",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "PIX \u2013 IA Gera Mensagem 3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PIX \u2013 IA Gera Mensagem 3": {
      "main": [
        [
          {
            "node": "PIX \u2013 Enviar WhatsApp 3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PIX \u2013 Enviar WhatsApp 3": {
      "main": [
        [
          {
            "node": "Log \u2013 PIX Follow-up 3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "BOLETO \u2013 Aguardar 6h": {
      "main": [
        [
          {
            "node": "BOLETO \u2013 Verificar Status 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "BOLETO \u2013 Verificar Status 1": {
      "main": [
        [
          {
            "node": "BOLETO \u2013 Bloqueado? 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "BOLETO \u2013 Bloqueado? 1": {
      "main": [
        [
          {
            "node": "Ignorar Duplicado",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "BOLETO \u2013 IA Gera Mensagem 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "BOLETO \u2013 IA Gera Mensagem 1": {
      "main": [
        [
          {
            "node": "BOLETO \u2013 Enviar WhatsApp 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "BOLETO \u2013 Enviar WhatsApp 1": {
      "main": [
        [
          {
            "node": "BOLETO \u2013 Aguardar 24h",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "BOLETO \u2013 Aguardar 24h": {
      "main": [
        [
          {
            "node": "BOLETO \u2013 Verificar Status 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "BOLETO \u2013 Verificar Status 2": {
      "main": [
        [
          {
            "node": "BOLETO \u2013 Bloqueado? 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "BOLETO \u2013 Bloqueado? 2": {
      "main": [
        [
          {
            "node": "Ignorar Duplicado",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "BOLETO \u2013 IA Gera Mensagem 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "BOLETO \u2013 IA Gera Mensagem 2": {
      "main": [
        [
          {
            "node": "BOLETO \u2013 Enviar WhatsApp 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "BOLETO \u2013 Enviar WhatsApp 2": {
      "main": [
        [
          {
            "node": "Log \u2013 BOLETO Follow-up 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ABANDONO \u2013 IA Gera Mensagem 1": {
      "main": [
        [
          {
            "node": "ABANDONO \u2013 Enviar WhatsApp 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ABANDONO \u2013 Enviar WhatsApp 1": {
      "main": [
        [
          {
            "node": "ABANDONO \u2013 Aguardar 24h",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ABANDONO \u2013 Aguardar 24h": {
      "main": [
        [
          {
            "node": "ABANDONO \u2013 Verificar Status 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ABANDONO \u2013 Verificar Status 2": {
      "main": [
        [
          {
            "node": "ABANDONO \u2013 Bloqueado? 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ABANDONO \u2013 Bloqueado? 2": {
      "main": [
        [
          {
            "node": "Ignorar Duplicado",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "ABANDONO \u2013 IA Gera Mensagem 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ABANDONO \u2013 IA Gera Mensagem 2": {
      "main": [
        [
          {
            "node": "ABANDONO \u2013 Enviar WhatsApp 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ABANDONO \u2013 Enviar WhatsApp 2": {
      "main": [
        [
          {
            "node": "ABANDONO \u2013 Aguardar 48h",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ABANDONO \u2013 Aguardar 48h": {
      "main": [
        [
          {
            "node": "ABANDONO \u2013 Verificar Status 3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ABANDONO \u2013 Verificar Status 3": {
      "main": [
        [
          {
            "node": "ABANDONO \u2013 Bloqueado? 3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ABANDONO \u2013 Bloqueado? 3": {
      "main": [
        [
          {
            "node": "Ignorar Duplicado",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "ABANDONO \u2013 IA Gera Mensagem 3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ABANDONO \u2013 IA Gera Mensagem 3": {
      "main": [
        [
          {
            "node": "ABANDONO \u2013 Enviar WhatsApp 3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CART\u00c3O \u2013 IA Gera Mensagem 1": {
      "main": [
        [
          {
            "node": "CART\u00c3O \u2013 Enviar WhatsApp 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CART\u00c3O \u2013 Enviar WhatsApp 1": {
      "main": [
        [
          {
            "node": "CART\u00c3O \u2013 Aguardar 2h",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CART\u00c3O \u2013 Aguardar 2h": {
      "main": [
        [
          {
            "node": "CART\u00c3O \u2013 Verificar Status 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CART\u00c3O \u2013 Verificar Status 2": {
      "main": [
        [
          {
            "node": "CART\u00c3O \u2013 Bloqueado? 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CART\u00c3O \u2013 Bloqueado? 2": {
      "main": [
        [
          {
            "node": "Ignorar Duplicado",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "CART\u00c3O \u2013 IA Gera Mensagem 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CART\u00c3O \u2013 IA Gera Mensagem 2": {
      "main": [
        [
          {
            "node": "CART\u00c3O \u2013 Enviar WhatsApp 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PAGO \u2013 Montar Onboarding": {
      "main": [
        [
          {
            "node": "PAGO \u2013 Enviar WhatsApp Onboarding",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PAGO \u2013 Enviar WhatsApp Onboarding": {
      "main": [
        [
          {
            "node": "PAGO \u2013 Enviar Email Onboarding",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PAGO \u2013 Enviar Email Onboarding": {
      "main": [
        [
          {
            "node": "Log \u2013 PAGO Onboarding",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "RENOVA\u00c7\u00c3O \u2013 IA Gera Mensagem": {
      "main": [
        [
          {
            "node": "RENOVA\u00c7\u00c3O \u2013 Enviar WhatsApp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "REEMBOLSO \u2013 IA Gera Mensagem": {
      "main": [
        [
          {
            "node": "REEMBOLSO \u2013 Enviar WhatsApp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "callerPolicy": "workflowsFromSameOwner",
    "errorWorkflow": ""
  },
  "staticData": null,
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "versionId": "euclara-kiwify-v1",
  "triggerCount": 1,
  "tags": [
    {
      "name": "EuClara"
    },
    {
      "name": "Kiwify"
    },
    {
      "name": "Funil"
    }
  ]
}