{ "name": "Disparador 1.5", "nodes": [ { "parameters": { "rule": { "interval": [ { "field": "minutes", "minutesInterval": 1 } ] } }, "id": "340c174a-59ba-43b5-bb51-ac8a14fe218d", "name": "Schedule Trigger", "type": "n8n-nodes-base.scheduleTrigger", "typeVersion": 1, "position": [ -2180, 1040 ] }, { "parameters": { "conditions": { "dateTime": [ { "value1": "={{ $json.newDate }}", "operation": "before", "value2": "={{ $now }}" } ] } }, "id": "1edfb4d2-33e3-4a97-9802-4c56a4fafe9c", "name": "Horario", "type": "n8n-nodes-base.if", "typeVersion": 1, "position": [ -1460, 1040 ] }, { "parameters": { "content": "# Buscando Campanhas", "height": 456.3958547081602, "width": 1221.218469617133 }, "id": "e6acfa3d-8cfa-4307-9ac0-143fb7e7cda7", "name": "Sticky Note5", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ -2231.8637163263666, 840 ] }, { "parameters": { "content": "# Disparador de Campanha para ChatWoot\n## Evolution API\n\n\nv 1.5", "height": 163.30528430133387, "width": 847.4993167412657, "color": 4 }, "id": "a46fb63d-7831-4b9a-b603-0f9857cd7567", "name": "Sticky Note10", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ -1940, 520 ] }, { "parameters": { "operation": "subtractFromDate", "magnitude": "={{ $json.scheduled_at }}", "timeUnit": "hours", "duration": 3, "options": { "includeInputFields": true } }, "id": "b55513b0-1036-4c62-b27c-82df301c9cfc", "name": "Altera fuso horário", "type": "n8n-nodes-base.dateTime", "typeVersion": 2, "position": [ -1640, 1040 ] }, { "parameters": { "content": "# Busca contatos / Envia campanha\n", "height": 918.3121272287237, "width": 5519.984579857509, "color": 3 }, "id": "9d12feaa-1384-4363-9724-e526a950d380", "name": "Sticky Note", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ -160, 780 ] }, { "parameters": {}, "id": "f8824154-8a53-43b4-bf01-ea68fbc04f2e", "name": "Repetir ação", "type": "n8n-nodes-base.noOp", "typeVersion": 1, "position": [ 5220, 1220 ] }, { "parameters": { "jsCode": "// Este exemplo gera um tempo de espera aleatório entre 10 e 60 segundos\nconst minWait = 8; // Tempo mínimo de espera em segundos\nconst maxWait = 15; // Tempo máximo de espera em segundos\nconst randomWaitTime = Math.floor(Math.random() * (maxWait - minWait + 1)) + minWait;\n\nreturn [\n {\n json: {\n waitTime: randomWaitTime\n }\n }\n];\n" }, "id": "dd6343b7-cfa0-41b1-9620-58c6225de1ad", "name": "Time Randon1", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 2400, 1060 ] }, { "parameters": { "amount": "={{ $json.waitTime }}" }, "id": "98a6cab0-24b3-414d-b4e6-bf22ed0b92fe", "name": "Tempo de espera1", "type": "n8n-nodes-base.wait", "typeVersion": 1.1, "position": [ 2580, 1060 ], "webhookId": "31abe436-92ec-4d95-abaa-9e1b8a0daf69" }, { "parameters": { "conditions": { "string": [ { "value1": "={{ $('Buscar campanhas').item.json.campaign_type }}", "value2": "={{ 1 }}" } ] } }, "id": "86e3f39b-80fa-4e7d-beff-583b36f46ea1", "name": "IF6", "type": "n8n-nodes-base.if", "typeVersion": 1, "position": [ -840, 1000 ] }, { "parameters": { "fieldToSplitOut": "audience", "include": "allOtherFields", "options": {} }, "id": "a510b759-02d7-4e87-a130-6526171a9c0e", "name": "Item Lists1", "type": "n8n-nodes-base.itemLists", "typeVersion": 3, "position": [ -620, 1000 ] }, { "parameters": { "content": "# Trata mensagem", "height": 456.8892799239013, "width": 728.217926985971, "color": 2 }, "id": "37380d5e-9ff9-4cb0-8bb1-c93af1c27f3b", "name": "Sticky Note2", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ -940, 840 ] }, { "parameters": { "options": {} }, "id": "477ed4cd-61d1-4672-aeba-7c9992ad6ab6", "name": "Loop Over Items", "type": "n8n-nodes-base.splitInBatches", "typeVersion": 3, "position": [ 360, 1020 ], "executeOnce": false, "alwaysOutputData": false, "retryOnFail": false, "notesInFlow": false }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict" }, "conditions": [ { "id": "d0205698-dcfd-4d3c-b6e3-dfd7209035c3", "leftValue": "={{ $json.limite_disparo }}", "rightValue": 1, "operator": { "type": "number", "operation": "gte" } } ], "combinator": "and" }, "options": {} }, "id": "f060c009-8377-4df6-8e26-89008ddbba3b", "name": "If", "type": "n8n-nodes-base.if", "typeVersion": 2, "position": [ 1520, 1060 ] }, { "parameters": { "content": "## Contador de limite / Verificação do número", "height": 225.35612209945384, "width": 853.0984671711764, "color": 4 }, "id": "5ba7c3d9-b728-4b39-b7d9-97097aac1b39", "name": "Sticky Note1", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 1320, 1000 ] }, { "parameters": { "content": "## Tempo entre as mensagens", "height": 230.3746650610074, "width": 404.53569195365, "color": 4 }, "id": "daf532a0-247e-470d-812f-f22947cfc1ea", "name": "Sticky Note3", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 2340, 1000 ] }, { "parameters": { "content": "## Contabiliza falhas", "height": 225.08131697058332, "width": 546.5336275124715, "color": 2 }, "id": "cfda581b-b06c-4902-a9b6-e3fc5c11dffb", "name": "Sticky Note6", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 3720, 1400 ] }, { "parameters": { "content": "## Contabiliza envios", "height": 215.09474919455494, "width": 376.16757486051324, "color": 2 }, "id": "f3bab47b-15d0-45b8-805f-5cd3267fcd05", "name": "Sticky Note7", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 3460, 980 ] }, { "parameters": { "operation": "executeQuery", "query": "SELECT falhou\nFROM campaigns\nWHERE id = {{ $('IF6').item.json.id }};", "options": { "queryReplacement": "=" } }, "id": "5c05c936-0e56-43f2-a9c4-c53f1562384c", "name": "Busca falhas", "type": "n8n-nodes-base.postgres", "typeVersion": 2.4, "position": [ 3760, 1440 ] }, { "parameters": { "operation": "executeQuery", "query": "SELECT enviou\nFROM campaigns\nWHERE id = {{ $('IF6').item.json.id }};", "options": {} }, "id": "be39ed05-43ca-4467-bc4a-60a1229c111e", "name": "Busca envios", "type": "n8n-nodes-base.postgres", "typeVersion": 2.4, "position": [ 3520, 1040 ] }, { "parameters": { "assignments": { "assignments": [ { "id": "cbb23691-dfc9-413f-b996-ba0515b0a902", "name": "etiqueta", "value": "={{ $('Buscar campanhas').item.json.audience[0].id }}", "type": "number" }, { "id": "7a194f32-e774-4d48-94ed-1e2c9b9fd025", "name": "msg.title", "value": "={{ $('Buscar campanhas').item.json.title }}", "type": "string" }, { "id": "4dc32df3-cc5a-4a9b-8dcd-2d3f8a50a6fd", "name": "msg.message", "value": "={{ $('Buscar campanhas').item.json.message }}", "type": "string" }, { "id": "3b2fef42-7655-4ebc-ac93-1a25f77cbec1", "name": "img", "value": "={{ $('IF6').item.json.message.split('&img=')[1].split('&')[0] }}", "type": "string" }, { "id": "66e5ac5e-5cef-4737-81d8-9457f8fb8536", "name": "nomecontato", "value": "={{ $json.message.match(/&nome/)[0] }}", "type": "string" }, { "id": "afa0b53c-9933-44e1-ab91-49a9540f9c7d", "name": "emailcontato", "value": "={{ $json.message.match(/&email/)[0] }}", "type": "string" }, { "id": "fde7488d-6bca-4057-a2c3-17cd21ea41cd", "name": "doc", "value": "={{ $('IF6').item.json.message.split('&doc=')[1].split('&')[0] }}", "type": "string" }, { "id": "459f505e-48c9-4829-a151-e9a9c651901c", "name": "", "value": "", "type": "string" } ] }, "options": {} }, "id": "f8450871-2275-463b-99ec-7627c7cce009", "name": "Campanha", "type": "n8n-nodes-base.set", "typeVersion": 3.3, "position": [ -420, 1000 ] }, { "parameters": { "content": "# Relatorio da campanha", "height": 346.43605543050865, "width": 1085.0447604700087 }, "id": "a71bd8df-0484-49b0-b87c-c07f4e016242", "name": "Sticky Note8", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 1060, 414.55190978677456 ] }, { "parameters": { "content": "# Limite excedido", "height": 339.69571412210314, "width": 1088.2492332463764 }, "id": "a6207421-9db6-45c9-b503-fd4f164e86e4", "name": "Sticky Note9", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 1060, 20 ] }, { "parameters": { "operation": "executeQuery", "query": "UPDATE campaigns\nSET enviou = {{ $json.enviou +1 }}\nWHERE id = {{ $('IF6').item.json.id }};", "options": {} }, "id": "c139c950-3c24-49b2-935f-2ec304380a5d", "name": "Adiciona envios", "type": "n8n-nodes-base.postgres", "typeVersion": 2.4, "position": [ 3680, 1040 ] }, { "parameters": { "content": "## Somente texto", "height": 199.63817652105178, "width": 313.99126283929667 }, "id": "1dfd8fbf-acb1-4fa4-a600-ca35a1242705", "name": "Sticky Note4", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 3080, 840 ] }, { "parameters": { "content": "## Com imagem", "height": 221.17684873191945, "width": 313.99126283929667 }, "id": "a9f4f1c5-48a5-466a-9167-f5c7128a3131", "name": "Sticky Note11", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 3080, 1100 ] }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict" }, "conditions": [ { "id": "ebbe2797-49a1-47e7-9c54-161ff02dfa49", "leftValue": "={{ $('Campanha').item.json.nomecontato }}", "rightValue": "", "operator": { "type": "string", "operation": "empty", "singleValue": true } }, { "id": "77ff2a0a-ae27-427a-b489-2daac4e90429", "leftValue": "={{ $('Campanha').item.json.emailcontato}}", "rightValue": "", "operator": { "type": "string", "operation": "empty", "singleValue": true } } ], "combinator": "or" }, "options": {} }, "id": "885d9791-0308-4213-8e46-f160617952a5", "name": "If2", "type": "n8n-nodes-base.if", "typeVersion": 2, "position": [ 720, 1040 ] }, { "parameters": { "content": "## Resolve Conversa\n** Se a conversa estiver aberta mantém / Se for uma conversa nova ele fecha!", "height": 331.5360284004761, "width": 1227.4972493046307 }, "id": "0cac7b92-0dbd-47a9-aa69-0ca301ad9fcf", "name": "Sticky Note12", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 3920, 940 ] }, { "parameters": { "assignments": { "assignments": [ { "id": "a8de3538-0eac-4149-aaf9-7bc2c5c4b00e", "name": "id_caixa", "value": "={{ $('Info_Base').item.json.id_caixa }}", "type": "string" }, { "id": "04e8a587-52b0-4ddc-877e-e97fdd1ef171", "name": "id_contato", "value": "={{ $('Busca Contato Existe').item.json.payload[0].id }}", "type": "string" } ] }, "options": {} }, "id": "12716989-d5c3-47ee-abd9-ef57d45f5d90", "name": "Salva conversa", "type": "n8n-nodes-base.set", "typeVersion": 3.3, "position": [ 4540, 1040 ] }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict" }, "conditions": [ { "id": "493b5963-2314-4179-a065-3a9aca90749e", "leftValue": "={{ $json.payload[0].status }}", "rightValue": "", "operator": { "type": "string", "operation": "exists", "singleValue": true } } ], "combinator": "and" }, "options": {} }, "id": "645d5deb-4967-4463-a976-d407575cc50f", "name": "If3", "type": "n8n-nodes-base.if", "typeVersion": 2, "position": [ 4280, 1040 ] }, { "parameters": { "amount": 1 }, "id": "a6d9ab7f-a016-4432-86ec-1f5d12e74f8d", "name": "Wait", "type": "n8n-nodes-base.wait", "typeVersion": 1.1, "position": [ 4700, 1040 ], "webhookId": "9564575c-7414-4c94-b1f1-d73c99222ecc" }, { "parameters": { "content": "# Resolve Conversa", "height": 246.1701698163285, "width": 704.4608631799392 }, "id": "3cfc96af-5e02-44e7-aba6-88cb5f454e87", "name": "Sticky Note13", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 2340, 280 ] }, { "parameters": { "operation": "executeQuery", "query": "SELECT limite_disparo\nFROM accounts\nWHERE id ={{ $('Info_Base').item.json.chatwoot_account_id }};", "options": { "queryReplacement": "=" } }, "id": "b7e94c23-023a-45ae-bf6a-08423995b60c", "name": "Busca limite diario", "type": "n8n-nodes-base.postgres", "typeVersion": 2.4, "position": [ 1360, 1060 ] }, { "parameters": { "fromEmail": "suportesetabot@gmail.com", "toEmail": "={{ $node['Info_Base'].json.email_relatorio }}", "subject": "SetaBot - Limite de disparo excedido", "text": "=⚠️ Atenção! Algumas mensagens da campanha {{ $node['Buscar campanhas'].json.title }} podem não ter sido enviadas. ⚠️\n\n✔️ Total de envios: {{ $('Notifica limite excedido').item.json.enviou }}\n❌ Número de falhas: {{ $('Notifica limite excedido').item.json.falhou }}\n#️⃣ Limite restante: {{ $('Notifica limite excedido').item.json.limite_disparo }} \n\nO limite de disparos diários foi excedido. Por favor, verifique os envios ou entre em contato com o suporte para mais informações.\n\nObrigado pela compreensão! ", "options": {} }, "id": "6a0fb4f7-2e3e-49e9-88a7-74b3eae029da", "name": "Send Email", "type": "n8n-nodes-base.emailSend", "typeVersion": 2, "position": [ 1800, 80 ], "continueOnFail": true }, { "parameters": { "fromEmail": "suportesetabot@gmail.com", "toEmail": "={{ $node['Info_Base'].json.email_relatorio }}", "subject": "SetaBot - Relatório a Campanha", "text": "=📢 Campanha {{ $node['Buscar campanhas'].json.title }} enviada com sucesso! 📢\n\n✔️ Total de envios: {{ $('Resumo relatorio').item.json.enviou }}\n❌ Número de falhas: {{ $('Resumo relatorio').item.json.falhou }} \n#️⃣ Limite restante: {{ $('Resumo relatorio').item.json.limite_disparo }} \n\nObrigado por utilizar nossos serviços!", "options": {} }, "id": "be4d879f-7de5-4721-a738-691d0f249df0", "name": "Send Email1", "type": "n8n-nodes-base.emailSend", "typeVersion": 2, "position": [ 1800, 480 ], "continueOnFail": true }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict" }, "conditions": [ { "id": "c2573aed-9acc-4fc6-a799-b11e2191d408", "leftValue": "={{ $json.exists }}", "rightValue": "true", "operator": { "type": "boolean", "operation": "true", "singleValue": true } } ], "combinator": "and" }, "options": {} }, "id": "7c327d7e-0143-454d-b028-c2a0a85c07a4", "name": "If4", "type": "n8n-nodes-base.if", "typeVersion": 2, "position": [ 1860, 1060 ] }, { "parameters": {}, "id": "ed86a90e-8f24-4c25-b714-1a68dd305c81", "name": "Wait1", "type": "n8n-nodes-base.wait", "typeVersion": 1.1, "position": [ 2396, 360 ], "webhookId": "82162c4e-916e-460e-9f04-c21ed4c6895e" }, { "parameters": { "operation": "executeQuery", "query": "UPDATE campaigns\nSET falhou = {{ $json.falhou +1 }}\nWHERE id = {{ $('IF6').item.json.id }};", "options": {} }, "id": "5bd4675b-18ee-431d-86b8-9434feb10bec", "name": "Adiciona num de falhas", "type": "n8n-nodes-base.postgres", "typeVersion": 2.4, "position": [ 3940, 1440 ] }, { "parameters": { "operation": "executeQuery", "query": "INSERT INTO campaigns_failled (nomecontato, telefone, id_campanha)\nSELECT '{{ $('Busca contatos').item.json.name }}', '{{ $('Busca contatos').item.json.phone_number }}', {{ $('Buscar campanhas').item.json.id }}\nWHERE NOT EXISTS (\n SELECT 1\n FROM campaigns_failled\n WHERE telefone = '{{ $('Busca contatos').item.json.phone_number }}' AND id_campanha = {{ $('Buscar campanhas').item.json.id }}\n);", "options": {} }, "id": "a6391e66-33ff-4248-9ca6-43605072d6d9", "name": "Adiciona num não enviado", "type": "n8n-nodes-base.postgres", "typeVersion": 2.4, "position": [ 4120, 1440 ] }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict" }, "conditions": [ { "id": "0ed1f598-cec8-458a-97d7-1d82aedf251e", "leftValue": "={{ $json.falhou }}", "rightValue": 0, "operator": { "type": "number", "operation": "equals" } } ], "combinator": "and" }, "options": {} }, "id": "b06f8d61-800e-4527-948e-cec8be070900", "name": "If5", "type": "n8n-nodes-base.if", "typeVersion": 2, "position": [ 1280, 180 ] }, { "parameters": { "operation": "executeQuery", "query": "SELECT \n c.falhou, \n c.enviou, \n a.limite_disparo \nFROM \n campaigns c\nJOIN \n accounts a ON c.account_id = a.id\nWHERE \n c.id = {{ $('IF6').item.json.id }};", "options": { "queryReplacement": "=" } }, "id": "67de1521-ac0b-4ac8-b090-5028e10eb78c", "name": "Notifica limite excedido", "type": "n8n-nodes-base.postgres", "typeVersion": 2.4, "position": [ 1120, 180 ] }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict" }, "conditions": [ { "id": "69cc2650-7d52-4da1-b391-a88b2326d63d", "leftValue": "={{ $json.falhou }}", "rightValue": 0, "operator": { "type": "number", "operation": "equals" } } ], "combinator": "and" }, "options": {} }, "id": "9d8e6abf-14f6-496d-9bd1-23fb1333ff72", "name": "If6", "type": "n8n-nodes-base.if", "typeVersion": 2, "position": [ 1280, 580 ] }, { "parameters": { "jsCode": "let contatos = items.map(item => `${item.json.nomecontato} - ${item.json.telefone}`).join('\\n');\n\nreturn [\n {\n json: {\n listaContatos: contatos\n }\n }\n];" }, "id": "d7ccc463-49a8-44e2-a5ae-49d1e7808d7b", "name": "Code", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1620, 620 ] }, { "parameters": { "jsCode": "let contatos = items.map(item => `${item.json.nomecontato} - ${item.json.telefone}`).join('\\n');\n\nreturn [\n {\n json: {\n listaContatos: contatos\n }\n }\n];" }, "id": "efa516c0-a8cb-4921-bc18-f5756f79f476", "name": "Code1", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1620, 220 ] }, { "parameters": { "fromEmail": "suportesetabot@gmail.com", "toEmail": "={{ $node['Info_Base'].json.email_relatorio }}", "subject": "SetaBot - Relatório a Campanha", "text": "=📢 Campanha {{ $node['Buscar campanhas'].json.title }} enviada com sucesso! 📢\n\n✔️ Total de envios: {{ $node['Resumo relatorio'].json.enviou }}\n❌ Número de falhas: {{ $node['Resumo relatorio'].json.falhou }} \n#️⃣ Limite restante: {{ $node['Resumo relatorio'].json.limite_disparo }} \n\nContatos não enviados:\n{{ $('Code').item.json[\"listaContatos\"] }}\n\nObrigado por utilizar nossos serviços!", "options": {} }, "id": "069b730a-745b-48b5-816f-1609e02f0d8b", "name": "Send Email2", "type": "n8n-nodes-base.emailSend", "typeVersion": 2, "position": [ 1980, 620 ], "continueOnFail": true }, { "parameters": { "operation": "executeQuery", "query": "SELECT \n (SELECT COUNT(*) FROM campaigns_failled WHERE id_campanha = {{ $('Buscar campanhas').item.json.id }}) AS total_registros,\n campaigns_failled.*\nFROM campaigns_failled\nWHERE id_campanha = {{ $('Buscar campanhas').item.json.id }};", "options": {} }, "id": "3eb8ede6-d136-43cc-9778-2cd9de47a146", "name": "Postgres1", "type": "n8n-nodes-base.postgres", "typeVersion": 2.4, "position": [ 1440, 220 ], "alwaysOutputData": true }, { "parameters": { "fromEmail": "suportesetabot@gmail.com", "toEmail": "={{ $node['Info_Base'].json.email_relatorio }}", "subject": "SetaBot - Limite de disparo excedido", "text": "=⚠️ Atenção! Algumas mensagens da campanha {{ $node['Buscar campanhas'].json.title }} podem não ter sido enviadas. ⚠️\n\n✔️ Total de envios: {{ $node['Notifica limite excedido'].json.enviou }}\n❌ Número de falhas: {{ $node['Notifica limite excedido'].json.falhou }}\n#️⃣ Limite restante: {{ $node['Notifica limite excedido'].json.limite_disparo }} \n\nContatos não enviados:\n{{ $node['Code1'].json[\"listaContatos\"] }}\n\nO limite de disparos diários foi excedido. Por favor, verifique os envios ou entre em contato com o suporte para mais informações.\n\nObrigado pela compreensão! ", "options": {} }, "id": "ee817be8-c8b1-424d-86a8-28e17eb64266", "name": "Send Email3", "type": "n8n-nodes-base.emailSend", "typeVersion": 2, "position": [ 1980, 220 ], "continueOnFail": true }, { "parameters": { "assignments": { "assignments": [ { "id": "4e7aab24-149c-4afb-8970-97f3f4b91841", "name": "etiqueta", "value": "={{ $node['Buscar campanhas'].json.audience[0].id }}", "type": "string" }, { "id": "93fad362-a35a-43c8-85ce-9d8dff3a28ad", "name": "titulo_campanha", "value": "={{ $node['Campanha'].json.msg.title }}", "type": "string" }, { "id": "ae1dace5-7708-4042-a4f6-5d34a6b046bd", "name": "id_campanha", "value": "={{ $node['Buscar campanhas'].json.id }}", "type": "string" } ] }, "options": {} }, "id": "b9b808ea-09e8-420d-9214-35bde4723d31", "name": "Dados da campanha", "type": "n8n-nodes-base.set", "typeVersion": 3.3, "position": [ 800, 600 ] }, { "parameters": { "fieldToSplitOut": "audience", "include": "allOtherFields", "options": {} }, "id": "ab5b1d8d-b38c-46a2-80fc-955b626ffaea", "name": "Tratamento de lista", "type": "n8n-nodes-base.itemLists", "typeVersion": 3, "position": [ 580, 860 ], "alwaysOutputData": true }, { "parameters": { "operation": "executeQuery", "query": "SELECT \n (SELECT COUNT(*) FROM campaigns_failled WHERE id_campanha = {{ $node['Dados da campanha'].json.id_campanha }}) AS total_registros,\n cf.*\nFROM campaigns_failled cf\nWHERE cf.id_campanha = {{ $node['Dados da campanha'].json.id_campanha }};", "options": {} }, "id": "aa7668d3-8747-4fa7-bd74-d439b1ecbd10", "name": "Postgres", "type": "n8n-nodes-base.postgres", "typeVersion": 2.4, "position": [ 1440, 620 ], "alwaysOutputData": true }, { "parameters": { "operation": "executeQuery", "query": "SELECT \n c.falhou, \n c.enviou, \n a.limite_disparo \nFROM \n campaigns c\nJOIN \n accounts a ON c.account_id = a.id\nWHERE \n c.id = {{ $json.id_campanha }};", "options": {} }, "id": "c198e4d8-9ed1-414b-ac43-28a02bd485a5", "name": "Resumo relatorio", "type": "n8n-nodes-base.postgres", "typeVersion": 2.4, "position": [ 1120, 580 ] }, { "parameters": { "operation": "executeQuery", "query": "UPDATE accounts\nSET limite_disparo = {{ $('Busca limite diario').item.json.limite_disparo -1 }}\nWHERE id ={{ $('Info_Base').item.json.chatwoot_account_id }};", "options": {} }, "id": "afaead58-13a5-4b86-b13d-0e16aa979098", "name": "Subtrair", "type": "n8n-nodes-base.postgres", "typeVersion": 2.4, "position": [ 2040, 1060 ] }, { "parameters": { "url": "={{ $node['Info_Base'].json.chatwoot_url }}/api/v1/accounts/{{ $node['Info_Base'].json.chatwoot_account_id }}/contacts/{{ $json.payload[0].id }}/conversations", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "api_access_token", "value": "={{ $node['Info_Base'].json.chatwoot_token }}" } ] }, "options": {} }, "id": "abea672f-ef40-4199-bfe9-b1ee05e2e803", "name": "Abre conversa de contato existente", "type": "n8n-nodes-base.httpRequest", "typeVersion": 3, "position": [ 4120, 1040 ], "onError": "continueRegularOutput" }, { "parameters": { "url": "={{ $node['Info_Base'].json.chatwoot_url }}/api/v1/accounts/{{ $node['Info_Base'].json.chatwoot_account_id }}/contacts/search", "sendQuery": true, "queryParameters": { "parameters": [ { "name": "q", "value": "={{ $node['Edita Mensagem'].json.verificanum }}" } ] }, "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "api_access_token", "value": "={{ $node['Info_Base'].json.chatwoot_token }}" } ] }, "options": {} }, "id": "dda3aa66-5d7d-46f4-914f-ca5e7cf786fb", "name": "Busca Contato Existe", "type": "n8n-nodes-base.httpRequest", "typeVersion": 3, "position": [ 3960, 1040 ], "onError": "continueRegularOutput" }, { "parameters": { "method": "POST", "url": "={{ $node['Info_Base'].json.evolution_url }}/chat/whatsappNumbers/{{ $node['Info_Base'].json.instance_name }}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Content-Type", "value": "application/json" }, { "name": "apikey", "value": "={{ $node['Info_Base'].json.global_api_key }}" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"numbers\": [\n \"{{ $node['Edita Mensagem'].json.verificanum }}\"\n ]\n} ", "options": {} }, "id": "d1df106c-43ab-4bab-bf62-8a2ced83e4ae", "name": "HTTP Request1", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 1700, 1060 ] }, { "parameters": { "method": "POST", "url": "={{ $node['Info_Base'].json.chatwoot_url }}/api/v1/accounts/{{ $node['Info_Base'].json.chatwoot_account_id }}/conversations/{{ $json.payload[0].id }}/toggle_status", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "api_access_token", "value": "={{ $node['Info_Base'].json[\"chatwoot_token\"] }}" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n\"status\": \"resolved\"\n}", "options": {} }, "id": "45d730a9-2122-48e3-9d61-2c2b6e6de362", "name": "Fecha Conversa", "type": "n8n-nodes-base.httpRequest", "typeVersion": 3, "position": [ 2876, 360 ], "onError": "continueRegularOutput" }, { "parameters": { "url": "={{ $node['Info_Base'].json.chatwoot_url }}/api/v1/accounts/{{ $node['Info_Base'].json.chatwoot_account_id }}/contacts/{{ $json.payload[0].id }}/conversations", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "api_access_token", "value": "={{ $node['Info_Base'].json.chatwoot_token }}" } ] }, "options": {} }, "id": "17c4d96f-dce7-4a1f-a10f-1e709018bf82", "name": "Seleciona conversa", "type": "n8n-nodes-base.httpRequest", "typeVersion": 3, "position": [ 2716, 360 ], "onError": "continueRegularOutput" }, { "parameters": { "url": "={{ $node['Info_Base'].json.chatwoot_url }}/api/v1/accounts/{{ $node['Info_Base'].json.chatwoot_account_id }}/contacts/search", "sendQuery": true, "queryParameters": { "parameters": [ { "name": "q", "value": "=+{{ $node['Info_Base'].json[\"recebe_relatorio\"] }}" } ] }, "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "api_access_token", "value": "={{ $node['Info_Base'].json.chatwoot_token }}" } ] }, "options": {} }, "id": "74a57751-1e8c-4808-b294-cb49c56bab3a", "name": "Busca Contato do Relatorio", "type": "n8n-nodes-base.httpRequest", "typeVersion": 3, "position": [ 2560, 360 ], "onError": "continueRegularOutput" }, { "parameters": { "operation": "executeQuery", "query": "UPDATE conversations\nSET status = 1\nWHERE contact_id = {{ $json.id_contato }};", "options": {} }, "id": "41c1cfa3-f53d-4047-a33a-ed46f499ccd1", "name": "Resolve Conversa", "type": "n8n-nodes-base.postgres", "typeVersion": 2.4, "position": [ 4880, 1040 ], "onError": "continueRegularOutput" }, { "parameters": { "content": "## Com documento", "height": 221.17684873191945, "width": 313.99126283929667 }, "id": "f812dc4c-19e6-46a6-b163-ca616d97c81f", "name": "Sticky Note14", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 3080, 1400 ] }, { "parameters": { "operation": "executeQuery", "query": "SELECT * \nFROM campaigns c \nWHERE account_id = 0\nAND status_envia = 0\nAND inbox_id = 0\nLIMIT 1;", "additionalFields": {} }, "id": "6f70e67a-1790-4e73-bd40-df8e2f33abed", "name": "Buscar campanhas", "type": "n8n-nodes-base.postgres", "typeVersion": 1, "position": [ -1820, 1040 ] }, { "parameters": { "operation": "executeQuery", "query": "UPDATE campaigns SET status_envia = 1 WHERE id = {{ $json.id }}", "options": {} }, "id": "27b0ae63-1e34-4c71-b723-350d964f83d0", "name": "UPDATE CAMPANHA", "type": "n8n-nodes-base.postgres", "typeVersion": 2.4, "position": [ -1200, 860 ], "alwaysOutputData": false }, { "parameters": { "operation": "executeQuery", "query": "SELECT c.*\nFROM contacts c\nJOIN taggings tg ON c.id = tg.taggable_id\nWHERE tg.tag_id = {{ $json.etiqueta }}\nAND tg.taggable_type = 'Contact'\nAND c.account_id = {{ $node['Info_Base'].json.chatwoot_account_id }};", "options": {} }, "id": "15c09c35-7ab3-4603-8720-9348e31b77a1", "name": "Busca contatos", "type": "n8n-nodes-base.postgres", "typeVersion": 2.4, "position": [ -80, 1040 ] }, { "parameters": { "keepOnlySet": true, "values": { "string": [ { "name": "chatwoot_url", "value": "https://urlchatwoot.com" }, { "name": "evolution_url", "value": "https://urlevo.com" }, { "name": "chatwoot_token", "value": "ZiyV29UVmQLB8jDKa1JMhe2k" }, { "name": "global_api_key", "value": "global api evo" }, { "name": "instance_name", "value": "nome da tenancia evo" }, { "name": "id_caixa", "value": "id caixa evo" }, { "name": "chatwoot_account_id", "value": "id conta chatwoot" }, { "name": "email_relatorio", "value": "email@email.com" }, { "name": "recebe_relatorio", "value": "551199996666" } ] }, "options": {} }, "id": "32df25b6-c893-432d-9450-fc112f878b26", "name": "Info_Base", "type": "n8n-nodes-base.set", "typeVersion": 2, "position": [ -2000, 1040 ] }, { "parameters": { "method": "=POST", "url": "={{ $('Info_Base').item.json.evolution_url }}/message/sendText/{{ $('Info_Base').item.json.instance_name }}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "accept", "value": "application/json, text/plain, */*" }, { "name": "apikey", "value": "={{ $('Info_Base').item.json.global_api_key }}" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"number\":\"{{ $node['Edita Mensagem'].json.verificanum }}\",\n \"options\":{\"delay\":3000,\"presence\":\"composing\"},\n \"textMessage\":{\"text\":\"{{ $('Edita Mensagem').item.json.var_msg.replace(/\\n/g, '\\\\n') }}\"}\n} ", "options": {} }, "id": "fbd66398-af4d-413a-a104-62b30c7c03d2", "name": "Envia msg", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.1, "position": [ 3180, 880 ], "retryOnFail": false, "maxTries": 2, "waitBetweenTries": 2000, "executeOnce": true, "onError": "continueErrorOutput" }, { "parameters": { "rules": { "values": [ { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict" }, "conditions": [ { "leftValue": "={{ $('Campanha').item.json.img }}", "rightValue": "", "operator": { "type": "string", "operation": "notEmpty", "singleValue": true } } ], "combinator": "and" } }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict" }, "conditions": [ { "id": "68892a20-1c5e-42f8-a74d-aec4a687d0dd", "leftValue": "={{ $('Campanha').item.json.doc }}", "rightValue": "", "operator": { "type": "string", "operation": "notEmpty", "singleValue": true } } ], "combinator": "and" } } ] }, "options": {} }, "id": "d7fc16bd-3dce-4136-b162-8af79e0952f1", "name": "Switch", "type": "n8n-nodes-base.switch", "typeVersion": 3, "position": [ 2820, 1300 ] }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict" }, "conditions": [ { "id": "eba67cd0-fd9f-4069-b1e3-accd10450f96", "leftValue": "={{ $('Campanha').item.json.img}}", "rightValue": "", "operator": { "type": "string", "operation": "empty", "singleValue": true } }, { "id": "de8f0cf5-8faf-45a1-8965-7e660b401c5d", "leftValue": "={{ $('Campanha').item.json.doc}}", "rightValue": "", "operator": { "type": "string", "operation": "empty", "singleValue": true } } ], "combinator": "and" }, "options": {} }, "id": "9b8c4f7f-ef97-4ab7-a320-1a3e0008ad61", "name": "If1", "type": "n8n-nodes-base.if", "typeVersion": 2, "position": [ 2800, 1060 ] }, { "parameters": { "method": "POST", "url": "={{ $node['Info_Base'].json[\"evolution_url\"] }}/message/sendText/{{ $node['Info_Base'].json[\"instance_name\"] }}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "accept", "value": "application/json, text/plain, */*" }, { "name": "apikey", "value": "={{ $node['Info_Base'].json.global_api_key }}" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"number\": \"{{ $node['Info_Base'].json['recebe_relatorio'] }}\",\n \"options\": {\n \"delay\": 3000,\n \"presence\": \"composing\"\n },\n \"textMessage\": {\n \"text\": \"📢 Campanha *{{ $node['Buscar campanhas'].json.title }}* enviada com sucesso! 📢\\n\\n✔️ Total de envios: {{ $node['Resumo relatorio'].json.enviou }}\\n❌ Número de falhas: {{ $node['Resumo relatorio'].json.falhou }}\\n#️⃣ Limite restante: {{ $node['Resumo relatorio'].json.limite_disparo }}\\n\\n*Contatos não enviados:*\\n{{ $('Code').item.json.listaContatos.replace(/\\n/g, '\\\\n') }} \\n\\nObrigado por utilizar nossos serviços!\"\n }\n}\n ", "options": {} }, "id": "1e2e47c0-96a3-4d7f-97e9-a1df60ae2aa9", "name": "Envia relatorio3", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.1, "position": [ 1800, 620 ], "retryOnFail": false, "maxTries": 2, "waitBetweenTries": 2000, "executeOnce": true }, { "parameters": { "method": "POST", "url": "={{ $('Info_Base').item.json.evolution_url }}/message/sendText/{{ $('Info_Base').item.json.instance_name }}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "accept", "value": "application/json, text/plain, */*" }, { "name": "apikey", "value": "={{ $('Info_Base').item.json.global_api_key }}" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\"number\":\"{{ $('Info_Base').item.json[\"recebe_relatorio\"] }}\",\"options\":{\"delay\":3000,\"presence\":\"composing\"},\"textMessage\":{\"text\":\"📢 Campanha *{{ $('Buscar campanhas').item.json.title }}* enviada com sucesso! 📢\\n\\n✔️ Total de envios: {{ $json[\"enviou\"] }}\\n❌ Número de falhas: {{ $json[\"falhou\"] }}\\n#️⃣ Limite restante: {{ $json[\"limite_disparo\"] }}\\n\\nObrigado por utilizar nossos serviços!\"}}", "options": {} }, "id": "8e12e19b-7828-4c2b-be9b-f17427f2497a", "name": "Envia relatorio", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.1, "position": [ 1620, 480 ], "retryOnFail": false, "maxTries": 2, "waitBetweenTries": 2000, "executeOnce": true }, { "parameters": { "method": "POST", "url": "={{ $node['Info_Base'].json[\"evolution_url\"] }}/message/sendText/{{ $node['Info_Base'].json[\"instance_name\"] }}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "accept", "value": "application/json, text/plain, */*" }, { "name": "apikey", "value": "={{ $node['Info_Base'].json.global_api_key }}" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\"number\":\"{{ $node['Info_Base'].json[\"recebe_relatorio\"] }}\",\"options\":{\"delay\":3000,\"presence\":\"composing\"},\"textMessage\":{\"text\":\"⚠️ *Atenção!* Algumas mensagens da campanha *{{ $node['Buscar campanhas'].json.title }}* podem não ter sido enviadas. ⚠️\\n\\n✔️ Total de envios: {{ $node['Notifica limite excedido'].json[\"enviou\"] }}\\n❌ Número de falhas: {{ $node['Notifica limite excedido'].json[\"falhou\"] }}\\n#️⃣ Limite restante: {{ $node['Notifica limite excedido'].json[\"limite_disparo\"] }}\\n\\n*Contatos não enviados:*\\n{{ $('Code1').item.json.listaContatos.replace(/\\n/g, '\\\\n') }} \\n\\nO limite de disparos diários foi excedido. Por favor, verifique os envios ou entre em contato com o suporte para mais informações.\\n\\nObrigado pela compreensão!\"}}\n", "options": {} }, "id": "d3bb2767-78bd-4966-b988-392c9ac5babc", "name": "Envia relatorio2", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.1, "position": [ 1800, 220 ], "retryOnFail": false, "maxTries": 2, "waitBetweenTries": 2000, "executeOnce": true }, { "parameters": { "method": "POST", "url": "={{ $('Info_Base').item.json.evolution_url }}/message/sendText/{{ $('Info_Base').item.json.instance_name }}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "accept", "value": "application/json, text/plain, */*" }, { "name": "apikey", "value": "={{ $('Info_Base').item.json.global_api_key }}" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\"number\":\"{{ $('Info_Base').item.json[\"recebe_relatorio\"] }}\",\"options\":{\"delay\":3000,\"presence\":\"composing\"},\"textMessage\":{\"text\":\"⚠️ *Atenção!* Algumas mensagens da campanha *{{ $('Buscar campanhas').item.json.title }}* podem não ter sido enviadas. ⚠️\\n\\n✔️ Total de envios: {{ $json[\"enviou\"] }}\\n❌ Número de falhas: {{ $json[\"falhou\"] }}\\n#️⃣ Limite restante: {{ $json[\"limite_disparo\"] }}\\n\\nO limite de disparos diários foi excedido. Por favor, verifique os envios ou entre em contato com o suporte para mais informações.\\n\\nObrigado pela compreensão!\"}}", "options": {} }, "id": "894e381a-fd47-424f-b9f5-098676e0ce00", "name": "Envia relatorio1", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.1, "position": [ 1620, 80 ], "retryOnFail": false, "maxTries": 2, "waitBetweenTries": 2000, "executeOnce": true }, { "parameters": { "method": "POST", "url": "={{ $('Info_Base').item.json.evolution_url }}/message/sendText/{{ $('Info_Base').item.json.instance_name }}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "accept", "value": "application/json, text/plain, */*" }, { "name": "apikey", "value": "={{ $('Info_Base').item.json.global_api_key }}" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\"number\":\"{{ $('Info_Base').item.json[\"recebe_relatorio\"] }}\",\"options\":{\"delay\":3000,\"presence\":\"composing\"},\"textMessage\":{\"text\":\"📢 Notificação Importante 📢\\n\\n🚀 A campanha *{{ $('Buscar campanhas').item.json.title }}* foi iniciada com sucesso! 🎉\\n\\n📲 As mensagens estão sendo enviadas. Fique atento para atualizações.\\n\\nObrigado por utilizar nossos serviços! 😊\"}}", "options": {} }, "id": "b7e1db5a-9530-4907-ae39-6f0a5f92ec9a", "name": "Envia Notificação", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.1, "position": [ 160, 920 ], "retryOnFail": false, "maxTries": 2, "waitBetweenTries": 2000, "executeOnce": true }, { "parameters": { "assignments": { "assignments": [ { "id": "a588a036-88bc-4bc2-aefa-a2c0b9af2000", "name": "var_msg", "value": "={{ $('IF6').item.json.message.split('&nome').join($json.name).split('&email').join($json.email) }}", "type": "string" }, { "id": "16d86caa-9f85-496d-ae3d-7ad024e100d7", "name": "verificanum", "value": "={{ $('Loop Over Items').item.json.phone_number }}", "type": "string" } ] }, "options": {} }, "id": "7a474735-c8d1-4993-bc14-101d7106ca00", "name": "Edita Mensagem", "type": "n8n-nodes-base.set", "typeVersion": 3.3, "position": [ 980, 1040 ] }, { "parameters": { "fields": { "values": [ { "name": "mensagem", "stringValue": "={{ $('Edita Mensagem').item.json.var_msg.split(\"&doc=\")[0].replace(/\\n/g, \"\\\\n\") }}" }, { "name": "titulo", "stringValue": "={{ $('Campanha').item.json.msg.title }}" }, { "name": "doc", "stringValue": "={{ $('Campanha').item.json.doc }}" } ] }, "options": { "includeBinary": true } }, "id": "685aaf58-e036-409c-b7fe-68f924def8c8", "name": "Edit Fields", "type": "n8n-nodes-base.set", "typeVersion": 3.2, "position": [ 3120, 1460 ] }, { "parameters": { "fields": { "values": [ { "name": "mensagem", "stringValue": "={{ $('Edita Mensagem').item.json.var_msg.split(\"&img=\")[0].replace(/\\n/g, \"\\\\n\") }}" }, { "name": "titulo", "stringValue": "={{ $('Campanha').item.json.msg.title }}" }, { "name": "img", "stringValue": "={{ $('Campanha').item.json.img }}" } ] }, "options": { "includeBinary": true } }, "id": "4f0af8f5-0fe9-4f9d-a44a-93cacd561eea", "name": "Edit Fields2", "type": "n8n-nodes-base.set", "typeVersion": 3.2, "position": [ 3120, 1160 ] }, { "parameters": { "method": "POST", "url": "={{ $('Info_Base').item.json.evolution_url }}/message/sendMedia/{{ $('Info_Base').item.json.instance_name }}", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "accept", "value": "application/json, text/plain, */*" }, { "name": "apikey", "value": "={{ $('Info_Base').item.json.global_api_key }}" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"number\":\"{{ $node['Edita Mensagem'].json.verificanum }}\",\n \"options\":{\"delay\":3000,\"presence\":\"composing\"},\n \"mediaMessage\":{\"mediatype\":\"image\",\"caption\":\"{{ $json.mensagem }}\",\n \"media\":\"{{ $json[\"img\"] }}\"}\n}\n", "options": {} }, "id": "a235d6e7-3a28-4625-84f6-30b36505e606", "name": "Envia msg2", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.1, "position": [ 3260, 1160 ], "retryOnFail": false, "maxTries": 2, "waitBetweenTries": 2000, "executeOnce": true, "onError": "continueErrorOutput" }, { "parameters": { "method": "=POST", "url": "=https://evo.setabot.com.br/message/sendMedia/SetaBotQRCode", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "accept", "value": "application/json, text/plain, */*" }, { "name": "apikey", "value": "=d12a3367a8e365ff6bd6df881578fa42" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"number\": \"{{ $node['Edita Mensagem'].json.verificanum }}\",\n \"options\": {\n \"delay\": 3000,\n \"presence\": \"composing\"\n },\n \"mediaMessage\": {\n \"mediatype\": \"document\",\n \"media\": \"{{ $json[\"doc\"] }}\",\n \"caption\": \"{{ $json.mensagem }}\",\n \"fileName\": \"documento.pdf\"\n }\n}", "options": {} }, "id": "bded3f73-8499-4d2d-84df-f088f097df2e", "name": "Envia msg1", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.1, "position": [ 3260, 1460 ], "retryOnFail": false, "maxTries": 2, "waitBetweenTries": 2000, "executeOnce": true, "onError": "continueErrorOutput" } ], "pinData": {}, "connections": { "Schedule Trigger": { "main": [ [ { "node": "Info_Base", "type": "main", "index": 0 } ] ] }, "Horario": { "main": [ [ { "node": "IF6", "type": "main", "index": 0 }, { "node": "UPDATE CAMPANHA", "type": "main", "index": 0 } ] ] }, "Altera fuso horário": { "main": [ [ { "node": "Horario", "type": "main", "index": 0 } ] ] }, "Repetir ação": { "main": [ [ { "node": "Loop Over Items", "type": "main", "index": 0 } ] ] }, "Time Randon1": { "main": [ [ { "node": "Tempo de espera1", "type": "main", "index": 0 } ] ] }, "Tempo de espera1": { "main": [ [ { "node": "If1", "type": "main", "index": 0 } ] ] }, "IF6": { "main": [ [ { "node": "Item Lists1", "type": "main", "index": 0 } ] ] }, "Item Lists1": { "main": [ [ { "node": "Campanha", "type": "main", "index": 0 } ] ] }, "Loop Over Items": { "main": [ [ { "node": "Tratamento de lista", "type": "main", "index": 0 } ], [ { "node": "If2", "type": "main", "index": 0 } ] ] }, "If": { "main": [ [ { "node": "HTTP Request1", "type": "main", "index": 0 } ], [ { "node": "Notifica limite excedido", "type": "main", "index": 0 } ] ] }, "Busca falhas": { "main": [ [ { "node": "Adiciona num de falhas", "type": "main", "index": 0 } ] ] }, "Busca envios": { "main": [ [ { "node": "Adiciona envios", "type": "main", "index": 0 } ] ] }, "Campanha": { "main": [ [ { "node": "Busca contatos", "type": "main", "index": 0 } ] ] }, "Adiciona envios": { "main": [ [ { "node": "Busca Contato Existe", "type": "main", "index": 0 } ] ] }, "Salva conversa": { "main": [ [ { "node": "Wait", "type": "main", "index": 0 } ] ] }, "If3": { "main": [ [ { "node": "Repetir ação", "type": "main", "index": 0 } ], [ { "node": "Salva conversa", "type": "main", "index": 0 } ] ] }, "Wait": { "main": [ [ { "node": "Resolve Conversa", "type": "main", "index": 0 } ] ] }, "Busca limite diario": { "main": [ [ { "node": "If", "type": "main", "index": 0 } ] ] }, "If2": { "main": [ [ { "node": "Edita Mensagem", "type": "main", "index": 0 } ], [ { "node": "Edita Mensagem", "type": "main", "index": 0 } ] ] }, "If4": { "main": [ [ { "node": "Subtrair", "type": "main", "index": 0 } ], [ { "node": "Busca falhas", "type": "main", "index": 0 } ] ] }, "Wait1": { "main": [ [ { "node": "Busca Contato do Relatorio", "type": "main", "index": 0 } ] ] }, "Adiciona num de falhas": { "main": [ [ { "node": "Adiciona num não enviado", "type": "main", "index": 0 } ] ] }, "Adiciona num não enviado": { "main": [ [ { "node": "Repetir ação", "type": "main", "index": 0 } ] ] }, "If5": { "main": [ [ { "node": "Envia relatorio1", "type": "main", "index": 0 } ], [ { "node": "Postgres1", "type": "main", "index": 0 } ] ] }, "Notifica limite excedido": { "main": [ [ { "node": "If5", "type": "main", "index": 0 } ] ] }, "If6": { "main": [ [ { "node": "Envia relatorio", "type": "main", "index": 0 } ], [ { "node": "Postgres", "type": "main", "index": 0 } ] ] }, "Code": { "main": [ [ { "node": "Envia relatorio3", "type": "main", "index": 0 } ] ] }, "Code1": { "main": [ [ { "node": "Envia relatorio2", "type": "main", "index": 0 } ] ] }, "Postgres1": { "main": [ [ { "node": "Code1", "type": "main", "index": 0 } ] ] }, "Dados da campanha": { "main": [ [ { "node": "Resumo relatorio", "type": "main", "index": 0 } ] ] }, "Tratamento de lista": { "main": [ [ { "node": "Dados da campanha", "type": "main", "index": 0 } ] ] }, "Postgres": { "main": [ [ { "node": "Code", "type": "main", "index": 0 } ] ] }, "Resumo relatorio": { "main": [ [ { "node": "If6", "type": "main", "index": 0 } ] ] }, "Subtrair": { "main": [ [ { "node": "Time Randon1", "type": "main", "index": 0 } ] ] }, "Abre conversa de contato existente": { "main": [ [ { "node": "If3", "type": "main", "index": 0 } ] ] }, "Busca Contato Existe": { "main": [ [ { "node": "Abre conversa de contato existente", "type": "main", "index": 0 } ] ] }, "HTTP Request1": { "main": [ [ { "node": "If4", "type": "main", "index": 0 } ] ] }, "Seleciona conversa": { "main": [ [ { "node": "Fecha Conversa", "type": "main", "index": 0 } ] ] }, "Busca Contato do Relatorio": { "main": [ [ { "node": "Seleciona conversa", "type": "main", "index": 0 } ] ] }, "Resolve Conversa": { "main": [ [ { "node": "Repetir ação", "type": "main", "index": 0 } ] ] }, "Buscar campanhas": { "main": [ [ { "node": "Altera fuso horário", "type": "main", "index": 0 } ] ] }, "Busca contatos": { "main": [ [ { "node": "Envia Notificação", "type": "main", "index": 0 }, { "node": "Loop Over Items", "type": "main", "index": 0 } ] ] }, "Info_Base": { "main": [ [ { "node": "Buscar campanhas", "type": "main", "index": 0 } ] ] }, "Envia msg": { "main": [ [ { "node": "Busca envios", "type": "main", "index": 0 } ], [ { "node": "Busca falhas", "type": "main", "index": 0 } ] ] }, "Switch": { "main": [ [ { "node": "Edit Fields2", "type": "main", "index": 0 } ], [ { "node": "Edit Fields", "type": "main", "index": 0 } ] ] }, "If1": { "main": [ [ { "node": "Envia msg", "type": "main", "index": 0 } ], [ { "node": "Switch", "type": "main", "index": 0 } ] ] }, "Envia relatorio3": { "main": [ [ { "node": "Send Email2", "type": "main", "index": 0 }, { "node": "Wait1", "type": "main", "index": 0 } ] ] }, "Envia relatorio": { "main": [ [ { "node": "Send Email1", "type": "main", "index": 0 }, { "node": "Wait1", "type": "main", "index": 0 } ] ] }, "Envia relatorio2": { "main": [ [ { "node": "Send Email3", "type": "main", "index": 0 }, { "node": "Wait1", "type": "main", "index": 0 } ] ] }, "Envia relatorio1": { "main": [ [ { "node": "Send Email", "type": "main", "index": 0 }, { "node": "Wait1", "type": "main", "index": 0 } ] ] }, "Edita Mensagem": { "main": [ [ { "node": "Busca limite diario", "type": "main", "index": 0 } ] ] }, "Edit Fields": { "main": [ [ { "node": "Envia msg1", "type": "main", "index": 0 } ] ] }, "Edit Fields2": { "main": [ [ { "node": "Envia msg2", "type": "main", "index": 0 } ] ] }, "Envia msg2": { "main": [ [ { "node": "Busca envios", "type": "main", "index": 0 } ], [ { "node": "Busca falhas", "type": "main", "index": 0 } ] ] }, "Envia msg1": { "main": [ [ { "node": "Busca envios", "type": "main", "index": 0 } ], [ { "node": "Busca falhas", "type": "main", "index": 0 } ] ] } }, "active": false, "settings": { "executionOrder": "v1" }, "versionId": "23cd186f-7027-4f80-ab81-60c5876a43f1", "meta": { "templateCredsSetupCompleted": true, "instanceId": "33738330930e3881dd5571eca013f36ddf8aab20e4ea5c1f2ebaf4a2b4668ac6" }, "id": "xVN4ktEqvxZNZVUj", "tags": [ { "createdAt": "2024-06-24T17:54:45.734Z", "updatedAt": "2024-06-24T17:54:45.734Z", "id": "W4QFAwjDhUwUJMhH", "name": "Dev" } ] }