{
  "format": "columba-flow",
  "formatVersion": 1,
  "app": "Columba · Blog",
  "flow": {
    "name": "Stripe · Cobrança pelo WhatsApp (link de pagamento)",
    "description": "Cliente escreve \"pagar\": o fluxo garante o cliente no Stripe, cria um link de pagamento de R$ 150,00 válido por 1 hora e manda na conversa. Três minutos depois, confere no Stripe. Pago: confirma, aplica a tag \"reserva paga\" e move o negócio. Pendente: lembrete com o mesmo link e nova conferência quando o link vence; se expirou sem pagamento, oferece outro. Qualquer erro vai para o sino da equipe.",
    "triggerType": "trigger_keyword",
    "triggerConfig": {
      "nodeType": "trigger_keyword",
      "label": "Cliente pede para pagar",
      "keywords": "pagar\nquero pagar\npagamento\nlink de pagamento\ncobrança\ncobranca",
      "matchMode": "exact"
    },
    "priority": 20,
    "nodes": [
      {
        "id": "gatilho",
        "type": "trigger_keyword",
        "position": { "x": 0, "y": 0 },
        "data": {
          "nodeType": "trigger_keyword",
          "label": "Cliente pede para pagar",
          "keywords": "pagar\nquero pagar\npagamento\nlink de pagamento\ncobrança\ncobranca",
          "matchMode": "exact"
        }
      },
      {
        "id": "nota",
        "type": "note_sticky",
        "position": { "x": 380, "y": -40 },
        "data": {
          "nodeType": "note_sticky",
          "label": "Antes de publicar",
          "text": "Antes de publicar:\n1. No nó Cobrança, ajuste o valor (R$ 150,00), a descrição e a validade do link (1 hora).\n2. Crie a tag \"reserva paga\" em Configurações › Tags.\n3. No Mover de Etapa, escolha o funil e a etapa (ex.: Confirmada).\n4. Se o Pix ainda não está liberado na sua conta Stripe, tire \"Pix\" das mensagens.\nO gatilho usa palavra exata: \"pagar\", \"quero pagar\", \"pagamento\"..."
        }
      },
      {
        "id": "aviso",
        "type": "action_send_text",
        "position": { "x": 0, "y": 150 },
        "data": {
          "nodeType": "action_send_text",
          "label": "Avisa que vai gerar o link",
          "message": "Perfeito, {{contact.first_name}}! Vou gerar o seu link de pagamento agora. Um instante…"
        }
      },
      {
        "id": "cliente",
        "type": "integration_stripe_upsert_customer",
        "position": { "x": 0, "y": 300 },
        "data": {
          "nodeType": "integration_stripe_upsert_customer",
          "label": "Cliente no Stripe",
          "searchByEmail": true,
          "updateExisting": true
        }
      },
      {
        "id": "cobranca",
        "type": "integration_stripe_create_charge",
        "position": { "x": 0, "y": 470 },
        "data": {
          "nodeType": "integration_stripe_create_charge",
          "label": "Cobrança: link de R$ 150 (1 hora)",
          "kind": "checkout",
          "amount": "150,00",
          "description": "Sinal de reserva — {{contact.name}}",
          "expiresMinutes": 60,
          "existingPolicy": "reuse_open",
          "createCustomer": true
        }
      },
      {
        "id": "link",
        "type": "action_send_text",
        "position": { "x": -260, "y": 660 },
        "data": {
          "nodeType": "action_send_text",
          "label": "Manda o link",
          "message": "Aqui está o seu link de pagamento de {{flow.stripe_amount_formatted}} (Pix, cartão ou boleto):\n{{flow.stripe_payment_url}}\n\nEle vale por 1 hora. Assim que o pagamento cair eu te aviso por aqui. 😉"
        }
      },
      {
        "id": "link_existente",
        "type": "action_send_text",
        "position": { "x": 60, "y": 660 },
        "data": {
          "nodeType": "action_send_text",
          "label": "Reaproveita o link aberto",
          "message": "Você já tem um link de pagamento em aberto de {{flow.stripe_amount_formatted}}:\n{{flow.stripe_payment_url}}"
        }
      },
      {
        "id": "erro_cobranca",
        "type": "integration_notify_team",
        "position": { "x": 380, "y": 660 },
        "data": {
          "nodeType": "integration_notify_team",
          "label": "Erro ao cobrar → sino",
          "notificationMessage": "Stripe: não consegui criar a cobrança de {{contact.name}}. Motivo: {{flow.stripe_error}} ({{flow.stripe_error_code}}).",
          "priority": "high"
        }
      },
      {
        "id": "espera",
        "type": "action_delay",
        "position": { "x": -100, "y": 840 },
        "data": {
          "nodeType": "action_delay",
          "label": "Aguarda 3 minutos",
          "duration": 3,
          "unit": "minutes"
        }
      },
      {
        "id": "status",
        "type": "integration_stripe_charge_status",
        "position": { "x": -100, "y": 990 },
        "data": {
          "nodeType": "integration_stripe_charge_status",
          "label": "Já pagou?"
        }
      },
      {
        "id": "pago",
        "type": "action_send_text",
        "position": { "x": -420, "y": 1180 },
        "data": {
          "nodeType": "action_send_text",
          "label": "Pagamento confirmado",
          "message": "Pagamento de {{flow.stripe_amount_formatted}} confirmado via {{flow.stripe_payment_method_label}}! ✅ Obrigado, {{contact.first_name}}. Sua reserva está garantida."
        }
      },
      {
        "id": "tag_pagou",
        "type": "integration_tag_contact",
        "position": { "x": -420, "y": 1330 },
        "data": {
          "nodeType": "integration_tag_contact",
          "label": "Tag: reserva paga",
          "tagAction": "add",
          "tags": "reserva paga"
        }
      },
      {
        "id": "ganho",
        "type": "integration_move_stage",
        "position": { "x": -420, "y": 1480 },
        "data": {
          "nodeType": "integration_move_stage",
          "label": "Negócio → Confirmada (escolha a etapa)",
          "stageId": "",
          "pipelineId": ""
        }
      },
      {
        "id": "pendente",
        "type": "action_send_text",
        "position": { "x": -100, "y": 1180 },
        "data": {
          "nodeType": "action_send_text",
          "label": "Lembrete",
          "message": "Ainda não vi o seu pagamento por aqui. O link continua válido: {{flow.stripe_payment_url}}\nSe precisar de ajuda, é só me chamar."
        }
      },
      {
        "id": "espera_fim",
        "type": "action_delay",
        "position": { "x": -100, "y": 1330 },
        "data": {
          "nodeType": "action_delay",
          "label": "Aguarda o link vencer (1 hora)",
          "duration": 60,
          "unit": "minutes"
        }
      },
      {
        "id": "status_fim",
        "type": "integration_stripe_charge_status",
        "position": { "x": -100, "y": 1480 },
        "data": {
          "nodeType": "integration_stripe_charge_status",
          "label": "Pagou até o fim do prazo?"
        }
      },
      {
        "id": "expirado",
        "type": "action_send_text",
        "position": { "x": 220, "y": 1180 },
        "data": {
          "nodeType": "action_send_text",
          "label": "Link expirou: oferece outro",
          "message": "O link de pagamento expirou. Se ainda quiser garantir a reserva, escreva \"pagar\" que eu gero outro na hora."
        }
      },
      {
        "id": "erro_status",
        "type": "integration_notify_team",
        "position": { "x": 540, "y": 1180 },
        "data": {
          "nodeType": "integration_notify_team",
          "label": "Erro ao consultar → sino",
          "notificationMessage": "Stripe: não consegui conferir a cobrança de {{contact.name}}: {{flow.stripe_error}}.",
          "priority": "medium"
        }
      }
    ],
    "edges": [
      {
        "id": "e_gatilho_aviso",
        "source": "gatilho",
        "target": "aviso"
      },
      {
        "id": "e_aviso_cliente",
        "source": "aviso",
        "target": "cliente"
      },
      {
        "id": "e_cliente_cobranca_success",
        "source": "cliente",
        "target": "cobranca",
        "sourceHandle": "success",
        "label": "Sucesso"
      },
      {
        "id": "e_cliente_erro_cobranca_error",
        "source": "cliente",
        "target": "erro_cobranca",
        "sourceHandle": "error",
        "label": "Erro"
      },
      {
        "id": "e_cobranca_link_created",
        "source": "cobranca",
        "target": "link",
        "sourceHandle": "created",
        "label": "Criada"
      },
      {
        "id": "e_cobranca_link_existente_existing",
        "source": "cobranca",
        "target": "link_existente",
        "sourceHandle": "existing",
        "label": "Já existia"
      },
      {
        "id": "e_cobranca_erro_cobranca_error",
        "source": "cobranca",
        "target": "erro_cobranca",
        "sourceHandle": "error",
        "label": "Erro"
      },
      {
        "id": "e_link_espera",
        "source": "link",
        "target": "espera"
      },
      {
        "id": "e_link_existente_espera",
        "source": "link_existente",
        "target": "espera"
      },
      {
        "id": "e_espera_status",
        "source": "espera",
        "target": "status"
      },
      {
        "id": "e_status_pago_paid",
        "source": "status",
        "target": "pago",
        "sourceHandle": "paid",
        "label": "Paga"
      },
      {
        "id": "e_status_pendente_pending",
        "source": "status",
        "target": "pendente",
        "sourceHandle": "pending",
        "label": "Pendente"
      },
      {
        "id": "e_status_expirado_expired",
        "source": "status",
        "target": "expirado",
        "sourceHandle": "expired",
        "label": "Expirada"
      },
      {
        "id": "e_status_erro_status_error",
        "source": "status",
        "target": "erro_status",
        "sourceHandle": "error",
        "label": "Erro"
      },
      {
        "id": "e_pago_tag_pagou",
        "source": "pago",
        "target": "tag_pagou"
      },
      {
        "id": "e_tag_pagou_ganho",
        "source": "tag_pagou",
        "target": "ganho"
      },
      {
        "id": "e_pendente_espera_fim",
        "source": "pendente",
        "target": "espera_fim"
      },
      {
        "id": "e_espera_fim_status_fim",
        "source": "espera_fim",
        "target": "status_fim"
      },
      {
        "id": "e_status_fim_pago_paid",
        "source": "status_fim",
        "target": "pago",
        "sourceHandle": "paid",
        "label": "Paga"
      },
      {
        "id": "e_status_fim_expirado_expired",
        "source": "status_fim",
        "target": "expirado",
        "sourceHandle": "expired",
        "label": "Expirada"
      },
      {
        "id": "e_status_fim_erro_status_error",
        "source": "status_fim",
        "target": "erro_status",
        "sourceHandle": "error",
        "label": "Erro"
      }
    ]
  }
}
