{
  "name": "My workflow 10",
  "nodes": [
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "80350bc7-6ae6-4659-abeb-fb99e9331f60",
              "name": "url",
              "value": "={{ $json.body.server_url }}",
              "type": "string"
            },
            {
              "id": "e4a15ec4-1aed-492d-afda-790c38c41e52",
              "name": "INSTANCIA",
              "value": "={{ $json.body.instance }}",
              "type": "string"
            },
            {
              "id": "e4696b1d-8965-48b8-97c9-267adbdc6cf5",
              "name": "APIKEY",
              "value": "={{ $json.body.apikey }}",
              "type": "string"
            },
            {
              "id": "dc2f6409-50ab-4bfb-8bf9-5eed7b749939",
              "name": "NUMERO_LEAD",
              "value": "={{ $json.body.data.key.remoteJid }}",
              "type": "string"
            },
            {
              "id": "1cb22a0c-0865-43b9-bc75-b875195650f6",
              "name": "MENSAGEM_TIPO",
              "value": "={{ $json.body.data.messageType }}",
              "type": "string"
            },
            {
              "id": "089ded7a-f817-4691-80e4-f2282f488dd6",
              "name": "MENSAGEM",
              "value": "={{ $json.body.data.message.conversation }}",
              "type": "string"
            },
            {
              "id": "1f6e49c9-7600-427f-a093-5d41e0d4fe15",
              "name": "message_id",
              "value": "={{ $json.body.data.key.id }}",
              "type": "string"
            },
            {
              "id": "72b77371-eca1-4654-9c08-c9e881f4b64a",
              "name": "hora",
              "value": "={{ $json.body.date_time }}",
              "type": "string"
            },
            {
              "id": "2cbf8083-4e4e-4195-a4a0-91657e7742d0",
              "name": "Base64",
              "value": "={{ $json.body.data.message.base64 }}",
              "type": "string"
            },
            {
              "id": "3e6d26bc-2a50-4682-94b8-78860d98595e",
              "name": "Mensagem_ID",
              "value": "={{ $json.body.data.key.id }}",
              "type": "string"
            },
            {
              "id": "875eb6c0-f23d-4bb5-9ae0-c6bb02cd297c",
              "name": "hora",
              "value": "={{ $json.body.date_time }}",
              "type": "string"
            },
            {
              "id": "6228bbab-3861-46ed-a097-6f8b76f561d7",
              "name": "fromMe",
              "value": "={{ $json.body.data.key.fromMe }}",
              "type": "boolean"
            }
          ]
        },
        "options": {}
      },
      "id": "12e4414e-e903-4b0f-a6d0-8f30eb80bb40",
      "name": "Tratamento de Dados",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -5760,
        380
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "7b1fb8c5-39a9-4c9c-a6be-c59c03037a49",
              "name": "Mensagem",
              "value": "={{ $json.MENSAGEM }}{{ $('Tratamento de Dados').item.json.MENSAGEM }}{{ $json.content }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "7ec61634-3f33-4c39-b111-68cabb31d693",
      "name": "Mensagem Principal",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -3860,
        400
      ]
    },
    {
      "parameters": {
        "resource": "audio",
        "operation": "transcribe",
        "binaryPropertyName": "=data2",
        "options": {}
      },
      "id": "c13f1b5a-392e-4871-8058-247fe0b70194",
      "name": "OpenAI1",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.4,
      "position": [
        -4300,
        600
      ],
      "credentials": {
        "openAiApi": {
          "id": "enKhHqNKibYUkzcO",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "aab56c59-e5ab-4a6a-a90f-52e8546a2a6a",
              "name": "MENSAGEM",
              "value": "={{ $json.text }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "9808f3f4-5791-44ba-8a7a-4ae8af79ae83",
      "name": "DEFINIR MENSAGEM",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -4080,
        600
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "cac09de4-58a9-43bb-aa94-b0bd16094a57",
              "leftValue": "={{ $('Evolution API').item.json.base64 }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "b591835e-93c2-474e-a3a0-300fb34fed32",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -5180,
        600
      ]
    },
    {
      "parameters": {
        "operation": "toBinary",
        "sourceProperty": "base64",
        "binaryPropertyName": "data2",
        "options": {
          "fileName": "foto.jpeg",
          "mimeType": "image/jpeg"
        }
      },
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        -4300,
        240
      ],
      "id": "2b13b641-8c76-4aaa-b374-6541d2bb8194",
      "name": "Convert to File1"
    },
    {
      "parameters": {
        "operation": "toBinary",
        "sourceProperty": "=data",
        "binaryPropertyName": "data2",
        "options": {
          "fileName": "audio.mp3",
          "mimeType": "audio/mpeg"
        }
      },
      "id": "07fe41b4-3aae-498b-abd7-8e03aaaf4434",
      "name": "Convert to File",
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        -4520,
        600
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "5840679c-7016-46e5-92d3-7179c11b62a6",
              "name": "base64",
              "value": "={{ $('Tratamento de Dados').item.json.Base64 }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -4520,
        240
      ],
      "id": "c6ebbbb2-6b8a-4a39-a945-d487ddd611a8",
      "name": "Imagem/Base64"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "40192510-4f2a-4a6d-adf7-eaf614a321f3",
              "name": "data",
              "value": "={{ $json.base64 }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "01674f3a-c391-4a52-afc2-bbc793edff9e",
      "name": "BASE",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -4740,
        600
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "7ba9b235-4f0b-4e29-8adb-0cd73113e41b",
              "leftValue": "={{ $json.id }}",
              "rightValue": 0,
              "operator": {
                "type": "number",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -2880,
        300
      ],
      "id": "120496d0-b3f5-47a6-8b12-5996d1a62834",
      "name": "If1"
    },
    {
      "parameters": {
        "url": "=https://api.openai.com/v1/threads/{{ $json.thread_id }}/messages?order=desc",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "openAiApi",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "limit",
              "value": "1"
            }
          ]
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "OpenAI-Beta",
              "value": "assistants=v2"
            }
          ]
        },
        "options": {}
      },
      "id": "1a65c468-5311-494c-bdff-da6e51e1b2a5",
      "name": "Verifica Última Mensagem - Post Retrieve Messages",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        -2660,
        240
      ],
      "credentials": {
        "openAiApi": {
          "id": "enKhHqNKibYUkzcO",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "10529067-5a89-4ca6-9b6a-bbf057eab11a",
                    "leftValue": "={{ $json.MENSAGEM_TIPO }}",
                    "rightValue": "imageMessage",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "IMAGEM"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.MENSAGEM_TIPO }}",
                    "rightValue": "conversation",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "26b52b69-f4b9-4246-b706-f27616c62023"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "TEXTO"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "6e37cd84-587f-49b7-b2ed-78d0666c1a9e",
                    "leftValue": "={{ $json.MENSAGEM_TIPO }}",
                    "rightValue": "audioMessage",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "AUDIO"
            }
          ]
        },
        "options": {}
      },
      "id": "256ce231-d37f-4e58-b393-d6473042fa16",
      "name": "Tipo de Mensagem",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -5400,
        400
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "68db7bec-7f2f-4948-be67-54fd27fb0770",
        "options": {}
      },
      "id": "d1ff5aa6-7644-4384-b125-a281b13c42de",
      "name": "Evolution API",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -5960,
        380
      ],
      "webhookId": "68db7bec-7f2f-4948-be67-54fd27fb0770"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.openai.com/v1/threads",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "openAiApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "OpenAI-Beta",
              "value": "assistants=v2"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "{\n  \"messages\": [\n    {\n      \"role\": \"assistant\",\n      \"content\": \"Responda a mensagem do lead com uma saudacao (Uma unica vez) e se necessario tambem a pergunta que ele fez, se apresente como [nome] e pergunte como você pode ajudar, saudação ideal: Olá tudo bem? Eu sou a [nome]. Qual o seu nome?\"\n    }\n  ]\n}",
        "options": {}
      },
      "id": "3f4822d5-a431-4802-863c-8ffeb564cb2c",
      "name": "Cria Thread - Banco de Dados",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -2660,
        560
      ],
      "credentials": {
        "openAiApi": {
          "id": "enKhHqNKibYUkzcO",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.openai.com/v1/threads/{{ $('Supabase').item.json.thread_id }}/messages",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "openAiApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "OpenAI-Beta",
              "value": "assistants=v2"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "role",
              "value": "user"
            },
            {
              "name": "content",
              "value": "={{ $('Mensagem Principal').item.json.Mensagem }}"
            }
          ]
        },
        "options": {}
      },
      "id": "d734e361-c2df-474d-9694-259d2d8bc0de",
      "name": "Puxa Histórico de Mensagens",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -2220,
        360
      ],
      "credentials": {
        "openAiApi": {
          "id": "enKhHqNKibYUkzcO",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "method": "=POST",
        "url": "={{ $json.url }}/chat/getBase64FromMediaMessage/{{ $('Tratamento de Dados').item.json.INSTANCIA }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "apikey",
              "value": "={{ $('Tratamento de Dados').item.json.APIKEY }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"message\": {\n    \"key\": {\n      \"id\": \"{{ $json.message_id }}\"\n    }\n  },\n  \"convertToMp4\": true\n} ",
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "id": "a86020af-3670-4aa1-8b13-21d36c4c7191",
      "name": "HTTP Request1",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -4960,
        660
      ]
    },
    {
      "parameters": {
        "operation": "get",
        "tableId": "LEADS",
        "filters": {
          "conditions": [
            {
              "keyName": "number",
              "keyValue": "={{ $('Tipo de Mensagem').item.json.NUMERO_LEAD }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        -3100,
        380
      ],
      "id": "1a6cba20-05ff-489a-ba04-4c7ef707e78c",
      "name": "Supabase",
      "alwaysOutputData": true,
      "credentials": {
        "supabaseApi": {
          "id": "j2dHliCnAbaNqRCg",
          "name": "Supabase account"
        }
      }
    },
    {
      "parameters": {
        "tableId": "LEADS",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "number",
              "fieldValue": "={{ $('Tratamento de Dados').item.json.NUMERO_LEAD }}"
            },
            {
              "fieldId": "thread_id",
              "fieldValue": "={{ $json.id }}"
            },
            {
              "fieldId": "created_at",
              "fieldValue": "={{ $('Tratamento de Dados').item.json.hora }}"
            },
            {
              "fieldId": "timeout",
              "fieldValue": "={{ $('Tratamento de Dados').item.json.hora }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        -2440,
        560
      ],
      "id": "5d53600d-b34f-4e34-8d62-6434f893b42a",
      "name": "Supabase1",
      "retryOnFail": true,
      "maxTries": 5,
      "waitBetweenTries": 5000,
      "credentials": {
        "supabaseApi": {
          "id": "j2dHliCnAbaNqRCg",
          "name": "Supabase account"
        }
      }
    },
    {
      "parameters": {
        "descriptionType": "manual",
        "toolDescription": "Essa Tool precisa ser acionada para adicionar o nome do lead no supabase.",
        "tableId": "LEADS",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "lead_name",
              "fieldValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Field_Value', `Nome do lead/usuário`, 'string') }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabaseTool",
      "typeVersion": 1,
      "position": [
        -1420,
        640
      ],
      "id": "c617e756-6b8e-450f-be5d-bce2087cd33e",
      "name": "Supabase2",
      "credentials": {
        "supabaseApi": {
          "id": "j2dHliCnAbaNqRCg",
          "name": "Supabase account"
        }
      }
    },
    {
      "parameters": {
        "amount": 22
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        -1900,
        360
      ],
      "id": "b8196edf-7f30-4e5f-97ad-350d82561b8f",
      "name": "Wait1",
      "webhookId": "d1c53490-09da-4fdb-92c8-e674d5951919"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.openai.com/v1/threads/{{ $('Supabase').item.json.thread_id }}/messages",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "openAiApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "OpenAI-Beta",
              "value": "assistants=v2"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "role",
              "value": "user"
            },
            {
              "name": "content",
              "value": "={{ $('Mensagem Principal').item.json.Mensagem }}"
            }
          ]
        },
        "options": {}
      },
      "id": "07544c14-2e76-43f0-bbcb-f0a255c21d66",
      "name": "CREATE A THREAD2",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -2220,
        180
      ],
      "credentials": {
        "openAiApi": {
          "id": "enKhHqNKibYUkzcO",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "94a4c81d-969a-47b1-9f11-9fe2f596c65c",
              "leftValue": "={{ $json.data[0].role }}",
              "rightValue": "assistant",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -2440,
        240
      ],
      "id": "0b9364d8-c707-4785-b90d-f94640a568a0",
      "name": "Última mensagem foi do Assistente?1"
    },
    {
      "parameters": {
        "jsCode": "function getDayOfWeek(query) {\n    const [day, month, year] = query.split('/').map(Number);\n    const date = new Date(year, month - 1, day);\n    return date.toLocaleDateString('pt-BR', { weekday: 'long' });\n}\n\n// Array para armazenar os próximos 10 dias\nconst next10Days = [];\n\nfor (let i = 0; i < 10; i++) {\n    const date = new Date();\n    date.setDate(date.getDate() + i);\n\n    next10Days.push(` ${date.toLocaleDateString('pt-BR', { weekday: 'long' })}, ${date.toLocaleDateString('pt-BR')}`);\n}\n\nreturn [{ json: { resultado: next10Days.join('\\n') } }];\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -1260,
        340
      ],
      "id": "4cb89758-d42e-4f0e-b3ee-9b3074a010cc",
      "name": "Organizar Dias"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        620,
        360
      ],
      "id": "01678398-dec9-44e8-828c-4f64c11828e9",
      "name": "Loop Over Items"
    },
    {
      "parameters": {
        "jsCode": "// Obtém todos os itens do nó \"Code\"\nconst codeNode = $('Loop Over Items').all();\n\n// Verifica se há itens no nó \"Code\"\nif (!codeNode || codeNode.length === 0) {\n  return [{ json: { erro: \"Nenhum dado encontrado no nó 'Code'.\" } }];\n}\n\n// Array para armazenar os resultados\nconst output = [];\n\n// Processa cada item do nó \"Code\"\ncodeNode.forEach(item => {\n  // Obtém o texto corretamente\n  const text = item.json.result || \"\";\n\n  // Verifica se o texto é válido\n  if (!text || text.trim() === \"\") {\n    output.push({ json: { erro: \"Texto ausente ou inválido\" } });\n    return;\n  }\n\n  // Conta o número de caracteres na mensagem\n  const characterCount = text.length;\n\n  // Calcula os milissegundos (100 caracteres = 10000 ms)\n  const milliseconds = Math.floor((characterCount / 100) * 10000);\n\n  // Adiciona o resultado ao array de saída\n  output.push({ json: { result: text, characterCount, milliseconds } });\n});\n\n// Retorna os resultados\nreturn output;\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1000,
        360
      ],
      "id": "099203a0-c9d2-4a76-abfc-2f67ab75b916",
      "name": "Contabilizar Caracteres"
    },
    {
      "parameters": {
        "jsCode": "// Obtém a saída do nó \"BDR\"\nconst output = $('SDR').first().json?.output || '';\n\n// Remove espaços extras e conta os caracteres\nconst texto = output.trim();\nconst totalCaracteres = texto.length;\n\n// Se o texto for menor que 200 caracteres, retorna ele inteiro\nif (totalCaracteres <= 200) {\n    return [{ json: { result: texto } }];\n}\n\n// Expressão regular para encontrar os pontos de corte corretos\nconst regex = /(?<=[?.!])\\s+/g;\n\n// Divide o texto **mas não separa frases com menos de 200 caracteres**\nlet partes = [];\nlet buffer = \"\";\n\n// Percorre cada frase e agrupa até atingir o mínimo de 200 caracteres\ntexto.split(regex).forEach((frase) => {\n    if ((buffer + \" \" + frase).trim().length < 200) {\n        buffer += \" \" + frase;\n    } else {\n        partes.push(buffer.trim());\n        buffer = frase;\n    }\n});\n\n// Adiciona a última parte ao array\nif (buffer) {\n    partes.push(buffer.trim());\n}\n\n// Retorna cada bloco como um item separado para o n8n processar corretamente\nreturn partes.map(part => ({ json: { result: part } }));\n"
      },
      "id": "974e69f6-be76-442a-939a-7eabd84b6705",
      "name": "Code4",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        400,
        360
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "6ae1c853-7e81-4c35-b5af-56b7a0ce02a5",
              "leftValue": "={{ $json.output }}",
              "rightValue": "=AUDION8N",
              "operator": {
                "type": "string",
                "operation": "contains"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        120,
        360
      ],
      "id": "e0e9e10b-7d20-461b-a95d-729035131170",
      "name": "If3"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://evo.agentevende.store/message/sendText/AGENTEVENDECURSO",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "apiKey ",
              "value": "={{ $('Tratamento de Dados').item.json.APIKEY }}"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "number",
              "value": "={{ $('Tipo de Mensagem').item.json.NUMERO_LEAD }}"
            },
            {
              "name": "text",
              "value": "={{ $('Loop Over Items').item.json.result }}"
            },
            {
              "name": "delay",
              "value": "={{ $json.milliseconds }}"
            }
          ]
        },
        "options": {
          "allowUnauthorizedCerts": true
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1360,
        360
      ],
      "id": "7fb9de9f-d79f-4834-a78d-f00ef4689e83",
      "name": "Enviar Texto1"
    },
    {
      "parameters": {
        "name": "Envia_Audio",
        "description": "Call this TOOL to answer leads questions via audio. Send the audio only if the corresponding question is marked with: \"Enviar audio\"\n\nYour query should never be empty and must contain only what should be sent as audio.",
        "workflowId": {
          "__rl": true,
          "value": "UDuhOAhr1aRGMmU2",
          "mode": "list",
          "cachedResultName": "[PRIVADO] AUDIO [VENDEDOR]"
        },
        "fields": {
          "values": [
            {
              "name": "id_usuário",
              "stringValue": "={{ $('Tipo de Mensagem').item.json.NUMERO_LEAD }}"
            },
            {
              "name": "url",
              "stringValue": "={{ $('Tratamento de Dados').item.json.url }}"
            },
            {
              "name": "instancia",
              "stringValue": "={{ $('Tratamento de Dados').item.json.INSTANCIA }}"
            },
            {
              "name": "apikey",
              "stringValue": "={{ $('Tratamento de Dados').item.json.APIKEY }}"
            }
          ]
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 1.3,
      "position": [
        -980,
        640
      ],
      "id": "c6236d58-6dc0-4088-b06a-8581a1999c74",
      "name": "Envio de Áudio"
    },
    {
      "parameters": {
        "content": "# FLUXO 1 \n## Esse Fluxo é responsável por receber toda a mensagem e entender se ela é uma mensagem de áudio, de texto, ou uma imagem.\n",
        "height": 820,
        "width": 2580
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -6020,
        60
      ],
      "typeVersion": 1,
      "id": "437fb1ee-0a59-432a-bc96-9b7bafba7e32",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "## FLUXO 2\n### Esse fluxo é responsável pelo cadastro do lead na nossa tabela do Supabase e também pela criação da nossa Threads (Memória do Agente). É exatamente aqui que o fluxo armazena não só as mensagens que o lead manda, mas também as mensagens que o próprio agente envia; gerando mais contexto e mais assertividade no fluxo,",
        "height": 820,
        "width": 1680,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3280,
        60
      ],
      "typeVersion": 1,
      "id": "94019c4f-c002-499f-8d9a-0b3bf2d43e37",
      "name": "Sticky Note5"
    },
    {
      "parameters": {
        "content": "# AGENTE DE I.A\n\n## Responsável pelo cérebro do Agente, é aqui que ajustamos toda a parte de interação do fluxo. É importante que para mudar o prompt do seu agente você acesse o Playground da OpenAI. ",
        "height": 880,
        "width": 1480,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1540,
        20
      ],
      "typeVersion": 1,
      "id": "9a16b413-8180-4a65-88a7-a7a94eb6df24",
      "name": "Sticky Note6"
    },
    {
      "parameters": {
        "content": "# Retorno da Mensagem e envio da Mensagem por texto\n\n## É aqui que fazemos a repartição das mensagens para elas não irem grande demais; criamos o delay para dar aquele \"sentido\" digitando, e enviamos a mensagem por texto via Evolution API.",
        "height": 880,
        "width": 1600,
        "color": 2
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "typeVersion": 1,
      "id": "2f48431e-2465-4ba4-b9d1-076f8b70d31e",
      "name": "Sticky Note8"
    },
    {
      "parameters": {
        "name": "agendamento",
        "description": "=Chame esta ferramenta após o usuário informar nome e email e data do agendamento. \n\nNa variável \"nome\", você vai preencher o nome do usuário\n\nNa variável \"email\" você vai preencher o email do usuário\n\nNa variável \"dia\" você vai preencher o dia desejado que ele tem mais facilidade em fazer a call\n\nNa variável \"histórico\" você vai subir o histórico das ultimas 3 mensagens.\n\n\nA data do agendamento você vai transformar para seguinte formato, exemplo: 2024-10-18T14:30:00-03:00\n\nEm seguida você vai inserir uma hora a mais depois no horario de agendamento e na variavel \"end\" você vai prencher com o horario no mesmo formato da variavel start",
        "workflowId": {
          "__rl": true,
          "value": "pEmfDrdbeB16KG0V",
          "mode": "list",
          "cachedResultName": "AGENDAMENTO GOOGLE"
        },
        "fields": {
          "values": [
            {
              "name": "Evento",
              "stringValue": "agendamento"
            },
            {
              "name": "Nome",
              "stringValue": "={{ $fromAI(\"nome\",\"email do cliente para fazer agendamento\",\"string\",\"\")}}"
            },
            {
              "name": "Email",
              "stringValue": "={{ $fromAI(\"email\",\"email do cliente para fazer agendamento\",\"string\",\"\")}}"
            },
            {
              "name": "Hora_desejada",
              "stringValue": "={{ $fromAI(\"hora\",\"email do cliente para fazer agendamento\",\"string\",\"\")}}"
            },
            {
              "name": "whatsappid",
              "stringValue": "={{ $('Tipo de Mensagem').item.json.NUMERO_LEAD }}"
            },
            {
              "name": "Historico_conversas",
              "stringValue": "={{ $('Mensagem Principal').item.json.Mensagem }}"
            }
          ]
        },
        "specifyInputSchema": true,
        "jsonSchemaExample": "{\n  \"nome\": \"\",\n  \"email\": \"\",\n  \"tipo_evento\": \"agendamento\",\n  \"horario\": \"\",\n  \"conversationStory\": \"\"\n}\n"
      },
      "id": "efbdecb9-dd5c-4ad9-b02a-6a2a12031afe",
      "name": "agendamento",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 1.2,
      "position": [
        -460,
        640
      ]
    },
    {
      "parameters": {
        "name": "REagendar",
        "description": "=Após o usuário informar que quer REAGENDAR ou que já tem horário, e colete o nome, email e nova data Chame esta tool\n\nNa variável \"nome\", você vai preencher o nome do usuário e na variavel \"email\" você vai preencher com email do usuário\n\nA data do agendamento você vai transformar para seguinte formato, exemplo: 2024-10-18T14:30:00-03:00 e vai preencher a variavel \"start\"\n\nEm seguida você vai inserir uma hora a mais depois no horario de agendamento e na variavel \"end\" você vai prencher com o horario no mesmo formato da variavel start",
        "workflowId": {
          "__rl": true,
          "value": "pEmfDrdbeB16KG0V",
          "mode": "list",
          "cachedResultName": "AGENDAMENTO GOOGLE"
        },
        "fields": {
          "values": [
            {
              "name": "Evento",
              "stringValue": "reagendamento"
            },
            {
              "name": "Email",
              "stringValue": "={{ $fromAI(\"email_cliente\",\"email do cliente para fazer agendamento\",\"string\",\"\")}}"
            },
            {
              "name": "Nome",
              "stringValue": "={{ $fromAI(\"nome_cliente\",\"nome do cliente para fazer agendamento\",\"string\",\"\")}}"
            },
            {
              "name": "whatsappId",
              "stringValue": "={{ $('Tratamento de Dados').item.json.NUMERO_LEAD }}"
            },
            {
              "name": "Historico_conversas",
              "stringValue": "={{ $('Mensagem Principal').item.json.Mensagem }}"
            }
          ]
        },
        "specifyInputSchema": true,
        "jsonSchemaExample": "{\n  \"nome\": \"\",\n  \"email\": \"\",\n  \"tipo_evento\": \"reagendamento\",\n  \"horario\": \"\",\n  \"conversationStory\": \"\"\n}\n"
      },
      "id": "526b7c21-ee87-4c3a-956c-59739f5e6ef0",
      "name": "reagendamento",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 1.2,
      "position": [
        -600,
        640
      ]
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.toolCalculator",
      "typeVersion": 1,
      "position": [
        -180,
        640
      ],
      "id": "334cbae4-7fff-4658-9359-97b18e993c65",
      "name": "Calculator"
    },
    {
      "parameters": {
        "name": "disponibilidade",
        "description": "=CHAME ESTA TOOL PARA sempre que precisar conferir a DISPONIBILIDADE na agenda antes de agendar qualquer cliente e encontrar horários disponíveis.\n\nRegras:\nTraga apenas os horários disponíveis entre 09:00 e 18:00.\n\nConsidere os horários já ocupados e não marque nenhum agendamento nesses intervalos.\n\nRetorne exatamente 2 horários disponíveis por dia, considerando 3 dias diferentes.",
        "workflowId": {
          "__rl": true,
          "value": "pEmfDrdbeB16KG0V",
          "mode": "list",
          "cachedResultName": "AGENDAMENTO GOOGLE"
        },
        "fields": {
          "values": [
            {
              "name": "Evento",
              "stringValue": "disponibilidade"
            },
            {
              "name": "Historico_conversas",
              "stringValue": "={{ $('Mensagem Principal').item.json.Mensagem }}"
            }
          ]
        },
        "specifyInputSchema": true,
        "jsonSchemaExample": "{\n  \"nome\": \"\",\n  \"email\": \"\",\n  \"tipo_evento\": \"disponibilidade\",\n  \"horario\": \"\",\n  \"conversationStory\": \"\"\n}\n"
      },
      "id": "9b67ac41-a0db-4624-b667-72633ea57aa3",
      "name": "disponibilidade",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 1.2,
      "position": [
        -320,
        640
      ]
    },
    {
      "parameters": {
        "name": "cancelamento",
        "description": "=Chame esta TOOL após o usuário informar que dedeseja cancelar, peça nome e email e data do agendamento. \n\nNa variável \"nome\", você vai preencher o nome do usuário\n\nNa variável \"email\" você vai preencher o email do usuário\n\nNa variável \"dia\" você vai preencher o dia desejado que ele tem mais facilidade em fazer a call\n\n\nA data do agendamento você vai transformar para seguinte formato, exemplo: 2024-10-18T14:30:00-03:00\n\nEm seguida você vai inserir uma hora a mais depois no horario de agendamento e na variavel \"end\" você vai prencher com o horario no mesmo formato da variavel start",
        "workflowId": {
          "__rl": true,
          "value": "pEmfDrdbeB16KG0V",
          "mode": "list",
          "cachedResultName": "AGENDAMENTO GOOGLE"
        },
        "fields": {
          "values": [
            {
              "name": "Email",
              "stringValue": "={{ $fromAI(\"email_cliente\",\"email do cliente para fazer agendamento\",\"string\",\"\")}}"
            },
            {
              "name": "Nome",
              "stringValue": "={{ $fromAI(\"nome_cliente\",\"nome do cliente para fazer agendamento\",\"string\",\"\")}}"
            },
            {
              "name": "evento",
              "stringValue": "cancelamento"
            },
            {
              "name": "whatsappID",
              "stringValue": "={{ $('Tratamento de Dados').item.json.NUMERO_LEAD }}"
            },
            {
              "name": "historico_conversas",
              "stringValue": "={{ $('Mensagem Principal').item.json.Mensagem }}"
            }
          ]
        },
        "specifyInputSchema": true,
        "jsonSchemaExample": "{\n  \"nome\": \"\",\n  \"email\": \"\",\n  \"tipo_evento\": \"cancelamento\",\n  \"horario\": \"\",\n  \"conversationStory\": \"\"\n}\n"
      },
      "id": "0abe7483-822d-4b40-ab8d-292f54d4d4bd",
      "name": "cancelamento",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 1.2,
      "position": [
        -740,
        640
      ]
    },
    {
      "parameters": {
        "name": "dia_semana",
        "description": "ESSA TOOL É OBRIGATÓRIA A SER A PRIMEIRA EXECUTADA PARA QUALQUER TIPO DE PROCESSO para identificar o dia da semana exato. Use essa tool para consultar o dia da semana.\nForneça como parâmetro uma data no formato dd/MM/yyyy",
        "jsCode": "const input = query;\n\n//AQUI O CHATGPT PODE SER LIVRE\nconst [day, month, year] = input.split('/').map(Number);\nconst date = new Date(year, month - 1, day);\n// ATÉ AQUI\nreturn date.toLocaleDateString('pt-BR', { weekday: 'long' });"
      },
      "type": "@n8n/n8n-nodes-langchain.toolCode",
      "typeVersion": 1.1,
      "position": [
        -1120,
        640
      ],
      "id": "35e22401-c95c-4b87-af1a-493c8ec86b55",
      "name": "dia_semana"
    },
    {
      "parameters": {
        "content": "# SDR "
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -6380,
        420
      ],
      "typeVersion": 1,
      "id": "906389b0-636d-44fc-8f30-804be6ac360f",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "10b122b1-23d1-4175-afa3-2f7617e63e27",
              "leftValue": "={{ $json.fromMe }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -5580,
        380
      ],
      "id": "ecead472-4311-4f07-a928-d71979bc3086",
      "name": "If2"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        -5400,
        220
      ],
      "id": "280a44ca-dc9a-4cfb-85e9-59e6b6c0536c",
      "name": "No Operation, do nothing"
    },
    {
      "parameters": {
        "resource": "assistant",
        "assistantId": {
          "__rl": true,
          "value": "asst_cev5SvSnQPa426myufijySDd",
          "mode": "list",
          "cachedResultName": "LÚCIO SDR"
        },
        "prompt": "define",
        "text": "=Dia e Horário da Mensagem: {{ $now }}\n\n#NOTAS:\n\n-NÃO RETORNE UMA RESPOSTA EM MARKDOWN\n-NÃO RETORNE RESPOSTAS COM CARACTERES ESPECIAIS.\n\nSe no Google Sheets tiver \"Envio de áudio?:Enviar áudio\", ativa a Tool \"ÁUDIO\" na mesma hora. ",
        "memory": "threadId",
        "threadId": "={{ $('Supabase').item.json.thread_id }}",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.7,
      "position": [
        -940,
        340
      ],
      "id": "897c906e-96e0-4c7d-a3fb-c62600deaed3",
      "name": "SDR",
      "retryOnFail": true,
      "credentials": {
        "openAiApi": {
          "id": "enKhHqNKibYUkzcO",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "resource": "image",
        "operation": "analyze",
        "modelId": {
          "__rl": true,
          "value": "chatgpt-4o-latest",
          "mode": "list",
          "cachedResultName": "CHATGPT-4O-LATEST"
        },
        "text": "Descreva exatamente o que está nesta imagem, o que ela representa, e fatores que podem ajudar a identificar o significado dela.",
        "inputType": "base64",
        "binaryPropertyName": "data2",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        -4080,
        240
      ],
      "id": "6cdfb2a6-c3c2-4959-95a6-4bf2b51e2e0c",
      "name": "OpenAI",
      "credentials": {
        "openAiApi": {
          "id": "enKhHqNKibYUkzcO",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "descriptionType": "manual",
        "toolDescription": "Ative essa tool SEMPRE e TODA vez que o usuário fizer uma pergunta sobre o produto/curso/ ou serviço dentro da conversa. Sempre use essa tool!",
        "documentId": {
          "__rl": true,
          "value": "1nxYNJstcWiXIwhvghV7tf5jotddxwBmrHdc7PJOM7_0",
          "mode": "list",
          "cachedResultName": "FAQ [AGENTEVENDE] AUDIO",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1nxYNJstcWiXIwhvghV7tf5jotddxwBmrHdc7PJOM7_0/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Página1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1nxYNJstcWiXIwhvghV7tf5jotddxwBmrHdc7PJOM7_0/edit#gid=0"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.5,
      "position": [
        -1260,
        640
      ],
      "id": "15bf667b-604f-4101-8a4a-6cdbb7ce6ffd",
      "name": "FAQ - GOOGLE SHEETS",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "fET52qCdePXdO2Hy",
          "name": "Google Sheets account"
        }
      }
    }
  ],
  "pinData": {
    "Evolution API": [
      {
        "json": {
          "headers": {
            "host": "n8neditor.agentevende.store",
            "user-agent": "axios/1.7.7",
            "content-length": "1013",
            "accept-encoding": "gzip, compress, deflate, br",
            "content-type": "application/json",
            "x-forwarded-for": "172.18.0.1",
            "x-forwarded-host": "n8neditor.agentevende.store",
            "x-forwarded-port": "443",
            "x-forwarded-proto": "https",
            "x-forwarded-server": "6ebe9615d8b2",
            "x-real-ip": "172.18.0.1"
          },
          "params": {},
          "query": {},
          "body": {
            "event": "messages.upsert",
            "instance": "AGENTEVENDECURSO",
            "data": {
              "key": {
                "remoteJid": "5522998030398@s.whatsapp.net",
                "fromMe": false,
                "id": "3EB0B742425D46C69E589D"
              },
              "pushName": "Quézia Demetrio",
              "status": "DELIVERY_ACK",
              "message": {
                "conversation": "Olá! Tudo bem por ai? Tenho dúvidas",
                "messageContextInfo": {
                  "deviceListMetadata": {
                    "senderKeyHash": "b93UqP1AbclHCQ==",
                    "senderTimestamp": "1742513696",
                    "senderAccountType": "E2EE",
                    "receiverAccountType": "E2EE",
                    "recipientKeyHash": "YlQcGCn6o99Osw==",
                    "recipientTimestamp": "1743082893"
                  },
                  "deviceListMetadataVersion": 2,
                  "messageSecret": "JRYUnGstZ+ZhWSePGZdV/pP1Lr1uzThFT+CvWlGvVPI="
                }
              },
              "messageType": "conversation",
              "messageTimestamp": 1743082997,
              "instanceId": "125ab9aa-8898-481a-a23f-7531add15bd0",
              "source": "web"
            },
            "destination": "https://n8neditor.agentevende.store/webhook-test/68db7bec-7f2f-4948-be67-54fd27fb0770",
            "date_time": "2025-03-27T10:43:17.380Z",
            "sender": "5519933001431@s.whatsapp.net",
            "server_url": "https://evolution-evolution.q0rndc.easypanel.host",
            "apikey": "C3E4F71BDFE4-4A7A-922F-70C87D151E75"
          },
          "webhookUrl": "https://n8nwebhook.agentevende.store/webhook-test/68db7bec-7f2f-4948-be67-54fd27fb0770",
          "executionMode": "test"
        }
      }
    ]
  },
  "connections": {
    "Tratamento de Dados": {
      "main": [
        [
          {
            "node": "If2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI1": {
      "main": [
        [
          {
            "node": "DEFINIR MENSAGEM",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "DEFINIR MENSAGEM": {
      "main": [
        [
          {
            "node": "Mensagem Principal",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "BASE",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "HTTP Request1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File": {
      "main": [
        [
          {
            "node": "OpenAI1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Imagem/Base64": {
      "main": [
        [
          {
            "node": "Convert to File1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "BASE": {
      "main": [
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File1": {
      "main": [
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mensagem Principal": {
      "main": [
        [
          {
            "node": "Supabase",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If1": {
      "main": [
        [
          {
            "node": "Verifica Última Mensagem - Post Retrieve Messages",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Cria Thread - Banco de Dados",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Verifica Última Mensagem - Post Retrieve Messages": {
      "main": [
        [
          {
            "node": "Última mensagem foi do Assistente?1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tipo de Mensagem": {
      "main": [
        [
          {
            "node": "Imagem/Base64",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Mensagem Principal",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Evolution API": {
      "main": [
        [
          {
            "node": "Tratamento de Dados",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Cria Thread - Banco de Dados": {
      "main": [
        [
          {
            "node": "Supabase1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Puxa Histórico de Mensagens": {
      "main": [
        [
          {
            "node": "Wait1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request1": {
      "main": [
        [
          {
            "node": "BASE",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Supabase": {
      "main": [
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Supabase1": {
      "main": [
        [
          {
            "node": "Supabase",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Supabase2": {
      "ai_tool": [
        [
          {
            "node": "SDR",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Wait1": {
      "main": [
        [
          {
            "node": "Organizar Dias",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Última mensagem foi do Assistente?1": {
      "main": [
        [
          {
            "node": "CREATE A THREAD2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Puxa Histórico de Mensagens",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Organizar Dias": {
      "main": [
        [
          {
            "node": "SDR",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Contabilizar Caracteres",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Contabilizar Caracteres": {
      "main": [
        [
          {
            "node": "Enviar Texto1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code4": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If3": {
      "main": [
        [],
        [
          {
            "node": "Code4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enviar Texto1": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Envio de Áudio": {
      "ai_tool": [
        [
          {
            "node": "SDR",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "agendamento": {
      "ai_tool": [
        [
          {
            "node": "SDR",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "reagendamento": {
      "ai_tool": [
        [
          {
            "node": "SDR",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Calculator": {
      "ai_tool": [
        [
          {
            "node": "SDR",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "disponibilidade": {
      "ai_tool": [
        [
          {
            "node": "SDR",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "cancelamento": {
      "ai_tool": [
        [
          {
            "node": "SDR",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "dia_semana": {
      "ai_tool": [
        [
          {
            "node": "SDR",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "If2": {
      "main": [
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Tipo de Mensagem",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SDR": {
      "main": [
        [
          {
            "node": "If3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI": {
      "main": [
        [
          {
            "node": "Mensagem Principal",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "FAQ - GOOGLE SHEETS": {
      "ai_tool": [
        [
          {
            "node": "SDR",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "dc26ef5f-38ab-42a1-bd6d-59f73901e846",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "08f792c88d6c17a03adaef9e98c81858795697599d5d63dc53224d9c2a9c8495"
  },
  "id": "lKQUHdXreCsCb319",
  "tags": [
    {
      "createdAt": "2025-03-04T23:06:10.476Z",
      "updatedAt": "2025-03-04T23:06:10.476Z",
      "id": "g3dqTIVg7CbBQcra",
      "name": "AGENTEVENDE"
    },
    {
      "createdAt": "2025-03-14T21:59:07.076Z",
      "updatedAt": "2025-03-14T21:59:07.076Z",
      "id": "ceapzG9CCHRBioq7",
      "name": "VENDEDOR"
    },
    {
      "createdAt": "2025-03-14T21:59:11.651Z",
      "updatedAt": "2025-03-14T21:59:11.651Z",
      "id": "GDbFOLYPZHxoIFWM",
      "name": "AULA"
    }
  ]
}