{
  "name": "form-website",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "form-site",
        "authentication": "basicAuth",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        912,
        -896
      ],
      "id": "259a1831-0887-4346-b773-cadc8eaf9cea",
      "name": "Webhook",
      "webhookId": "3142df9e-d10b-4a95-8602-73b48e7a2c70",
      "credentials": {
        "httpBasicAuth": {
          "id": "1Bw4URTLpbDVB8u4",
          "name": "Website Forms Webhook credential"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "03fa6023-f760-47bf-ad01-ff737842ee1b",
              "name": "chatfluxx.url",
              "value": "app.neofluxx.com",
              "type": "string"
            },
            {
              "id": "2011128c-50ec-4216-a58a-f5355782be81",
              "name": "chatfluxx.account_id",
              "value": "16",
              "type": "string"
            },
            {
              "id": "df05deaf-8947-4c0c-a9c6-5982831c7b22",
              "name": "chatfluxx.api_access_token",
              "value": "iZtHR98XNgqEdsUUDvTSNb4j",
              "type": "string"
            },
            {
              "id": "4185cfb9-0de5-47c9-a297-77a28456fb5c",
              "name": "chatfluxx.team_id",
              "value": "14",
              "type": "string"
            },
            {
              "id": "c4470306-615d-44fc-8a21-ace001cf96a4",
              "name": "chatfluxx.inbox_id",
              "value": "99",
              "type": "string"
            },
            {
              "id": "d998f8b8-e1da-47dc-91fa-593b240b360c",
              "name": "chatfluxx.contact_id",
              "value": "72971",
              "type": "string"
            },
            {
              "id": "f1d3ac4f-c318-4144-ba89-b9571f8740a5",
              "name": "chatfluxx.source_id",
              "value": "fed3a956-d3cb-4abe-8c01-e041bb9e9aa2",
              "type": "string"
            },
            {
              "id": "a8dae68c-e77c-40a1-88c8-53f68d250ec2",
              "name": "chatfluxx.assignee_id",
              "value": "2",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1360,
        -896
      ],
      "id": "b48917a4-8829-4a4d-ab53-659ef9a53731",
      "name": "w-cfg"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://{{ $('w-cfg').item.json.chatfluxx.url }}/api/v1/accounts/{{ $('w-cfg').item.json.chatfluxx.account_id }}/conversations",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"source_id\": \"{{ $json.source_id }}\",\n  \"inbox_id\": {{ $json.inbox_id }},\n  \"contact_id\": {{ $json.contact_id }},\n  \"status\": \"open\",\n  \"team_id\": {{ $('w-cfg').item.json.chatfluxx.team_id }},\n  \"assignee_id\": {{ $('w-cfg').item.json.chatfluxx.assignee_id }}\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        3824,
        -896
      ],
      "id": "294de6d9-2b60-457e-9fd9-a426f00944f1",
      "name": "Create Conversation",
      "retryOnFail": true,
      "credentials": {
        "httpHeaderAuth": {
          "id": "jXJXoudoAwmSaD4P",
          "name": "Header Auth account (Chatfluxx)"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://{{ $('w-cfg').item.json.chatfluxx.url }}/api/v1/accounts/{{ $('w-cfg').item.json.chatfluxx.account_id }}/conversations/{{$('Create Conversation').item.json.id}}/toggle_priority",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"priority\": \"medium\"\n}",
        "options": {
          "response": {
            "response": {
              "fullResponse": true,
              "responseFormat": "json"
            }
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        4272,
        -896
      ],
      "id": "3f9042bf-9750-4463-8a65-6e8772e841e2",
      "name": "Toggle Priority",
      "retryOnFail": true,
      "credentials": {
        "httpHeaderAuth": {
          "id": "jXJXoudoAwmSaD4P",
          "name": "Header Auth account (Chatfluxx)"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const body = $json.body;\n\nconst textoFormatado = Object.entries(body)\n  .map(([chave, valor]) => {\n    if (Array.isArray(valor)) {\n      return `• ${chave}: ${valor.join(', ')}`;\n    }\n\n    if (typeof valor === 'boolean') {\n      return `• ${chave}: ${valor ? 'true' : 'false'}`;\n    }\n\n    return `• ${chave}: ${valor}`;\n  })\n  .join('\\n');\n\nreturn [\n  {\n    json: {\n      content: textoFormatado\n    }\n  }\n];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1136,
        -896
      ],
      "id": "91f8212c-5616-4d00-9865-4d96b932605d",
      "name": "Normaliza Infos"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://{{$('w-cfg').item.json.chatfluxx.url}}/api/v1/accounts/{{$('w-cfg').item.json.chatfluxx.account_id}}/contacts",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"inbox_id\": {{ $('w-cfg').item.json.chatfluxx.inbox_id }},\n  \"name\": \"{{ $('Webhook').item.json.body.FullName }}\",\n  \"email\": \"{{ $('Webhook').item.json.body.Email }}\",\n  \"blocked\": false,\n  \"phone_number\": \"+{{ $('Webhook').item.json.body.WhatsApp }}\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        2480,
        -752
      ],
      "id": "95ceb70d-8954-4030-81b9-83336266b70b",
      "name": "Create Contact",
      "retryOnFail": true,
      "credentials": {
        "httpHeaderAuth": {
          "id": "jXJXoudoAwmSaD4P",
          "name": "Header Auth account (Chatfluxx)"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://{{ $('w-cfg').item.json.chatfluxx.url }}/api/v1/accounts/{{ $('w-cfg').item.json.chatfluxx.account_id }}/contacts/{{ $json.payload.contact.id }}/labels",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"labels\": [\n    \"lead-site\",\n    {{ JSON.stringify($('Webhook').item.json.body.Tags[0].toLowerCase()) }}\n  ]\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        2704,
        -752
      ],
      "id": "d4a147e4-7661-4b3e-b2d4-fb578ea7a394",
      "name": "Add Labels to Contact",
      "retryOnFail": true,
      "credentials": {
        "httpHeaderAuth": {
          "id": "3T1PJWzmOt3ZuZEY",
          "name": "Header Auth account (UazapiGo)"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://{{ $('w-cfg').item.json.chatfluxx.url }}/api/v1/accounts/{{ $('w-cfg').item.json.chatfluxx.account_id }}/conversations/{{ $json.id}}/labels",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"labels\": [\n    \"lead-site\",\n    {{ JSON.stringify($('Webhook').item.json.body.Tags[0].toLowerCase()) }}\n  ]\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        4048,
        -896
      ],
      "id": "f87a1368-ac5d-42d1-b27e-0ee7311d07ce",
      "name": "Add Labels to Conversation",
      "retryOnFail": true,
      "credentials": {
        "httpHeaderAuth": {
          "id": "jXJXoudoAwmSaD4P",
          "name": "Header Auth account (Chatfluxx)"
        }
      }
    },
    {
      "parameters": {
        "content": "## Webhook Basic Auth\n\n## user: bestpass.travel\n## token: J0eX0jkrP50YZzfj\n## endpoint: https://n8n.bestpass.travel/webhook/form-site",
        "height": 240,
        "width": 704
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        -1360
      ],
      "typeVersion": 1,
      "id": "ffccd57f-966e-4f77-907b-3c11c8f17485",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "method": "=GET",
        "url": "=https://{{ $json.chatfluxx.url }}/api/v1/accounts/{{ $json.chatfluxx.account_id }}/contacts/search?q={{ $('Webhook').item.json.body.Email }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "api_access_token",
              "value": "={{ $json.chatfluxx.api_access_token }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        1584,
        -896
      ],
      "id": "6c3ca3e1-4b37-4b49-af25-643fd517e8ed",
      "name": "Search Contacts by e-mail",
      "credentials": {
        "httpHeaderAuth": {
          "id": "jXJXoudoAwmSaD4P",
          "name": "Header Auth account (Chatfluxx)"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "16a252d4-8941-49f3-8296-125b5219eb57",
              "leftValue": "={{ $json.meta.count }}",
              "rightValue": 0,
              "operator": {
                "type": "number",
                "operation": "gt"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        1808,
        -896
      ],
      "id": "330f7ada-4c37-4593-bc92-0e93b6f1abe5",
      "name": "Existe Contato por e-mail?"
    },
    {
      "parameters": {
        "method": "=GET",
        "url": "=https://{{ $('w-cfg').item.json.chatfluxx.url }}/api/v1/accounts/{{ $('w-cfg').item.json.chatfluxx.account_id }}/contacts/search?q={{ $('Webhook').item.json.body.WhatsApp }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        2032,
        -832
      ],
      "id": "23dd91e1-8175-4000-b0c8-9e2ff6577790",
      "name": "Search Contacts by phone",
      "credentials": {
        "httpHeaderAuth": {
          "id": "jXJXoudoAwmSaD4P",
          "name": "Header Auth account (Chatfluxx)"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "16a252d4-8941-49f3-8296-125b5219eb57",
              "leftValue": "={{ $json.meta.count }}",
              "rightValue": 0,
              "operator": {
                "type": "number",
                "operation": "gt"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        2256,
        -832
      ],
      "id": "dd95408b-3b59-4cc3-958a-f2710793a28a",
      "name": "Existe Contato por phone?"
    },
    {
      "parameters": {
        "jsCode": "const inboxId = Number($('w-cfg').item.json.chatfluxx.inbox_id);\n\nlet contact = null;\nlet sourceId = null;\nlet origin = null;\n\n// 1) Se o contato acabou de ser criado pelo fluxo, o Chatwoot normalmente devolve payload.contact e payload.contact_inbox.\ntry {\n  const createdPayload = $('Create Contact').item.json.payload;\n\n  if (createdPayload?.contact) {\n    contact = createdPayload.contact;\n    origin = 'created_contact';\n\n    const createdContactInbox = createdPayload.contact_inbox;\n\n    if (createdContactInbox?.source_id) {\n      return [\n        {\n          json: {\n            contact_id: contact.id,\n            source_id: createdContactInbox.source_id,\n            inbox_id: inboxId,\n            has_contact_inbox: true,\n            origin,\n          },\n        },\n      ];\n    }\n  }\n} catch (error) {}\n\n// 2) Se encontrou por e-mail, usa esse contato.\ntry {\n  const emailPayload = $('Search Contacts by e-mail').item.json.payload;\n\n  if (Array.isArray(emailPayload) && emailPayload.length > 0) {\n    contact = emailPayload[0];\n    origin = 'found_by_email';\n  }\n} catch (error) {}\n\n// 3) Se não encontrou por e-mail, tenta usar o contato encontrado por telefone.\ntry {\n  const phonePayload = $('Search Contacts by phone').item.json.payload;\n\n  if (!contact && Array.isArray(phonePayload) && phonePayload.length > 0) {\n    contact = phonePayload[0];\n    origin = 'found_by_phone';\n  }\n} catch (error) {}\n\nif (!contact) {\n  throw new Error('Nenhum contato encontrado ou criado antes de criar a conversa.');\n}\n\nconst contactInboxes = contact.contact_inboxes || [];\n\n// Ponto principal da correção:\n// não usar contact_inboxes[0]; usar o contact_inbox pertencente ao inbox_id configurado.\nconst contactInbox = contactInboxes.find((ci) => {\n  const currentInboxId = Number(ci.inbox?.id || ci.inbox_id);\n  return currentInboxId === inboxId;\n});\n\nsourceId = contactInbox?.source_id || null;\n\nreturn [\n  {\n    json: {\n      contact_id: contact.id,\n      source_id: sourceId,\n      inbox_id: inboxId,\n      has_contact_inbox: Boolean(contactInbox && sourceId),\n      origin,\n    },\n  },\n];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2928,
        -896
      ],
      "id": "4053a904-3cd3-479f-af7b-b4030a915afa",
      "name": "Resolve Contact Inbox"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "e97a3be4-4294-453e-822e-b527f20f2700",
              "leftValue": "={{ $json.has_contact_inbox }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        3152,
        -896
      ],
      "id": "fe26731e-1929-4f08-9003-f4dfd7e7209b",
      "name": "Tem Contact Inbox do Inbox?"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://{{ $('w-cfg').item.json.chatfluxx.url }}/api/v1/accounts/{{ $('w-cfg').item.json.chatfluxx.account_id }}/contacts/{{ $('Resolve Contact Inbox').item.json.contact_id }}/contact_inboxes",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"inbox_id\": {{ $('w-cfg').item.json.chatfluxx.inbox_id }},\n  \"source_id\": \"{{ $('Webhook').item.json.body.WhatsApp }}\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        3376,
        -832
      ],
      "id": "2edf7b10-6a94-4ff9-8b0e-af58da7b606e",
      "name": "Create Contact Inbox",
      "retryOnFail": true,
      "credentials": {
        "httpHeaderAuth": {
          "id": "jXJXoudoAwmSaD4P",
          "name": "Header Auth account (Chatfluxx)"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const response = $json;\n\nconst sourceId =\n  response.source_id ||\n  response.payload?.source_id ||\n  response.payload?.contact_inbox?.source_id ||\n  response.contact_inbox?.source_id ||\n  `form_site_${$('Webhook').item.json.body.WhatsApp}`;\n\nreturn [\n  {\n    json: {\n      contact_id: $('Resolve Contact Inbox').item.json.contact_id,\n      source_id: sourceId,\n      inbox_id: Number($('w-cfg').item.json.chatfluxx.inbox_id),\n      has_contact_inbox: true,\n      origin: 'created_contact_inbox',\n    },\n  },\n];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        3600,
        -832
      ],
      "id": "b47854d1-3300-44a3-bfdc-8d0999dfbe5a",
      "name": "Normaliza Contact Inbox"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://{{ $('w-cfg').item.json.chatfluxx.url }}/api/v1/accounts/{{ $('w-cfg').item.json.chatfluxx.account_id }}/conversations/{{ $('Create Conversation').first().json.id }}/messages\n\n",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"content\": {{ JSON.stringify($('Normaliza Infos').item.json.content) }},\n  \"message_type\": \"outgoing\",\n  \"private\": true,\n  \"content_type\": \"text\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        4496,
        -896
      ],
      "id": "03b99f01-8aea-4c35-a661-6efa9b18baae",
      "name": "Create New Private Chat Message",
      "retryOnFail": true,
      "credentials": {
        "httpHeaderAuth": {
          "id": "jXJXoudoAwmSaD4P",
          "name": "Header Auth account (Chatfluxx)"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://{{ $('w-cfg').item.json.chatfluxx.url }}/api/v1/accounts/{{ $('w-cfg').item.json.chatfluxx.account_id }}/conversations/{{ $json.conversation_id }}/messages",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"content\": \"Enviado template de mensagem [boasvindas_b2c_01]\",\n  \"message_type\": \"outgoing\",\n  \"private\": false,\n  \"template_params\": {\n    \"name\": \"boasvindas_b2c_01\",\n    \"category\": \"MARKETING\",\n    \"language\": \"pt_BR\",\n    \"processed_params\": {\n      \"body\": {\n        \"1\": \"{{ ($('Webhook').item.json.body.FullName || '').trim().split(/\\s+/)[0] }}\"\n      }\n    }\n  }\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        4768,
        -896
      ],
      "id": "fcc2214c-f7ed-4bb1-a7f5-4d4920225e83",
      "name": "Create Template Message",
      "retryOnFail": true,
      "credentials": {
        "httpHeaderAuth": {
          "id": "jXJXoudoAwmSaD4P",
          "name": "Header Auth account (Chatfluxx)"
        }
      }
    }
  ],
  "pinData": {
    "Webhook": [
      {
        "json": {
          "headers": {
            "connection": "Keep-Alive",
            "host": "n8n.bestpass.travel",
            "x-forwarded-scheme": "http",
            "x-forwarded-proto": "http",
            "x-forwarded-for": "20.201.118.214, 172.69.114.91",
            "x-real-ip": "172.69.114.91",
            "content-length": "125",
            "authorization": "Basic YmVzdHBhc3MudHJhdmVsOkowZVgwamtyUDUwWVp6Zmo=",
            "request-context": "appId=cid-v1:635b5e94-b76e-4537-9117-31ed1a49cb4d",
            "content-type": "application/json; charset=utf-8",
            "traceparent": "00-6f6cc3bd8f876bf53c6d05bd027231ad-69c0f1c0c2abf860-00",
            "cf-ray": "9f70549f7fdb6274-GRU",
            "request-id": "|6f6cc3bd8f876bf53c6d05bd027231ad.69c0f1c0c2abf860.",
            "cdn-loop": "cloudflare; loops=1",
            "cf-connecting-ip": "20.201.118.214",
            "cf-ipcountry": "BR",
            "cf-visitor": "{\"scheme\":\"https\"}",
            "accept-encoding": "gzip, br"
          },
          "params": {},
          "query": {},
          "body": {
            "FullName": "Sergio Pironato Junior",
            "WhatsApp": "5511982084044",
            "Tags": [
              "B2C"
            ],
            "Email": "sjr1201@gmail.com",
            "AgreeTerms": true
          },
          "webhookUrl": "https://n8n.bestpass.travel/webhook/form-site",
          "executionMode": "production"
        },
        "pairedItem": {
          "item": 0
        }
      }
    ]
  },
  "connections": {
    "w-cfg": {
      "main": [
        [
          {
            "node": "Search Contacts by e-mail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normaliza Infos": {
      "main": [
        [
          {
            "node": "w-cfg",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Normaliza Infos",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Contact": {
      "main": [
        [
          {
            "node": "Add Labels to Contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Contacts by e-mail": {
      "main": [
        [
          {
            "node": "Existe Contato por e-mail?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Contacts by phone": {
      "main": [
        [
          {
            "node": "Existe Contato por phone?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Existe Contato por e-mail?": {
      "main": [
        [
          {
            "node": "Resolve Contact Inbox",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Search Contacts by phone",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Existe Contato por phone?": {
      "main": [
        [
          {
            "node": "Resolve Contact Inbox",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Create Contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add Labels to Contact": {
      "main": [
        [
          {
            "node": "Resolve Contact Inbox",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Resolve Contact Inbox": {
      "main": [
        [
          {
            "node": "Tem Contact Inbox do Inbox?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tem Contact Inbox do Inbox?": {
      "main": [
        [
          {
            "node": "Create Conversation",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Create Contact Inbox",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Contact Inbox": {
      "main": [
        [
          {
            "node": "Normaliza Contact Inbox",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normaliza Contact Inbox": {
      "main": [
        [
          {
            "node": "Create Conversation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Conversation": {
      "main": [
        [
          {
            "node": "Add Labels to Conversation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add Labels to Conversation": {
      "main": [
        [
          {
            "node": "Toggle Priority",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Toggle Priority": {
      "main": [
        [
          {
            "node": "Create New Private Chat Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create New Private Chat Message": {
      "main": [
        [
          {
            "node": "Create Template Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate"
  },
  "versionId": "f318bee0-0531-4f86-b92c-40d38bb343a0",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "231b62ab86295517a316dcbab72860738fdaeb87a0b16f5d61f8cedb008de282"
  },
  "id": "3HmNnMRAeTtr6TJ9",
  "tags": [
    {
      "updatedAt": "2026-04-23T19:27:59.422Z",
      "createdAt": "2026-04-23T19:27:59.422Z",
      "id": "EYMJQsVgfJqDcgnv",
      "name": "Chatfluxx"
    }
  ]
}