{
  "name": "Agent: IPTV (instance_e2165d22_1762376395079)",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "51313ab0-cdb6-4167-9910-fe4a2545c4e2",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -3024,
        224
      ],
      "id": "c6dd3d8a-1fdb-484a-a48d-178e22d6f371",
      "name": "Webhook"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "ddfc8c08-22d7-43e3-abad-b5cd3dfcdf13",
              "name": "Nome",
              "value": "={{ $json.body.data.pushName }}",
              "type": "string"
            },
            {
              "id": "da577156-0336-4cb8-98cf-acb620856825",
              "name": "Telefone",
              "value": "={{ $json.body.data.key.remoteJid.includes('@s.whatsapp.net') ? $json.body.data.key.remoteJid.split('@')[0] : $json.body.data.key.remoteJidAlt.split('@')[0] }}",
              "type": "string"
            },
            {
              "id": "3ba0eaa2-46cc-41a9-ac24-1f91aba1acca",
              "name": "tipoMensagem",
              "value": "={{ $json.body.data.messageType }}",
              "type": "string"
            },
            {
              "id": "e5af360f-3c55-4a41-bccf-0c764bdf6b4c",
              "name": "fremMe",
              "value": "={{ $json.body.data.key.fromMe }}",
              "type": "string"
            },
            {
              "id": "0fd39744-4570-425b-9898-424733135a4e",
              "name": "bloquearAgente",
              "value": "={{ $json.user_id + ':BloquearAgente:' + ($json.body.data.key.remoteJid.includes('@s.whatsapp.net') ? $json.body.data.key.remoteJid : $json.body.data.key.remoteJidAlt).replace('@s.whatsapp.net','') }}",
              "type": "string"
            },
            {
              "id": "64bd7c31-7555-4c11-a9dd-85cfb78b19b0",
              "name": "Mensagem",
              "value": "={{ $json.body.data.message.conversation }}",
              "type": "string"
            },
            {
              "id": "7a421dfe-7db5-4ad6-be47-f3e6d7b01bc9",
              "name": "msgPicotada",
              "value": "={{ $json.user_id + ':MensagemPicotada:' + ($json.body.data.key.remoteJid.includes('@s.whatsapp.net') ? $json.body.data.key.remoteJid : $json.body.data.key.remoteJidAlt) }}",
              "type": "string"
            },
            {
              "id": "a8f21c3e-9d56-4e17-bc42-f1e8d9a7b5c1",
              "name": "user_id",
              "value": "e2165d22-a30e-4d93-a0c3-3d90a7302ad2",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -2816,
        224
      ],
      "id": "74149fbc-b6ac-48ad-94fa-ee5c37e7a47d",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $('Edit Fields').item.json.tipoMensagem }}",
                    "rightValue": "conversation",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "b8a1042f-1d61-4a34-875b-25b15993a2d9"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Texto"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "87f39adc-b08d-453a-839f-7369a39afe1a",
                    "leftValue": "={{ $('Edit Fields').item.json.tipoMensagem }}",
                    "rightValue": "audioMessage",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Audio"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "2c8628c6-657d-42ad-926c-6a355fda90bb",
                    "leftValue": "={{ $('Edit Fields').item.json.tipoMensagem }}",
                    "rightValue": "imageMessage",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Imagem"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -2368,
        224
      ],
      "id": "ae0b83f1-31e2-4b92-ae9d-fd950a246bd3",
      "name": "Switch"
    },
    {
      "parameters": {
        "operation": "toBinary",
        "sourceProperty": "data",
        "options": {
          "fileName": "audio.mp3"
        }
      },
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        -1888,
        352
      ],
      "id": "4e1730ee-050c-40f6-9b8b-25fb791e11d6",
      "name": "Convert to File"
    },
    {
      "parameters": {
        "resource": "audio",
        "operation": "transcribe",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        -1664,
        352
      ],
      "id": "723968ba-8a4f-4a97-995d-6d94061b194e",
      "name": "OpenAI",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "c91c0065-d17a-41f3-8a0f-21772a5670f1",
              "name": "mensagemAudioemTexto",
              "value": "={{ $json.text }}",
              "type": "string"
            },
            {
              "id": "e771f841-569c-46fc-bfcd-df85f4e3298b",
              "name": "mensagemImagememTexto",
              "value": "={{ $json.content }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -1440,
        208
      ],
      "id": "14ce0d15-21a2-4f43-a9f6-4bebcbede517",
      "name": "Edit Fields1"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "5d74ff41-ebbc-4cbb-a1c5-f06801d577f0",
              "leftValue": "={{ $('Edit Fields').item.json.fremMe }}",
              "rightValue": "true",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -1184,
        320
      ],
      "id": "45b17d70-e173-4bda-89c8-ff86b5118ac6",
      "name": "If1"
    },
    {
      "parameters": {
        "operation": "set",
        "key": "={{ $('Edit Fields').item.json.bloquearAgente }}",
        "value": "true",
        "expire": true,
        "ttl": 600
      },
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        -944,
        240
      ],
      "id": "04652ad0-48f5-451f-ad2d-2186dd421a86",
      "name": "Redis",
      "credentials": {
        "redis": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "tableId": "messages",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "user_id",
              "fieldValue": "={{ $('Edit Fields').item.json.user_id }}"
            },
            {
              "fieldId": "content",
              "fieldValue": "={{ $('Edit Fields1').item.json.mensagemAudioemTexto || $('Edit Fields1').item.json.mensagemImagememTexto || $('Edit Fields').item.json.Mensagem }}"
            },
            {
              "fieldId": "sender_type",
              "fieldValue": "customer"
            },
            {
              "fieldId": "is_ai_generated",
              "fieldValue": "false"
            },
            {
              "fieldId": "status",
              "fieldValue": "received"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        -944,
        400
      ],
      "id": "8ddeb53d-1cc9-4d85-8f3e-c18fb6a8b679",
      "name": "Save Customer Message",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://cvyagrunpypnznptkcsf.supabase.co/rest/v1/rpc/upsert_conversation",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "supabaseApi",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ {\n  \"p_user_id\": $('Edit Fields').item.json.user_id,\n  \"p_contact_phone\": $('Edit Fields').item.json.Telefone,\n  \"p_contact_name\": $('Edit Fields').item.json.Nome\n} }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "text"
            }
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -720,
        400
      ],
      "id": "6d5c199c-25d3-4cfd-bf44-ceba70edd8d4",
      "name": "Upsert Conversation",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "get",
        "key": "={{ $('Edit Fields').item.json.bloquearAgente }}",
        "options": {}
      },
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        -512,
        400
      ],
      "id": "85402f67-d4a3-4e44-9251-a467c022a80e",
      "name": "Redis1",
      "credentials": {
        "redis": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "7093cc34-f209-4ea9-a755-721b3486cdab",
              "leftValue": "={{ $json.propertyName }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -496,
        224
      ],
      "id": "46c38019-d019-4105-bcf5-1d945ad0ddba",
      "name": "If2"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        -288,
        128
      ],
      "id": "f0288cad-4b0a-4197-8b27-9cf99373224f",
      "name": "No Operation, do nothing"
    },
    {
      "parameters": {
        "operation": "push",
        "list": "={{ $('Edit Fields').item.json.msgPicotada }}",
        "messageData": "={{ $json.mensagemAudioMaisTexto }}",
        "tail": true
      },
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        32,
        288
      ],
      "id": "759fcdac-4852-4c39-949f-e7faac2a6e14",
      "name": "Redis2",
      "credentials": {
        "redis": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "547a1227-9df2-4b0b-9c91-465326c0364f",
              "name": "mensagemAudioMaisTexto",
              "value": "={{ $('Edit Fields').item.json.Mensagem }}{{ $('Edit Fields1').item.json.mensagemAudioemTexto }}{{ $('Edit Fields1').item.json.mensagemImagememTexto }}\n\n\n\n",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -288,
        288
      ],
      "id": "6482759e-5362-438e-997f-c5f5485fa887",
      "name": "Edit Fields2"
    },
    {
      "parameters": {
        "operation": "get",
        "key": "={{ $('Edit Fields').item.json.msgPicotada }}",
        "options": {}
      },
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        464,
        288
      ],
      "id": "dd881a23-5808-42ed-b838-1e59f928cbba",
      "name": "Redis3",
      "credentials": {
        "redis": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "delete",
        "key": "={{ $('Edit Fields').item.json.msgPicotada }}"
      },
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        688,
        288
      ],
      "id": "12fb516c-efa8-4ec7-9bcb-808358f4abd1",
      "name": "Redis4",
      "credentials": {
        "redis": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.toString }}",
        "options": {
          "systemMessage": "=Hoje \u00e9 {{ $now.toFormat('EEEE, dd/MM/yyyy HH:mm') }} (hor\u00e1rio de Bras\u00edlia, UTC\u221203:00).\nSempre use essa data e hor\u00e1rio como base para responder perguntas sobre tempo, \"hoje\", \"amanh\u00e3\", \"semana que vem\", etc.\n\n\ud83d\udccb IDENTIFICA\u00c7\u00c3O DO CLIENTE:\n- O n\u00f3 \"Supabase\" no in\u00edcio do workflow busca os dados do cliente na tabela clientes_auroratech\n- Se o cliente J\u00c1 est\u00e1 cadastrado ({{ $('Supabase').item.json.nome }} retornou um valor), voc\u00ea J\u00c1 SABE o nome dele\n- NUNCA pergunte o nome novamente para clientes cadastrados\n- Use o nome naturalmente nas suas respostas: \"Ol\u00e1 {{ $('Supabase').item.json.nome }}!\", \"Como posso ajudar, {{ $('Supabase').item.json.nome }}?\"\n- Se o cliente N\u00c3O est\u00e1 cadastrado (nome vazio/null/undefined):\n  * Na primeira mensagem, pergunte educadamente: \"Qual seu nome para eu te chamar?\"\n  * Use a tool \"Criar ou atualizar contato no Supabase\" para salvar o nome\n  * Ap\u00f3s salvar, SEMPRE chame pelo nome nas pr\u00f3ximas mensagens\n- IMPORTANTE: N\u00e3o seja repetitivo com o nome. Use com naturalidade, como em uma conversa real.\n\n\ud83d\udcac Contexto do Agente:\nVoc\u00ea \u00e9 um assistente virtual inteligente. Siga estas regras importantes:\n\n1. **Captura de Nome do Cliente:**\n   - No in\u00edcio da conversa, ap\u00f3s a sauda\u00e7\u00e3o inicial, pergunte educadamente o nome completo do cliente\n   - Exemplo: \"Ol\u00e1! Tudo bem? Para te atender melhor, poderia me dizer seu nome completo?\"\n\n2. **Verifica\u00e7\u00e3o de Cliente Existente:**\n   - SEMPRE use a tool \"Consulta cliente\" ANTES de cadastrar um novo cliente\n   - Se o cliente j\u00e1 existir no banco, chame-o pelo nome cadastrado\n   - Se n\u00e3o existir, prossiga para o cadastro\n\n3. **Cadastro de Novo Cliente:**\n   - Quando o cliente fornecer o nome e voc\u00ea confirmar que ele N\u00c3O existe no banco, use a tool \"Cadastra Cliente\" para salvar\n   - Salve APENAS o nome fornecido pelo cliente (sem adicionar sobrenomes inventados)\n\n4. **Personaliza\u00e7\u00e3o:**\n   - Ap\u00f3s cadastrar ou encontrar o cliente, SEMPRE chame ele pelo nome durante toda a conversa\n   - Seja cordial, educado e profissional\n\n5. **Fluxo de Conversa:**\n   Primeira mensagem \u2192 Perguntar nome \u2192 Consultar se existe \u2192 Se n\u00e3o existe, cadastrar \u2192 Continuar atendimento chamando pelo nome\n   \nIDENTIDADE E PERSONALIDADE\nVoc\u00ea \u00e9 o atendente virtual oficial da Streman IPTV. Seja:\n\nCordial e profissional em todas as intera\u00e7\u00f5es\nDireto e objetivo nas respostas (m\u00e1ximo 2-3 linhas por resposta)\nProativo em oferecer solu\u00e7\u00f5es\nPaciente com d\u00favidas t\u00e9cnicas\n\nFLUXO DE ATENDIMENTO\nConsulte se cliente j\u00e1 \u00e9 cadastrado e use o nome dele consulta na tool consulta cliente.\n\ud83c\udf89 ABERTURA (Sempre iniciar assim)\n\nSempre consulte banco de dados saber se \u00e9 cliente e chamar pelo nome.\nExemplo Mensagem: \"Ol\u00e1 {Nome que esta no banco}\"! Bem-vindo \u00e0 Streman IPTV! \ud83d\ude0a Como posso ajud\u00e1-lo hoje?\"\n\ud83d\udc64 QUALIFICA\u00c7\u00c3O DO CLIENTE\n\nSe n\u00e3o tiver nome no banco Primeira pergunta: \"Voc\u00ea j\u00e1 \u00e9 nosso cliente?\"\nSe N\u00c3O for cliente:\n\n\"Qual seu nome para eu te atender melhor?\"\nAp\u00f3s o nome: \"Oi [Nome]! Tem alguma d\u00favida sobre nosso servi\u00e7o de IPTV?\"\n\nSe J\u00c1 for cliente:\n\n\"Perfeito! Em que posso ajud\u00e1-lo hoje? Renova\u00e7\u00e3o, suporte ou alguma d\u00favida?\"\n\n\n\n\ud83d\udcb0 INFORMA\u00c7\u00d5ES COMERCIAIS\nPlano \u00fanico:\n\nValor: R$ 35,00\nValidade: 30 dias corridos\nOferta especial: Teste GRATUITO de 4 horas para novos clientes\n\nScript de vendas:\n\"Nosso plano custa apenas R$ 35,00 por m\u00eas. Que tal experimentar com nosso teste de 4 horas? Assim voc\u00ea conhece a qualidade antes de assinar! \ud83d\udcfa\"\n\ud83d\udcfa CONTE\u00daDO DISPON\u00cdVEL\nResposta padr\u00e3o:\n\"Temos TODOS os canais abertos e fechados do Brasil, incluindo:\n\nPremiere e Combate (Pay Per View)\n+25.000 filmes atualizados\n+3.000 s\u00e9ries nacionais e internacionais\"\n\nConte\u00fado adulto (APENAS se perguntado):\n\"Dispon\u00edvel mediante solicita\u00e7\u00e3o na contrata\u00e7\u00e3o. \u00c9 s\u00f3 avisar que ativamos junto com seu login.\"\n\ud83d\udcb3 PAGAMENTO\nPIX: 12981493220\nScript: \"O pagamento \u00e9 via PIX: 12981493220. Ap\u00f3s enviar o comprovante, ativo seu acesso em at\u00e9 30 minutos.\"\nQuando receber comprovante: \"Comprovante recebido! J\u00e1 vou processar sua renova\u00e7\u00e3o/ativa\u00e7\u00e3o. Aguarde alguns minutos.\"\n\u2699\ufe0f SUPORTE T\u00c9CNICO\nPara problemas de conex\u00e3o/travamento:\n\"Vamos resolver isso! Fa\u00e7a este procedimento:\n\nReinicie o modem/roteador\nReinicie sua TV Box/Smart TV\nTeste novamente em 2 minutos\"\n\nSe persistir o problema:\n\"Vou verificar nossos sistemas e te dou retorno em instantes.\"\nPara login expirado:\n\"Seu acesso venceu. Para renovar \u00e9 R$ 35,00 via PIX: 12981493220\"\n\ud83d\udcf1 APLICATIVO\nApp oficial: IBO REVENDA\n\"Usamos o app IBO REVENDA - exclusivo para nossos clientes. Ap\u00f3s a ativa\u00e7\u00e3o, te envio o tutorial de instala\u00e7\u00e3o.\"\nRESPOSTAS R\u00c1PIDAS POR CATEGORIA\nVENDAS\n\nPre\u00e7o: \"R$ 35,00 por m\u00eas. Teste gr\u00e1tis de 4h dispon\u00edvel!\"\nConte\u00fado: \"Todos os canais + PPV + 10mil filmes + 3mil s\u00e9ries\"\nQualidade: \"Transmiss\u00e3o em HD/FHD, sem travamentos\"\n\nRENOVA\u00c7\u00c3O\n\nVencido: \"Para renovar: PIX R$ 35,00 para 12981493220\"\nComo renovar: \"Envie comprovante que ativo em 30 min\"\n\nSUPORTE\n\nTravando: \"Reinicie modem \u2192 TV Box \u2192 teste em 2 min\"\nN\u00e3o conecta: \"Verifique internet \u2192 reinicie equipamentos\"\nApp parou: \"Force fechamento \u2192 abra novamente\"\n\nINSTALA\u00c7\u00c3O\n\nNovo cliente: \"Ap\u00f3s pagamento envio: login, senha e tutorial\"\nApp: \"Baixe IBO REVENDA \u2192 configure com dados que enviarei\"\n\nREGRAS IMPORTANTES\n\u2705 SEMPRE FAZER:\n\nSer cordial e usar emojis moderadamente\nManter respostas curtas (m\u00e1ximo 3 linhas)\nOferecer teste para n\u00e3o-clientes\nConfirmar recebimento de comprovantes\nPersonalizar com o nome do cliente\n\n\u274c NUNCA FAZER:\n\nDar descontos n\u00e3o autorizados\nPrometer prazos irreais\nFalar de conte\u00fado adulto sem ser perguntado\nResolver problemas t\u00e9cnicos complexos (escalar para suporte)\nSer t\u00e9cnico demais nas explica\u00e7\u00f5es\n\nESCALA\u00c7\u00c3O\nQuando escalar para humano:\n\nProblemas t\u00e9cnicos complexos ap\u00f3s procedimentos b\u00e1sicos\nReclama\u00e7\u00f5es sobre cobran\u00e7a\nSolicita\u00e7\u00f5es de cancelamento\nProblemas que persistem ap\u00f3s 2 tentativas de solu\u00e7\u00e3o\n\nFrase para escala\u00e7\u00e3o: \"Vou conectar voc\u00ea com nosso suporte especializado para resolver isso rapidinho!\"\nM\u00c9TRICAS DE SUCESSO\n\nRespostas em at\u00e9 30 segundos\nM\u00e1ximo 3 linhas por resposta\nTaxa de convers\u00e3o de teste para venda\nResolu\u00e7\u00e3o de problemas em primeira intera\u00e7\u00e3o"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.9,
      "position": [
        1168,
        288
      ],
      "id": "d35b1ccf-c54a-45a0-a97d-754265e54905",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-5-nano",
          "mode": "list",
          "cachedResultName": "gpt-5-nano"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        784,
        592
      ],
      "id": "eaf39b0c-2d03-40ee-bf69-3155079c32c8",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        592,
        592
      ],
      "id": "8650d42b-b67b-4af6-9286-88b0b70d52da",
      "name": "Google Chat Model",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "tableId": "messages",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "user_id",
              "fieldValue": "={{ $('Edit Fields3').item.json.user_id }}"
            },
            {
              "fieldId": "content",
              "fieldValue": "={{ $('AI Agent').item.json.output }}"
            },
            {
              "fieldId": "sender_type",
              "fieldValue": "agent"
            },
            {
              "fieldId": "is_ai_generated",
              "fieldValue": "true"
            },
            {
              "fieldId": "status",
              "fieldValue": "sent"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        1472,
        288
      ],
      "id": "4536dc96-2bc3-4ede-b4fa-e4545912d9e6",
      "name": "Save Agent Message",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "c321c7c8-addc-4912-b1b4-316cc0bab974",
              "name": "toString",
              "value": "={{ $('Redis3').item.json.propertyName.toJsonString() }}",
              "type": "string"
            },
            {
              "id": "f7a8b9c0-d1e2-3f45-6789-a0b1c2d3e4f5",
              "name": "user_id",
              "value": "={{ $('Edit Fields').item.json.user_id }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        960,
        288
      ],
      "id": "73a5b1c8-e727-483a-ab5d-f8886c4a46c8",
      "name": "Edit Fields3"
    },
    {
      "parameters": {
        "operation": "get",
        "tableId": "clientes_auroratech",
        "filters": {
          "conditions": [
            {
              "keyName": "telefone",
              "keyValue": "={{ Number( $json.Telefone.replace(/[^0-9]/g, '') ) }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        -2576,
        224
      ],
      "id": "98f31e0e-3482-49bb-a4eb-7e09058eacde",
      "name": "Supabase",
      "alwaysOutputData": true,
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "descriptionType": "manual",
        "toolDescription": "Create a row in Supabase",
        "tableId": "clientes_auroratech",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "nome",
              "fieldValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('fieldValues0_Field_Value', `Aqui vai ser inserido o nome do cliente para cadastra na coluna nome da tabela clientes`, 'string') }}"
            },
            {
              "fieldId": "telefone",
              "fieldValue": "={{ Number( ($('Webhook').item.json.body.data.key.remoteJid.includes('@s.whatsapp.net') ? $('Webhook').item.json.body.data.key.remoteJid : $('Webhook').item.json.body.data.key.remoteJidAlt).split('@')[0] ) }}\n"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabaseTool",
      "typeVersion": 1,
      "position": [
        1152,
        592
      ],
      "id": "ff5db0fe-df92-4c87-941b-9d735a70b5c3",
      "name": "Cadastra Cliente",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "getAll",
        "tableId": "clientes_auroratech",
        "filters": {
          "conditions": [
            {
              "keyName": "telefone",
              "condition": "eq",
              "keyValue": "={{ Number( ($('Webhook').item.json.body.data.key.remoteJid.includes('@s.whatsapp.net') ? $('Webhook').item.json.body.data.key.remoteJid : $('Webhook').item.json.body.data.key.remoteJidAlt).split('@')[0] ) }}\n"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabaseTool",
      "typeVersion": 1,
      "position": [
        1312,
        592
      ],
      "id": "99b43c7d-ddf0-498b-a2b9-578ef096958a",
      "name": "Consulta cliente",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "toBinary",
        "sourceProperty": "data",
        "options": {
          "fileName": "file.png",
          "mimeType": "image/png"
        }
      },
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        -1888,
        560
      ],
      "id": "e80d5181-7250-4414-940f-89e6116a9008",
      "name": "Convert to File1"
    },
    {
      "parameters": {
        "resource": "image",
        "operation": "analyze",
        "modelId": {
          "__rl": true,
          "value": "gpt-4o-mini-2024-07-18",
          "mode": "list",
          "cachedResultName": "GPT-4O-MINI-2024-07-18"
        },
        "text": "Resumo curto da imagem. Responda sem acento, sem hifens",
        "inputType": "base64",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        -1664,
        560
      ],
      "id": "a93b3ccd-6de5-4d8b-a5bd-acf007570900",
      "name": "OpenAI1",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "3c5ccbc9-69d1-4b13-a7c3-e6945bc8c655",
              "name": "data",
              "value": "={{ $('Webhook').item.json.body.data.message.base64 }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "cd5dc068-640c-47e0-8dd2-0fa1c7ca625c",
      "name": "Edit Fields6",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -2144,
        560
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "3c5ccbc9-69d1-4b13-a7c3-e6945bc8c655",
              "name": "data",
              "value": "={{ $('Webhook').item.json.body.data.message.base64 }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "eee88364-fbe2-460b-88c8-e38138574214",
      "name": "Edit Fields7",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -2144,
        352
      ]
    },
    {
      "parameters": {
        "operation": "get",
        "tableId": "events",
        "filters": {
          "conditions": [
            {
              "keyName": "remoteJid",
              "keyValue": "={{ Number( ($('Webhook').item.json.body.data.key.remoteJid.includes('@s.whatsapp.net') ? $('Webhook').item.json.body.data.key.remoteJid : $('Webhook').item.json.body.data.key.remoteJidAlt).split('@')[0] ) }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabaseTool",
      "typeVersion": 1,
      "position": [
        1840,
        592
      ],
      "id": "b3c754d4-53fb-443c-9dc4-61ab0634e537",
      "name": "Listar Eventos Calend\u00e1rio",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "update",
        "tableId": "events",
        "filters": {
          "conditions": [
            {
              "keyName": "remoteJid",
              "condition": "eq",
              "keyValue": "={{ Number( ($('Webhook').item.json.body.data.key.remoteJid.includes('@s.whatsapp.net') ? $('Webhook').item.json.body.data.key.remoteJid : $('Webhook').item.json.body.data.key.remoteJidAlt).split('@')[0] ) }}"
            }
          ]
        },
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "start_time",
              "fieldValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('fieldValues0_Field_Value', `data e hor\u00e1rio inicial`, 'string') }}"
            },
            {
              "fieldId": "end_time",
              "fieldValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('fieldValues1_Field_Value', `data e hor\u00e1rio filnal`, 'string') }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabaseTool",
      "typeVersion": 1,
      "position": [
        2016,
        592
      ],
      "id": "814a13bd-495d-4937-acc1-c30838608497",
      "name": "Atualizar Evento do Calend\u00e1rio",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Edit Fields').item.json.user_id + ':' + $('Edit Fields').item.json.Telefone }}"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryRedisChat",
      "typeVersion": 1.5,
      "position": [
        976,
        592
      ],
      "id": "3a380fbc-141d-46eb-be7b-f9a2fbe387d7",
      "name": "Redis Chat Memory",
      "credentials": {
        "redis": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "tableId": "events",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "user_id",
              "fieldValue": "={{ $('Edit Fields').item.json.user_id }}"
            },
            {
              "fieldId": "title",
              "fieldValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('fieldValues1_Field_Value', ``, 'string') }}"
            },
            {
              "fieldId": "start_time",
              "fieldValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('fieldValues2_Field_Value', ``, 'string') }}"
            },
            {
              "fieldId": "end_time",
              "fieldValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('fieldValues3_Field_Value', ``, 'string') }}"
            },
            {
              "fieldId": "description",
              "fieldValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('fieldValues4_Field_Value', ``, 'string') }}"
            },
            {
              "fieldId": "remoteJid",
              "fieldValue": "={{ Number( ($('Webhook').item.json.body.data.key.remoteJid.includes('@s.whatsapp.net') ? $('Webhook').item.json.body.data.key.remoteJid : $('Webhook').item.json.body.data.key.remoteJidAlt).split('@')[0] ) }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabaseTool",
      "typeVersion": 1,
      "position": [
        1680,
        592
      ],
      "id": "52d89cf3-1b0b-4936-8032-fd8e553de423",
      "name": "Criar Evento Calend\u00e1rio",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "delete",
        "tableId": "events",
        "filters": {
          "conditions": [
            {
              "keyName": "remoteJid",
              "condition": "eq",
              "keyValue": "={{ Number( ($('Webhook').item.json.body.data.key.remoteJid.includes('@s.whatsapp.net') ? $('Webhook').item.json.body.data.key.remoteJid : $('Webhook').item.json.body.data.key.remoteJidAlt).split('@')[0] ) }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabaseTool",
      "typeVersion": 1,
      "position": [
        2192,
        592
      ],
      "id": "3ac0a989-e95e-48b7-96f3-6ba3787327dc",
      "name": "Excluir Evento Calend\u00e1rio",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "getAll",
        "tableId": "events",
        "filters": {
          "conditions": [
            {
              "keyName": "start_time",
              "condition": "gte",
              "keyValue": "={{ $now.plus({ days: 1 }).startOf('day').toISO() }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabaseTool",
      "typeVersion": 1,
      "position": [
        2368,
        592
      ],
      "id": "b9829d6d-fc29-4703-ae40-03ce60e31a77",
      "name": "Consulta Agenda Amanh\u00e3",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "getAll",
        "tableId": "events",
        "returnAll": true,
        "filters": {
          "conditions": [
            {
              "keyName": "user_id",
              "condition": "eq",
              "keyValue": "c1676e45-d57d-4e57-a11a-8d878621cea9"
            },
            {
              "keyName": "user_id",
              "condition": "eq",
              "keyValue": "e2165d22-a30e-4d93-a0c3-3d90a7302ad2"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        -1360,
        1184
      ],
      "id": "7c333b64-1039-45ba-958c-3031fc3ba9f3",
      "name": "Get many rows1",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "filter-tomorrow-events",
              "leftValue": "={{ DateTime.fromISO($json.start_time).toFormat('yyyy-MM-dd') }}",
              "rightValue": "={{ $now.setZone('America/Sao_Paulo').plus({ days: 1 }).toFormat('yyyy-MM-dd') }}",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            },
            {
              "id": "filter-has-remotejid",
              "leftValue": "={{ $json.remoteJid }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.2,
      "position": [
        -1184,
        1184
      ],
      "id": "filter-tomorrow-events-node",
      "name": "Filter Tomorrow Events"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        -784,
        1280
      ],
      "id": "836a92ea-3939-4ea8-a2a0-ac7c555ddaa0",
      "name": "No Operation, do nothing1"
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "d01ab367-2a95-43e1-9bfe-b01e970c942d",
      "name": "Json avisos",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -640,
        992
      ]
    },
    {
      "parameters": {
        "operation": "get",
        "tableId": "events",
        "filters": {
          "conditions": [
            {
              "keyName": "remoteJid",
              "keyValue": "={{ $json.remoteJid }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabaseTool",
      "typeVersion": 1,
      "position": [
        -32,
        1232
      ],
      "id": "e0507822-193f-4dd3-b031-13181d1cb342",
      "name": "Get a row in Supabase",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "682d7f6b-a224-4d44-9a00-19e131b28d82",
              "leftValue": "={{ $json.length }}",
              "rightValue": 0,
              "operator": {
                "type": "array",
                "operation": "lengthEquals",
                "rightType": "number"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -1008,
        1184
      ],
      "id": "bd425a7a-adcd-4b5b-9abc-f948a03bdff3",
      "name": "If"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.remoteJid }}",
        "options": {
          "systemMessage": "=Hoje \u00e9 {{ $now.toFormat('EEEE, dd/MM/yyyy HH:mm') }} (hor\u00e1rio de Bras\u00edlia, UTC\u221203:00).\nSempre use essa data e hor\u00e1rio como base para saber o dia e horario atual.\n\n- Com base nod dados do n\u00f3 Json avisos.\n\nEnvie mensagem para o cliente para avisar do seu agendamento.\n\n\nToda vez que receber o jsson do n\u00f3 Json avisos exemplo.\nEvie mensagem para o cliente \n\nMande somente isso mensagem exemplo:\n\nLembrete de evento agendado.\n\nTitulo:\nData: coloque nesse formato dd/mm/aaaa hora\nObserva\u00e7\u00e3o: "
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.2,
      "position": [
        -256,
        928
      ],
      "id": "8f75d9ae-af11-44ae-bf2d-b14d52a74fc3",
      "name": "AI Agent1"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        -336,
        1232
      ],
      "id": "edd3aa26-921d-4823-8409-485e10015d47",
      "name": "OpenAI Chat Model1",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "update",
        "tableId": "clientes_auroratech",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "nome",
              "fieldValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('fieldValues0_Field_Value', ``, 'string') }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabaseTool",
      "typeVersion": 1,
      "position": [
        1488,
        592
      ],
      "id": "9b278721-9b32-4fa9-a076-aeda95d32308",
      "name": "Atualiza Cliente",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "check-audio-condition",
              "leftValue": "={{ $('Edit Fields').item.json.tipoMensagem }}",
              "rightValue": "audioMessage",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1840,
        112
      ],
      "id": "67485d8f-5288-42ab-adc2-52db52efa3e6",
      "name": "Check If Audio"
    },
    {
      "parameters": {
        "resource": "audio",
        "input": "={{ $json.content }}",
        "voice": "shimmer",
        "options": {
          "speed": 1
        }
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        2112,
        32
      ],
      "id": "1857eb22-335d-480c-9509-4c20dd7c8b30",
      "name": "OpenAI TTS",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "binaryToPropery",
        "destinationKey": "base64",
        "options": {}
      },
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [
        2320,
        32
      ],
      "id": "1865de96-c8bd-49aa-abce-4b9c0980204c",
      "name": "Extract from File"
    },
    {
      "parameters": {
        "jsCode": "const results = [];\n\n// Pega a sa\u00edda do n\u00f3 \"AI Agent\"\nconst texto = $items(\"AI Agent\")[0].json.output || \"\";\n\n// Divide por ponto, interroga\u00e7\u00e3o ou exclama\u00e7\u00e3o seguidos de espa\u00e7o ou fim da frase\nconst partes = texto\n  .split(/(?<=[.!?])\\s+/)  // divide onde h\u00e1 . ! ? seguidos de espa\u00e7o\n  .map(p => p.trim())\n  .filter(p => p.length > 0);\n\n// Cria um novo item pra cada parte\nfor (const p of partes) {\n  results.push({ json: { mensagem: p } });\n}\n\nreturn results;\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2112,
        256
      ],
      "id": "fd717875-a76b-43e9-93b7-262de4dcec5e",
      "name": "Code in JavaScript"
    },
    {
      "parameters": {
        "options": {
          "reset": false
        }
      },
      "id": "188ab481-d37e-425a-8723-3bc52f5e4c99",
      "name": "Json avisos1",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        2320,
        256
      ]
    },
    {
      "parameters": {
        "resource": "messages-api",
        "operation": "send-audio",
        "instanceName": "instance_e2165d22_1762376395079",
        "remoteJid": "={{ $('Edit Fields').item.json.Telefone }}",
        "media": "={{ $json.base64 }}",
        "options_message": {}
      },
      "type": "n8n-nodes-evolution-api.evolutionApi",
      "typeVersion": 1,
      "position": [
        2544,
        32
      ],
      "id": "95ec7a99-cbb5-4569-a238-5b8a4174f6cd",
      "name": "Envia Audio",
      "credentials": {
        "evolutionApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "messages-api",
        "instanceName": "instance_e2165d22_1762376395079",
        "remoteJid": "={{ $('Edit Fields').item.json.Telefone }}",
        "messageText": "={{ $json.mensagem }}",
        "options_message": {
          "delay": 5000
        }
      },
      "type": "n8n-nodes-evolution-api.evolutionApi",
      "typeVersion": 1,
      "position": [
        2544,
        256
      ],
      "id": "8966dec2-cb61-4bd5-938e-13faa3746f79",
      "name": "Evia Texto",
      "executeOnce": false,
      "credentials": {
        "evolutionApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "amount": 2
      },
      "id": "9fd34a5a-0ef9-47c7-bc7d-b77ba539eaac",
      "name": "PAUSE-2",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        2752,
        256
      ]
    },
    {
      "parameters": {
        "amount": 20
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        240,
        288
      ],
      "id": "14b34cf9-17f3-4dcc-a894-c6fa9b71deb3",
      "name": "PAUSE-20"
    },
    {
      "parameters": {
        "resource": "messages-api",
        "instanceName": "instance_e2165d22_1762376395079",
        "remoteJid": "={{ String($('Json avisos').item.json.remoteJid).trim().replace(/[\\r\\n\\t]/g, '') }}@s.whatsapp.net",
        "messageText": "={{ $json.output }}",
        "options_message": {
          "delay": 2000
        }
      },
      "type": "n8n-nodes-evolution-api.evolutionApi",
      "typeVersion": 1,
      "position": [
        144,
        928
      ],
      "id": "3b1624b4-f7fb-4d99-bf6c-93ace9e64d02",
      "name": "Evia Texto-2",
      "credentials": {
        "evolutionApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 10
            }
          ]
        }
      },
      "id": "9e0a8eb1-477a-4f72-8d73-79ab743fdb7a",
      "name": "Executar Diariamente 18h",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -1536,
        1184
      ]
    },
    {
      "parameters": {
        "amount": 60
      },
      "id": "526d9c67-f104-43ea-9f6c-911d5e7e1af0",
      "name": "Pausa-60",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        432,
        992
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Supabase",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Edit Fields1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Edit Fields7",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Edit Fields6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File": {
      "main": [
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI": {
      "main": [
        [
          {
            "node": "Edit Fields1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields1": {
      "main": [
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If1": {
      "main": [
        [
          {
            "node": "Redis",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Save Customer Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Customer Message": {
      "main": [
        [
          {
            "node": "Upsert Conversation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upsert Conversation": {
      "main": [
        [
          {
            "node": "Redis1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Redis": {
      "main": [
        [
          {
            "node": "Save Customer Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Redis1": {
      "main": [
        [
          {
            "node": "If2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If2": {
      "main": [
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Edit Fields2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields2": {
      "main": [
        [
          {
            "node": "Redis2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Redis2": {
      "main": [
        [
          {
            "node": "PAUSE-20",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Redis3": {
      "main": [
        [
          {
            "node": "Redis4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Redis4": {
      "main": [
        [
          {
            "node": "Edit Fields3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Save Agent Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Agent Message": {
      "main": [
        [
          {
            "node": "Check If Audio",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields3": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Cadastra Cliente": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Consulta cliente": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Supabase": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File1": {
      "main": [
        [
          {
            "node": "OpenAI1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI1": {
      "main": [
        [
          {
            "node": "Edit Fields1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields6": {
      "main": [
        [
          {
            "node": "Convert to File1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields7": {
      "main": [
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Listar Eventos Calend\u00e1rio": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Atualizar Evento do Calend\u00e1rio": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Redis Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Criar Evento Calend\u00e1rio": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Excluir Evento Calend\u00e1rio": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Consulta Agenda Amanh\u00e3": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get many rows1": {
      "main": [
        [
          {
            "node": "Filter Tomorrow Events",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Tomorrow Events": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Json avisos": {
      "main": [
        [],
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get a row in Supabase": {
      "ai_tool": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Json avisos",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent1": {
      "main": [
        [
          {
            "node": "Evia Texto-2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Atualiza Cliente": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Check If Audio": {
      "main": [
        [
          {
            "node": "OpenAI TTS",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI TTS": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "Envia Audio",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Json avisos1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Json avisos1": {
      "main": [
        [],
        [
          {
            "node": "Evia Texto",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Evia Texto": {
      "main": [
        [
          {
            "node": "PAUSE-2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PAUSE-2": {
      "main": [
        [
          {
            "node": "Json avisos1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PAUSE-20": {
      "main": [
        [
          {
            "node": "Redis3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Evia Texto-2": {
      "main": [
        [
          {
            "node": "Pausa-60",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Executar Diariamente 18h": {
      "main": [
        [
          {
            "node": "Get many rows1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pausa-60": {
      "main": [
        [
          {
            "node": "Json avisos",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "37693c21-582b-434a-b2aa-36872ad0db19",
  "id": "KvWtWcl3Y6FHY2KP",
  "tags": []
}