Disparador-de-Campanha-Chat.../Disparador EVO V2.json
2025-06-04 16:38:51 -03:00

3458 lines
91 KiB
JSON
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"name": "[ git:rodtanci ] - [ Campanhas mkt ]",
"nodes": [
{
"parameters": {
"conditions": {
"dateTime": [
{
"value1": "={{ $json.newDate }}",
"operation": "before",
"value2": "={{ $now }}"
}
]
}
},
"id": "af3685b3-eab2-4ac1-a63f-d399940596f4",
"name": "Horario",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
-4080,
980
]
},
{
"parameters": {
"content": "# Buscando Campanhas",
"height": 496,
"width": 1604
},
"id": "0a35d248-a977-43c3-b720-42fbd5f2eeec",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-4920,
780
]
},
{
"parameters": {
"content": "# Disparador de Campanha para ChatWoot [SAAS]\n## Evolution API V2\n\n\nv 2.2\nhttps://github.com/rodtanci/Disparador-de-Campanha-Chatwoot-Evolution",
"height": 183,
"width": 847,
"color": 4
},
"id": "2b08fd86-59cb-4e08-badf-136815dafbfc",
"name": "Sticky Note10",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-4920,
560
]
},
{
"parameters": {
"operation": "subtractFromDate",
"magnitude": "={{ $json.scheduled_at }}",
"timeUnit": "hours",
"duration": 3,
"options": {
"includeInputFields": true
}
},
"id": "62c5d2fc-25de-406b-89d5-05e88808f810",
"name": "Altera fuso horário",
"type": "n8n-nodes-base.dateTime",
"typeVersion": 2,
"position": [
-4260,
980
]
},
{
"parameters": {
"content": "# Busca contatos / Envia campanha\n",
"height": 1751,
"width": 5120,
"color": 3
},
"id": "c9ff9efb-a017-446e-99dd-0ed6c08b1db2",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-820,
760
]
},
{
"parameters": {},
"id": "afcb7a19-78fd-4f4b-b84f-e4be3ff8ebed",
"name": "Repetir ação",
"type": "n8n-nodes-base.noOp",
"typeVersion": 1,
"position": [
4160,
1200
]
},
{
"parameters": {
"conditions": {
"string": [
{
"value1": "={{ $('Buscar campanhas').item.json.campaign_type }}",
"value2": "={{ 1 }}"
}
]
}
},
"id": "cc85767f-589a-452d-b763-5b7ee991df93",
"name": "IF6",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
-3220,
960
]
},
{
"parameters": {
"fieldToSplitOut": "audience",
"include": "allOtherFields",
"options": {}
},
"id": "779c6bf2-dadc-4e41-9c83-79b6a2664497",
"name": "Item Lists1",
"type": "n8n-nodes-base.itemLists",
"typeVersion": 3,
"position": [
-3020,
960
]
},
{
"parameters": {
"options": {}
},
"id": "37c6e58a-9d80-44fd-beba-c15b0d56ac93",
"name": "Loop Over Items",
"type": "n8n-nodes-base.splitInBatches",
"typeVersion": 3,
"position": [
-700,
1000
],
"executeOnce": false,
"alwaysOutputData": false,
"retryOnFail": false,
"notesInFlow": false
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"id": "d0205698-dcfd-4d3c-b6e3-dfd7209035c3",
"leftValue": "={{ $json.limite_disparo }}",
"rightValue": 1,
"operator": {
"type": "number",
"operation": "gte"
}
}
],
"combinator": "and"
},
"options": {}
},
"id": "671c136a-2d37-4484-93f8-8dbcc491c83e",
"name": "If",
"type": "n8n-nodes-base.if",
"typeVersion": 2,
"position": [
460,
1040
]
},
{
"parameters": {
"content": "## Contador de limite / Verificação do número",
"height": 225.35612209945384,
"width": 853.0984671711764,
"color": 4
},
"id": "d1237fac-e66e-452d-bfa9-3f72cb49faac",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
260,
980
]
},
{
"parameters": {
"content": "## Time Randon",
"height": 230,
"width": 185,
"color": 4
},
"id": "213a88ba-9aff-47e0-a88d-3fe6d6680822",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
1380,
980
]
},
{
"parameters": {
"content": "## Contabiliza falhas",
"height": 225.08131697058332,
"width": 546.5336275124715,
"color": 2
},
"id": "5df925a0-cb2f-40ff-9d9a-5aec12612ee2",
"name": "Sticky Note6",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
2660,
1380
]
},
{
"parameters": {
"content": "## Contabiliza envios",
"height": 215.09474919455494,
"width": 376.16757486051324,
"color": 2
},
"id": "7efdd1b9-2fe6-41b3-af39-1b7e8d405882",
"name": "Sticky Note7",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
2400,
960
]
},
{
"parameters": {
"operation": "executeQuery",
"query": "SELECT falhou\nFROM campaigns\nWHERE id = {{ $node['Campanha'].json.id.campanha }};",
"options": {
"queryReplacement": "="
}
},
"id": "d50134d2-822d-4003-b78e-5f0ced8561ec",
"name": "Busca falhas",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.4,
"position": [
2700,
1420
]
},
{
"parameters": {
"operation": "executeQuery",
"query": "SELECT enviou\nFROM campaigns\nWHERE id = {{ $node['Campanha'].json.id.campanha }};",
"options": {}
},
"id": "52839db8-5e4e-4ba8-b78f-1e53e84c62ff",
"name": "Busca envios",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.4,
"position": [
2460,
1020
]
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "cbb23691-dfc9-413f-b996-ba0515b0a902",
"name": "etiqueta",
"value": "={{ $('Buscar campanhas').item.json.audience ? $('Buscar campanhas').item.json.audience.map(a => a.id).join(',') : '0' }}",
"type": "string"
},
{
"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": "={{ $('Buscar campanhas').item.json.message.split('&img=')[1].split('&')[0] }}",
"type": "string"
},
{
"id": "66e5ac5e-5cef-4737-81d8-9457f8fb8536",
"name": "nomecontato",
"value": "={{ $('Buscar campanhas').item.json.message.match(/&nome/)[0] }}",
"type": "string"
},
{
"id": "afa0b53c-9933-44e1-ab91-49a9540f9c7d",
"name": "emailcontato",
"value": "={{ $('Buscar campanhas').item.json.message.match(/&email/)[0] }}",
"type": "string"
},
{
"id": "fde7488d-6bca-4057-a2c3-17cd21ea41cd",
"name": "doc",
"value": "={{ $('Buscar campanhas').item.json.message.split('&doc=')[1].split('&')[0] }}",
"type": "string"
},
{
"id": "459f505e-48c9-4829-a151-e9a9c651901c",
"name": "vid",
"value": "={{ $('Buscar campanhas').item.json.message.split('&vid=')[1].split('&')[0] }}",
"type": "string"
},
{
"id": "d5e7b83d-8c4b-4f2c-9905-1d6921d6a303",
"name": "audio",
"value": "={{ $('IF6').item.json.message.split('&audio=')[1].split('&')[0] }}",
"type": "string"
},
{
"id": "3d8f599b-3796-4538-8e78-a29494e85e40",
"name": "origemcontato",
"value": "={{ $json.audience.type }}",
"type": "string"
},
{
"id": "b596f98b-fbe0-44d7-98b0-667b4530c8e9",
"name": "id.campanha",
"value": "={{ $('Loop Over Items1').item.json.id }}",
"type": "string"
},
{
"id": "f40f7b3d-3c50-4e15-9c50-40197caed5ad",
"name": "typebot",
"value": "={{ $('Buscar campanhas').item.json.message.split('&typebot=')[1].split('&')[0] }}",
"type": "string"
}
]
},
"options": {}
},
"id": "d70f5bbd-1f3e-4480-8098-3da0e6df77e0",
"name": "Campanha",
"type": "n8n-nodes-base.set",
"typeVersion": 3.3,
"position": [
-2840,
960
]
},
{
"parameters": {
"content": "# Relatorio da campanha",
"height": 346.43605543050865,
"width": 1085.0447604700087
},
"id": "937f0a8a-8a42-4ea3-ac0a-b96f9a7867ca",
"name": "Sticky Note8",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
0,
400
]
},
{
"parameters": {
"content": "# Limite excedido ",
"height": 339.69571412210314,
"width": 1088.2492332463764
},
"id": "bc1e15fb-d0ff-4d3e-b95c-50dfc0ae2d23",
"name": "Sticky Note9",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
0,
0
]
},
{
"parameters": {
"operation": "executeQuery",
"query": "UPDATE campaigns\nSET enviou = {{ $json.enviou +1 }}\nWHERE id = {{ $node['Campanha'].json.id.campanha }};",
"options": {}
},
"id": "0ac0bc09-5dac-47ac-a8f3-238663bb9879",
"name": "Adiciona envios",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.4,
"position": [
2620,
1020
]
},
{
"parameters": {
"content": "## Somente texto",
"height": 199.63817652105178,
"width": 313.99126283929667
},
"id": "69c77ce0-f986-49eb-9085-6c48aa04afc4",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
2020,
820
]
},
{
"parameters": {
"content": "## Com imagem",
"height": 221.17684873191945,
"width": 313.99126283929667
},
"id": "97988853-b188-49e9-8cf0-b4c0efe210b3",
"name": "Sticky Note11",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
2020,
1080
]
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"id": "ebbe2797-49a1-47e7-9c54-161ff02dfa49",
"leftValue": "={{ $node['Campanha'].json.nomecontato }}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "empty",
"singleValue": true
}
},
{
"id": "77ff2a0a-ae27-427a-b489-2daac4e90429",
"leftValue": "={{ $node['Campanha'].json.emailcontato}}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "empty",
"singleValue": true
}
}
],
"combinator": "or"
},
"options": {}
},
"id": "81b27169-198d-4493-8aed-2149bc538866",
"name": "If2",
"type": "n8n-nodes-base.if",
"typeVersion": 2,
"position": [
-340,
1020
]
},
{
"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": "4e437898-35ee-4ab2-b760-41453999401c",
"name": "Sticky Note12",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
2860,
920
]
},
{
"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": "5e24f02e-5e63-4d95-971e-40abcb822015",
"name": "Salva conversa",
"type": "n8n-nodes-base.set",
"typeVersion": 3.3,
"position": [
3480,
1020
]
},
{
"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": "7a74979c-2929-4f51-9a73-91b68f24407d",
"name": "If3",
"type": "n8n-nodes-base.if",
"typeVersion": 2,
"position": [
3220,
1020
]
},
{
"parameters": {
"amount": 1
},
"id": "8f6bd327-9246-49ed-bfce-2e5583e4e868",
"name": "Wait",
"type": "n8n-nodes-base.wait",
"typeVersion": 1.1,
"position": [
3640,
1020
],
"webhookId": "2d3bd1b8-c8ab-4867-ac65-63691f4eee0e"
},
{
"parameters": {
"content": "# Resolve Conversa",
"height": 246.1701698163285,
"width": 704.4608631799392
},
"id": "9f14bdfc-4f4f-43ab-a000-ea19c22f5a54",
"name": "Sticky Note13",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
1280,
260
]
},
{
"parameters": {
"operation": "executeQuery",
"query": "SELECT limite_disparo\nFROM accounts\nWHERE id ={{ $node['Info_Base'].json.chatwoot_account_id }};",
"options": {
"queryReplacement": "="
}
},
"id": "09b42992-c209-4321-a9ae-be9532be8682",
"name": "Busca limite diario",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.4,
"position": [
300,
1040
]
},
{
"parameters": {
"fromEmail": "={{ $node['Info_Base'].json.email_envia_relatorio }}",
"toEmail": "={{ $node['Info_Base'].json.email_relatorio }}",
"subject": "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": "c64ef351-bb4a-487d-9796-6cded86839db",
"name": "Send Email",
"type": "n8n-nodes-base.emailSend",
"typeVersion": 2,
"position": [
740,
60
],
"webhookId": "76b88e39-9633-4f6c-89ce-c805f0f9ea8e",
"disabled": true,
"continueOnFail": true
},
{
"parameters": {
"fromEmail": "={{ $node['Info_Base'].json.email_envia_relatorio }}",
"toEmail": "={{ $node['Info_Base'].json.email_relatorio }}",
"subject": "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": "04254391-09d0-49eb-923b-5dae6aef632a",
"name": "Send Email1",
"type": "n8n-nodes-base.emailSend",
"typeVersion": 2,
"position": [
740,
460
],
"webhookId": "3f48c037-fb6f-497f-b146-9d55acbb4596",
"disabled": true,
"continueOnFail": true
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"id": "c2573aed-9acc-4fc6-a799-b11e2191d408",
"leftValue": "={{ $json.exists }}",
"rightValue": "true",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"id": "fc7fbe8b-43a0-452a-bcac-987a0446ccd8",
"name": "If4",
"type": "n8n-nodes-base.if",
"typeVersion": 2,
"position": [
800,
1040
]
},
{
"parameters": {},
"id": "e473c925-689c-495a-8067-261a6eb61cbb",
"name": "Wait1",
"type": "n8n-nodes-base.wait",
"typeVersion": 1.1,
"position": [
1340,
340
],
"webhookId": "39bf7e5c-0cb9-4e8b-9ff7-8bda47bf82d2"
},
{
"parameters": {
"operation": "executeQuery",
"query": "UPDATE campaigns\nSET falhou = {{ $json.falhou +1 }}\nWHERE id = {{ $node['Campanha'].json.id.campanha }};",
"options": {}
},
"id": "b4a4f280-53e2-4207-bc99-a8396e8c7b6b",
"name": "Adiciona num de falhas",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.4,
"position": [
2880,
1420
]
},
{
"parameters": {
"operation": "executeQuery",
"query": "INSERT INTO campaigns_failled (nomecontato, telefone, id_campanha)\nSELECT '{{ $node['Busca contatos'].json.name }}', '{{ $node['Busca contatos'].json.phone_number }}', {{ $('Buscar campanhas').item.json.id }}\nWHERE NOT EXISTS (\n SELECT 1\n FROM campaigns_failled\n WHERE telefone = '{{ $node['Busca contatos'].json.phone_number }}' AND id_campanha = {{ $node['Busca contatos'].json.id }}\n);",
"options": {}
},
"id": "03148187-e53a-4179-9e80-ad9c205c752e",
"name": "Adiciona num não enviado",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.4,
"position": [
3060,
1420
]
},
{
"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": "9b76a6e4-86e4-45f2-8770-0c44085c68b6",
"name": "If5",
"type": "n8n-nodes-base.if",
"typeVersion": 2,
"position": [
220,
160
]
},
{
"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 = {{ $node['Campanha'].json.id.campanha }};",
"options": {
"queryReplacement": "="
}
},
"id": "bc523351-5cfa-4d05-ac41-7f175b7a9aca",
"name": "Notifica limite excedido",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.4,
"position": [
60,
160
]
},
{
"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": "eafba039-3320-42fc-917d-328245d3f41d",
"name": "If6",
"type": "n8n-nodes-base.if",
"typeVersion": 2,
"position": [
220,
560
]
},
{
"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": "0abcbd7a-55d3-43cd-80f4-6acab467b6c2",
"name": "Code",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
560,
600
]
},
{
"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": "d777a475-fbd7-40cb-95fb-c0f682fa646b",
"name": "Code1",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
560,
200
]
},
{
"parameters": {
"fromEmail": "={{ $node['Info_Base'].json.email_envia_relatorio }}",
"toEmail": "={{ $node['Info_Base'].json.email_relatorio }}",
"subject": "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": "0a946e60-4112-4cad-8137-3b48b829df36",
"name": "Send Email2",
"type": "n8n-nodes-base.emailSend",
"typeVersion": 2,
"position": [
920,
600
],
"webhookId": "ec514a04-3386-4382-9a87-ed972c1479d4",
"disabled": true,
"continueOnFail": true
},
{
"parameters": {
"operation": "executeQuery",
"query": "SELECT \n (SELECT COUNT(*) FROM campaigns_failled WHERE id_campanha = {{ $node['Campanha'].json.id.campanha }}) AS total_registros,\n campaigns_failled.*\nFROM campaigns_failled\nWHERE id_campanha = {{ $node['Campanha'].json.id.campanha }};",
"options": {}
},
"id": "fe8b783b-606a-49e8-b485-1a843cb63d78",
"name": "Postgres1",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.4,
"position": [
380,
200
],
"alwaysOutputData": true
},
{
"parameters": {
"fromEmail": "={{ $node['Info_Base'].json.email_envia_relatorio }}",
"toEmail": "={{ $node['Info_Base'].json.email_relatorio }}",
"subject": "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": "08b3d373-2bfa-40e7-bdd2-7242c7764532",
"name": "Send Email3",
"type": "n8n-nodes-base.emailSend",
"typeVersion": 2,
"position": [
920,
200
],
"webhookId": "c85a18f5-abeb-42fb-a02c-0fcc8293beea",
"disabled": true,
"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": "4a5d4ec6-9f52-4479-bbd8-15b9a8cb4aa2",
"name": "Dados da campanha",
"type": "n8n-nodes-base.set",
"typeVersion": 3.3,
"position": [
-260,
580
]
},
{
"parameters": {
"fieldToSplitOut": "audience",
"include": "allOtherFields",
"options": {}
},
"id": "c8b7109e-c362-4ff0-9c53-270f3e850376",
"name": "Tratamento de lista",
"type": "n8n-nodes-base.itemLists",
"typeVersion": 3,
"position": [
-480,
840
],
"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": "f09f436d-2ae6-40a1-be5d-e3cbf0df35f8",
"name": "Postgres",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.4,
"position": [
380,
600
],
"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 = {{ $node['Campanha'].json.id.campanha }};",
"options": {}
},
"id": "2373743e-0dbf-474e-a363-157572a9152c",
"name": "Resumo relatorio",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.4,
"position": [
60,
560
]
},
{
"parameters": {
"operation": "executeQuery",
"query": "UPDATE accounts\nSET limite_disparo = {{ $('Busca limite diario').item.json.limite_disparo -1 }}\nWHERE id ={{ $node['Info_Base'].json.chatwoot_account_id }};",
"options": {}
},
"id": "b8922b48-57dd-4fe5-b02b-e13c4e2faf9f",
"name": "Subtrair",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.4,
"position": [
980,
1040
]
},
{
"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": "94b14301-b657-40b9-aaeb-f170250c2642",
"name": "Abre conversa de contato existente",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 3,
"position": [
3060,
1020
],
"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": "8496378d-2b92-4b5d-bd59-8c51fa503926",
"name": "Busca Contato Existe",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 3,
"position": [
2900,
1020
],
"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": "220afd40-7ded-4a65-b0cf-011f1f4e2446",
"name": "HTTP Request1",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
640,
1040
]
},
{
"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": "7eece7a5-0888-4ca6-b9b5-0b51bb6f992e",
"name": "Fecha Conversa",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 3,
"position": [
1820,
340
],
"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": "b1bc75cd-8053-4ae9-85a5-b35734a5a58f",
"name": "Seleciona conversa",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 3,
"position": [
1660,
340
],
"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": "b52d511e-160c-48b3-bee7-9f4a2a7cf4d6",
"name": "Busca Contato do Relatorio",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 3,
"position": [
1500,
340
],
"onError": "continueRegularOutput"
},
{
"parameters": {
"operation": "executeQuery",
"query": "UPDATE conversations\nSET status = 1\nWHERE contact_id = {{ $json.id_contato }};",
"options": {}
},
"id": "f0394c0e-20ba-4a9b-9cf1-f81a8e992fcb",
"name": "Resolve Conversa",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.4,
"position": [
3820,
1020
],
"onError": "continueRegularOutput"
},
{
"parameters": {
"content": "## Com documento",
"height": 221.17684873191945,
"width": 313.99126283929667
},
"id": "93e2729a-b358-4b6f-bcf3-5f7482d3ccc3",
"name": "Sticky Note14",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
2020,
1380
]
},
{
"parameters": {
"operation": "executeQuery",
"query": "UPDATE campaigns SET status_envia = 1 WHERE id = {{ $json.id }}",
"options": {}
},
"id": "88b83b73-4bcb-4d20-8822-3ad1a408f99c",
"name": "UPDATE CAMPANHA",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.4,
"position": [
-3820,
820
],
"alwaysOutputData": false,
"credentials": {
"postgres": {
"id": "jMSUQjgrwiXnjRkn",
"name": "SetaV4"
}
}
},
{
"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\": \"{{ $('HTTP Request1').item.json.jid }}\",\n \"text\": \"{{ $node['Edita Mensagem'].json.var_msg.replace(/\"/g, '\\\\\"').replace(/\\n/g, '\\\\n') }}\",\n \"delay\": 1200\n}",
"options": {}
},
"id": "5389d39b-12e0-42b4-ab9e-c0eab61ba9b3",
"name": "Envia msg",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.1,
"position": [
2120,
880
],
"retryOnFail": false,
"maxTries": 2,
"waitBetweenTries": 2000,
"executeOnce": true,
"onError": "continueErrorOutput"
},
{
"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 \"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{{ $node['Code'].json.listaContatos.replace(/\\n/g, '\\\\n') }} \\n\\nObrigado por utilizar nossos serviços!\"\n}",
"options": {}
},
"id": "011054d0-b474-4a03-9440-14c059645add",
"name": "Envia relatorio3",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.1,
"position": [
740,
600
],
"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": "={\n \"number\": \"{{ $node['Info_Base'].json[\"recebe_relatorio\"] }}\",\n \"text\": \"📢 Campanha *{{ $node['Buscar campanhas'].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!\"\n}",
"options": {}
},
"id": "d3b89aa9-4fe2-457b-a6ab-5442bb4533db",
"name": "Envia relatorio",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.1,
"position": [
560,
460
],
"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": "={\n \"number\": \"{{ $node['Info_Base'].json[\"recebe_relatorio\"] }}\",\n \"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{{ $node['Code1'].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": "5f01fdef-572f-4625-99c6-497a23093d33",
"name": "Envia relatorio2",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.1,
"position": [
740,
200
],
"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": "={\n \"number\": \"{{ $node['Info_Base'].json[\"recebe_relatorio\"] }}\",\n \"text\": \"⚠️ *Atenção!* Algumas mensagens da campanha *{{ $node['Buscar campanhas'].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!\"\n}",
"options": {}
},
"id": "05ef641b-877e-43b8-af3d-05f9aff052a7",
"name": "Envia relatorio1",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.1,
"position": [
560,
60
],
"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": "={\n \"number\": \"{{ $node['Info_Base'].json[\"recebe_relatorio\"] }}\",\n \"text\": \"📢 Notificação Importante 📢\\n\\n🚀 A campanha *{{ $node['Buscar campanhas'].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! 😊\"\n}",
"options": {}
},
"id": "942f356e-95fb-4ad0-a452-88cca30c6c61",
"name": "Envia Notificação",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.1,
"position": [
-700,
860
],
"retryOnFail": false,
"maxTries": 2,
"waitBetweenTries": 2000,
"executeOnce": true
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "a588a036-88bc-4bc2-aefa-a2c0b9af2000",
"name": "var_msg",
"value": "={{ $node['Campanha'].json.msg.message.split('&nome').join($('Loop Over Items').item.json.nome).split('&email').join($('Loop Over Items').item.json.email) }}",
"type": "string"
},
{
"id": "16d86caa-9f85-496d-ae3d-7ad024e100d7",
"name": "verificanum",
"value": "={{ $node['Loop Over Items'].json.phone_number || $('Loop Over Items').item.json.identifier }}",
"type": "string"
}
]
},
"options": {}
},
"id": "5309f11e-d3a5-46e9-9574-7d211aaeeac0",
"name": "Edita Mensagem",
"type": "n8n-nodes-base.set",
"typeVersion": 3.3,
"position": [
-80,
1020
]
},
{
"parameters": {
"fields": {
"values": [
{
"name": "mensagem",
"stringValue": "={{ $node['Edita Mensagem'].json.var_msg.split(\"&doc=\")[0].replace(/\"/g, '\\\\\"').replace(/\\n/g, '\\\\n') }}"
},
{
"name": "titulo",
"stringValue": "={{ $('Campanha').item.json.msg.title }}"
},
{
"name": "doc",
"stringValue": "={{ $('Campanha').item.json.doc }}"
}
]
},
"options": {
"includeBinary": true
}
},
"id": "ed6c53c1-f0c6-4b23-89ad-e799bd06518a",
"name": "Edit Fields",
"type": "n8n-nodes-base.set",
"typeVersion": 3.2,
"position": [
2060,
1440
]
},
{
"parameters": {
"fields": {
"values": [
{
"name": "mensagem",
"stringValue": "={{ $node['Edita Mensagem'].json.var_msg.split(\"&img=\")[0].replace(/\"/g, '\\\\\"').replace(/\\n/g, '\\\\n') }}"
},
{
"name": "titulo",
"stringValue": "={{ $('Campanha').item.json.msg.title }}"
},
{
"name": "img",
"stringValue": "={{ $('Campanha').item.json.img }}"
}
]
},
"options": {
"includeBinary": true
}
},
"id": "0f23165b-b0db-4e02-b46e-e805563b78a6",
"name": "Edit Fields2",
"type": "n8n-nodes-base.set",
"typeVersion": 3.2,
"position": [
2060,
1140
]
},
{
"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\": \"{{ $('HTTP Request1').item.json.jid }}\",\n \"mediatype\": \"image\",\n \"mimetype\": \"image/png\",\n \"caption\": \"{{ $json.mensagem }}\",\n \"media\": \"{{ $json[\"img\"] }}\",\n \"delay\": 1200\n}\n",
"options": {}
},
"id": "83fe73aa-35ad-446c-a187-2a49c27e33ad",
"name": "Envia msg2",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.1,
"position": [
2200,
1140
],
"retryOnFail": false,
"maxTries": 2,
"waitBetweenTries": 2000,
"executeOnce": true,
"onError": "continueErrorOutput"
},
{
"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\": \"{{ $('HTTP Request1').item.json.jid }}\",\n \"mediatype\": \"document\",\n \"caption\": \"{{ $json.mensagem }}\",\n \"media\": \"{{ $json[\"doc\"] }}\",\n \"fileName\": \"documento.pdf\",\n \"delay\": 1200\n}",
"options": {}
},
"id": "a3cf75c3-13fe-40e6-b77f-13e44ede5ab9",
"name": "Envia msg1",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.1,
"position": [
2200,
1440
],
"retryOnFail": false,
"maxTries": 2,
"waitBetweenTries": 2000,
"executeOnce": true,
"onError": "continueErrorOutput"
},
{
"parameters": {
"content": "## Com video",
"height": 221.17684873191945,
"width": 313.99126283929667
},
"id": "a570d4ad-5d63-44f9-a744-dd384f3abf37",
"name": "Sticky Note15",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
2020,
1680
]
},
{
"parameters": {
"fields": {
"values": [
{
"name": "mensagem",
"stringValue": "={{ $node['Edita Mensagem'].json.var_msg.split(\"&vid=\")[0].replace(/\"/g, '\\\\\"').replace(/\\n/g, '\\\\n') }}"
},
{
"name": "titulo",
"stringValue": "={{ $('Campanha').item.json.msg.title }}"
},
{
"name": "vid",
"stringValue": "={{ $('Campanha').item.json.vid }}"
}
]
},
"options": {
"includeBinary": true
}
},
"id": "6ac17022-f929-4691-8e5b-a8cd1b7495b4",
"name": "Edit Fields1",
"type": "n8n-nodes-base.set",
"typeVersion": 3.2,
"position": [
2060,
1740
]
},
{
"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\": \"{{ $('HTTP Request1').item.json.jid }}\",\n \"mediatype\": \"video\",\n \"caption\": \"{{ $json.mensagem }}\",\n \"media\": \"{{ $json[\"vid\"] }}\",\n \"delay\": 1200\n}\n",
"options": {}
},
"id": "1980b679-fdea-4783-bdb6-64386adcab0b",
"name": "Envia msg3",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.1,
"position": [
2200,
1740
],
"retryOnFail": false,
"maxTries": 2,
"waitBetweenTries": 2000,
"executeOnce": true,
"onError": "continueErrorOutput"
},
{
"parameters": {
"options": {}
},
"id": "51088462-8034-419d-a3e4-126eb6979f66",
"name": "Loop Over Items1",
"type": "n8n-nodes-base.splitInBatches",
"typeVersion": 3,
"position": [
-4480,
960
]
},
{
"parameters": {
"rules": {
"values": [
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"leftValue": "={{ $node['Campanha'].json.img }}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "notEmpty",
"singleValue": true
},
"id": "65b1f5f0-2d2b-4a94-a852-67a3ea38623a"
}
],
"combinator": "and"
}
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"id": "68892a20-1c5e-42f8-a74d-aec4a687d0dd",
"leftValue": "={{ $node['Campanha'].json.doc }}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "notEmpty",
"singleValue": true
}
}
],
"combinator": "and"
}
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"id": "a430d20e-500b-4938-a0c4-78d66d8bdff4",
"leftValue": "={{ $node['Campanha'].json.vid }}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "notEmpty",
"singleValue": true
}
}
],
"combinator": "and"
}
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"id": "3bd5629e-b41c-428e-98eb-733fe1fa5c95",
"leftValue": "={{ $node['Campanha'].json.audio}}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "notEmpty",
"singleValue": true
}
}
],
"combinator": "and"
}
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"id": "ac9b8896-a202-427a-b6f9-70fdb6d677d0",
"leftValue": "={{ $node['Campanha'].json.typebot}}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "notEmpty",
"singleValue": true
}
}
],
"combinator": "and"
}
}
]
},
"options": {
"fallbackOutput": "extra"
}
},
"id": "d5356372-9fe0-4107-be43-ac5367c6fc72",
"name": "Switch",
"type": "n8n-nodes-base.switch",
"typeVersion": 3,
"position": [
1760,
1280
]
},
{
"parameters": {
"content": "## Com Audio",
"height": 221.17684873191945,
"width": 313.99126283929667
},
"id": "dc8b2179-66d7-4043-b63b-0eb869683fc5",
"name": "Sticky Note16",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
2020,
1980
]
},
{
"parameters": {
"fields": {
"values": [
{
"name": "audio",
"stringValue": "={{ $('Campanha').item.json.audio }}"
}
]
},
"options": {
"includeBinary": true
}
},
"id": "93026f4c-33d4-4db2-a086-bf435a741198",
"name": "Edit Fields3",
"type": "n8n-nodes-base.set",
"typeVersion": 3.2,
"position": [
2060,
2040
]
},
{
"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\": \"{{ $('HTTP Request1').item.json.jid }}\",\n \"mediatype\": \"audio\",\n \"media\": \"{{ $json[\"audio\"] }}\",\n \"delay\": 1200\n \n}",
"options": {}
},
"id": "03b1f8b9-9b33-43d8-b769-ecef6d7d74e0",
"name": "Envia msg4",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.1,
"position": [
2200,
2040
],
"retryOnFail": false,
"maxTries": 2,
"waitBetweenTries": 2000,
"executeOnce": true,
"onError": "continueErrorOutput"
},
{
"parameters": {
"operation": "executeQuery",
"query": "select * from campaigns c where campaign_type = 1 and status_envia = 0 and account_id = 1",
"additionalFields": {}
},
"id": "dc28226f-841a-4479-b6d4-1c23ec58b9d9",
"name": "Buscar campanhas",
"type": "n8n-nodes-base.postgres",
"typeVersion": 1,
"position": [
-4680,
960
],
"credentials": {
"postgres": {
"id": "jMSUQjgrwiXnjRkn",
"name": "SetaV4"
}
}
},
{
"parameters": {
"operation": "executeQuery",
"query": "select * from inboxes i where id = {{ $json.inbox_id }}",
"options": {}
},
"id": "781e1a4d-3163-492a-88dd-05c2fa4a622d",
"name": "Busca Disparador",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.4,
"position": [
-3820,
980
],
"credentials": {
"postgres": {
"id": "jMSUQjgrwiXnjRkn",
"name": "SetaV4"
}
}
},
{
"parameters": {
"operation": "executeQuery",
"query": "select * from channel_sms where id = {{ $json.channel_id }}",
"options": {}
},
"id": "028630f8-42ae-404e-80d6-78bfc2208636",
"name": "Busca Caixa de Disparo",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.4,
"position": [
-3640,
980
],
"credentials": {
"postgres": {
"id": "jMSUQjgrwiXnjRkn",
"name": "SetaV4"
}
}
},
{
"parameters": {
"keepOnlySet": true,
"values": {
"string": [
{
"name": "chatwoot_url",
"value": "https://chatwoot"
},
{
"name": "evolution_url",
"value": "https://evolution"
},
{
"name": "typebotapi_url",
"value": "url do typebot"
},
{
"name": "global_api_key",
"value": "token_evolution"
},
{
"name": "chatwoot_token",
"value": "token do chatwoot"
},
{
"name": "email_envia_relatorio",
"value": "email que envia o relatorio"
},
{
"name": "instance_name",
"value": "={{ $json.provider_config.application_id }}"
},
{
"name": "chatwoot_account_id",
"value": "={{ $('Buscar campanhas').item.json.account_id }}"
},
{
"name": "recebe_relatorio",
"value": "={{ $json.provider_config.api_key }}"
},
{
"name": "email_relatorio",
"value": "={{ $json.provider_config.api_secret }}"
},
{
"name": "audience",
"value": "={{ $('Buscar campanhas').item.json.audience }}"
}
]
},
"options": {}
},
"id": "6d30cadc-4415-42ff-8198-a655c74cb91e",
"name": "Info_Base",
"type": "n8n-nodes-base.set",
"typeVersion": 2,
"position": [
-3460,
980
]
},
{
"parameters": {
"rule": {
"interval": [
{
"field": "minutes",
"minutesInterval": 1
}
]
}
},
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.2,
"position": [
-4860,
960
],
"id": "a4bd6ede-e13a-492c-ab06-73ee44e4aaea",
"name": "Schedule Trigger"
},
{
"parameters": {
"content": "## Typebot",
"height": 199.63817652105178,
"width": 313.99126283929667
},
"id": "f57cb77c-b65f-44b4-be78-10dbbec420a2",
"name": "Sticky Note17",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
2020,
2260
]
},
{
"parameters": {
"method": "POST",
"url": "={{ $node['Info_Base'].json.evolution_url }}/typebot/start/{{ $node['Info_Base'].json.instance_name }}",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "apikey",
"value": "={{ $node['Info_Base'].json.global_api_key }}"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"url\": \"{{ $node['Info_Base'].json.typebotapi_url }}\",\n \"typebot\": \"{{ $node['Code2'].json.typebot }}\",\n \"remoteJid\": \"{{ $('Edita Mensagem').item.json.verificanum }}\",\n \"startSession\": true,\n \"variables\": [\n {\n \"name\": \"pushName\",\n \"value\": \"{{ $node['Edita Mensagem'].json.nome }}\"\n },\n {\n \"name\": \"email\",\n \"value\": \"{{ $node['Edita Mensagem'].json.email }}\"\n }\n ]\n}",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
2120,
2320
],
"id": "5475a7f8-a1d4-43ca-ae7b-3209617d9ecf",
"name": "HTTP Request",
"onError": "continueErrorOutput"
},
{
"parameters": {
"content": "# Tratamento da campanha",
"height": 497,
"width": 608,
"color": 2
},
"id": "49f5c083-b152-4fcb-b005-13596c0823d6",
"name": "Sticky Note18",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-3280,
780
]
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "3817bfe2-1046-4a2e-b91b-3ecc981cf9d2",
"leftValue": "={{ $json.typebot }}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "notEmpty",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
-2620,
960
],
"id": "07609a03-2ca8-489b-a308-e3d663a8e1ed",
"name": "If1"
},
{
"parameters": {
"url": "={{ $('Info_Base').item.json.evolution_url }}/typebot/find/{{ $('Info_Base').item.json.instance_name }}",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "apikey",
"value": "={{ $('Info_Base').item.json.global_api_key }}"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
-2440,
840
],
"id": "246a1dfa-0269-4ce0-bb00-1b22b20a59a6",
"name": "HTTP Request2"
},
{
"parameters": {
"jsCode": "const targetTypebot = $('Campanha').first().json.typebot;\nconst registros = items; // todos os registros recebidos no nó\n\nconst existe = registros.some(item => item.json.typebot === targetTypebot);\n\nreturn [\n {\n json: {\n resultado: existe ? 'exist' : 'no',\n typebot: targetTypebot\n }\n }\n];\n"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-2280,
840
],
"id": "21683e59-6c19-471e-a4f0-5331a691aa23",
"name": "Code2"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "7eaa4c79-554b-429b-b145-f0712db74bcb",
"leftValue": "={{ $json.resultado }}",
"rightValue": "exist",
"operator": {
"type": "string",
"operation": "equals",
"name": "filter.operator.equals"
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
-2120,
840
],
"id": "ae7305e4-6774-4ea7-bf3d-684fa3fc6cda",
"name": "If7"
},
{
"parameters": {
"method": "POST",
"url": "={{ $('Info_Base').item.json.evolution_url }}/typebot/create/{{ $('Info_Base').item.json.instance_name }}",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "apikey",
"value": "={{ $('Info_Base').item.json.global_api_key }}"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"enabled\": true,\n \"url\": \"{{ $('Info_Base').item.json.typebotapi_url }}\",\n \"typebot\": \"{{ $('Campanha').item.json.typebot }}\",\n \"triggerType\": \"none\",\n \"triggerOperator\": \"regex\",\n \"triggerValue\": \"^atend.*\",\n \"expire\": 20,\n \"keywordFinish\": \"#SAIR\",\n \"delayMessage\": 1000,\n \"unknownMessage\": \"Mensagem não reconhecida\",\n \"listeningFromMe\": false,\n \"stopBotFromMe\": false,\n \"keepOpen\": false,\n \"debounceTime\": 10\n}",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
-2120,
980
],
"id": "5e742181-94c3-4b28-9e72-c3e3617cd200",
"name": "HTTP Request3"
},
{
"parameters": {
"content": "# Verifica Typebot",
"height": 497,
"width": 688,
"color": 2
},
"id": "45d21a52-fef5-46d0-b780-9e91f152d73e",
"name": "Sticky Note19",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-2640,
780
]
},
{
"parameters": {},
"type": "n8n-nodes-base.merge",
"typeVersion": 3.1,
"position": [
-1180,
960
],
"id": "ed66e103-e3d7-4bda-95a8-836d2b990f19",
"name": "Merge"
},
{
"parameters": {
"url": "={{ $('Info_Base').item.json.chatwoot_url }}/api/v1/accounts/{{ $('Info_Base').item.json.chatwoot_account_id }}/contacts?{{ $input.all().map(item =>`labels[]=${encodeURIComponent(item.json.title)}`).join('&') }}",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "page",
"value": "1"
}
]
},
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "api_access_token",
"value": "={{ $('Info_Base').item.json.chatwoot_token }}"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
-1420,
860
],
"id": "b3ef097b-e1ac-41c9-8c47-f4d430389504",
"name": "contatos"
},
{
"parameters": {
"url": "={{ $('Info_Base').item.json.chatwoot_url }}/api/v1/accounts/{{ $('Info_Base').item.json.chatwoot_account_id }}/conversations?{{ $input.all().map(item =>`labels[]=${encodeURIComponent(item.json.title)}`).join('&') }}",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "page",
"value": "1"
}
]
},
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "api_access_token",
"value": "={{ $('Info_Base').item.json.chatwoot_token }}"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
-1420,
1080
],
"id": "4b068cda-febc-45c2-be30-3be4ff2f3361",
"name": "conversas"
},
{
"parameters": {
"operation": "executeQuery",
"query": "select * from labels i where id = {{ JSON.parse($('Campanha').item.json.etiqueta) }};",
"options": {}
},
"id": "87665ccb-bb25-487f-a61d-fafb3519783c",
"name": "Labels",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.4,
"position": [
-1660,
1080
],
"credentials": {
"postgres": {
"id": "jMSUQjgrwiXnjRkn",
"name": "SetaV4"
}
}
},
{
"parameters": {
"jsCode": "const items = $input.all();\nconst contatosMap = {};\n\nfor (const item of items) {\n const data = item.json;\n\n // 1) Mapeia contatos do primeiro payload\n if (Array.isArray(data.payload)) {\n for (const user of data.payload) {\n // usa identifier ou phone_number como chave única\n const key = user.identifier || user.phone_number;\n if (!contatosMap[key]) {\n contatosMap[key] = {\n id_contato: user.id,\n id_conversa: null,\n nome: user.name,\n email: user.email,\n identifier: user.identifier,\n phone_number: user.phone_number,\n };\n }\n }\n }\n\n // 2) Mapeia conversas do segundo payload\n if (data.data?.payload && Array.isArray(data.data.payload)) {\n for (const conv of data.data.payload) {\n const sender = conv.meta?.sender;\n if (!sender) continue;\n const key = sender.identifier || sender.phone_number;\n if (!contatosMap[key]) {\n contatosMap[key] = {\n id_contato: sender.id,\n id_conversa: conv.id,\n nome: sender.name,\n email: sender.email,\n identifier: sender.identifier,\n phone_number: sender.phone_number,\n };\n } else if (!contatosMap[key].id_conversa) {\n contatosMap[key].id_conversa = conv.id;\n }\n }\n }\n}\n\nreturn Object.values(contatosMap);\n"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-1000,
960
],
"id": "de0311c7-4170-4e60-9dde-0620d75cb987",
"name": "Contatos"
},
{
"parameters": {
"operation": "executeQuery",
"query": "SELECT *\nFROM labels\nWHERE id IN ({{ $('Campanha').item.json.etiqueta }});",
"options": {}
},
"id": "b161c00e-5b2d-4905-b1a1-8c22f1d66e90",
"name": "Multi-Labels",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.4,
"position": [
-1660,
860
],
"credentials": {
"postgres": {
"id": "jMSUQjgrwiXnjRkn",
"name": "SetaV4"
}
}
},
{
"parameters": {
"content": "## Busca Etiqueta",
"height": 497,
"width": 428
},
"id": "432ddad2-2a0e-43b0-a5e6-7ff703e82586",
"name": "Sticky Note20",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-1920,
780
]
},
{
"parameters": {
"content": "## Busca Contatos",
"height": 497,
"width": 628
},
"id": "9a2c337f-7d11-4777-817e-e5aad336bebe",
"name": "Sticky Note21",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-1460,
780
]
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "9247aac7-4bf1-4be9-8317-b87671e795ba",
"leftValue": "={{ $('Info_Base').item.json.audience[1] }}",
"rightValue": "={{ $('Info_Base').item.json.audience[1] }}",
"operator": {
"type": "object",
"operation": "exists",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
-1880,
960
],
"id": "c6c7fe93-823d-4c71-8452-47598a9961b5",
"name": "If8"
},
{
"parameters": {
"amount": "={{ Math.floor(Math.random() * (20 - 10 + 1)) + 10 }}"
},
"id": "98a4aba9-c014-4066-9014-d678ef0ec50a",
"name": "Intervalo",
"type": "n8n-nodes-base.wait",
"typeVersion": 1.1,
"position": [
1420,
1040
],
"webhookId": "4036d994-e204-470a-82d9-1ac3c5244871"
}
],
"pinData": {},
"connections": {
"Horario": {
"main": [
[
{
"node": "Busca Disparador",
"type": "main",
"index": 0
},
{
"node": "UPDATE CAMPANHA",
"type": "main",
"index": 0
}
],
[
{
"node": "Loop Over Items1",
"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
}
]
]
},
"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": "If1",
"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": "Intervalo",
"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
}
]
]
},
"Envia msg": {
"main": [
[
{
"node": "Busca envios",
"type": "main",
"index": 0
}
],
[
{
"node": "Busca falhas",
"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
}
]
]
},
"Edit Fields1": {
"main": [
[
{
"node": "Envia msg3",
"type": "main",
"index": 0
}
]
]
},
"Envia msg3": {
"main": [
[
{
"node": "Busca envios",
"type": "main",
"index": 0
}
],
[
{
"node": "Busca falhas",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Items1": {
"main": [
[],
[
{
"node": "Altera fuso horário",
"type": "main",
"index": 0
}
]
]
},
"Switch": {
"main": [
[
{
"node": "Edit Fields2",
"type": "main",
"index": 0
}
],
[
{
"node": "Edit Fields",
"type": "main",
"index": 0
}
],
[
{
"node": "Edit Fields1",
"type": "main",
"index": 0
}
],
[
{
"node": "Edit Fields3",
"type": "main",
"index": 0
}
],
[
{
"node": "HTTP Request",
"type": "main",
"index": 0
}
],
[
{
"node": "Envia msg",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields3": {
"main": [
[
{
"node": "Envia msg4",
"type": "main",
"index": 0
}
]
]
},
"Envia msg4": {
"main": [
[
{
"node": "Busca envios",
"type": "main",
"index": 0
}
],
[
{
"node": "Busca falhas",
"type": "main",
"index": 0
}
]
]
},
"Buscar campanhas": {
"main": [
[
{
"node": "Loop Over Items1",
"type": "main",
"index": 0
}
]
]
},
"Busca Disparador": {
"main": [
[
{
"node": "Busca Caixa de Disparo",
"type": "main",
"index": 0
}
]
]
},
"Busca Caixa de Disparo": {
"main": [
[
{
"node": "Info_Base",
"type": "main",
"index": 0
}
]
]
},
"Info_Base": {
"main": [
[
{
"node": "IF6",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "Buscar campanhas",
"type": "main",
"index": 0
}
]
]
},
"If1": {
"main": [
[
{
"node": "HTTP Request2",
"type": "main",
"index": 0
}
],
[
{
"node": "If8",
"type": "main",
"index": 0
}
]
]
},
"HTTP Request2": {
"main": [
[
{
"node": "Code2",
"type": "main",
"index": 0
}
]
]
},
"Code2": {
"main": [
[
{
"node": "If7",
"type": "main",
"index": 0
}
]
]
},
"If7": {
"main": [
[
{
"node": "If8",
"type": "main",
"index": 0
}
],
[
{
"node": "HTTP Request3",
"type": "main",
"index": 0
}
]
]
},
"HTTP Request3": {
"main": [
[
{
"node": "If8",
"type": "main",
"index": 0
}
]
]
},
"HTTP Request": {
"main": [
[
{
"node": "Busca envios",
"type": "main",
"index": 0
}
],
[
{
"node": "Busca falhas",
"type": "main",
"index": 0
}
]
]
},
"Merge": {
"main": [
[
{
"node": "Contatos",
"type": "main",
"index": 0
}
]
]
},
"contatos": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 0
}
]
]
},
"conversas": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 1
}
]
]
},
"Labels": {
"main": [
[
{
"node": "contatos",
"type": "main",
"index": 0
},
{
"node": "conversas",
"type": "main",
"index": 0
}
]
]
},
"Multi-Labels": {
"main": [
[
{
"node": "contatos",
"type": "main",
"index": 0
},
{
"node": "conversas",
"type": "main",
"index": 0
}
]
]
},
"If8": {
"main": [
[
{
"node": "Multi-Labels",
"type": "main",
"index": 0
}
],
[
{
"node": "Labels",
"type": "main",
"index": 0
}
]
]
},
"Contatos": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
},
{
"node": "Envia Notificação",
"type": "main",
"index": 0
}
]
]
},
"Intervalo": {
"main": [
[
{
"node": "Switch",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "b7726838-0378-448c-8b34-9037be08b805",
"meta": {
"instanceId": "33738330930e3881dd5571eca013f36ddf8aab20e4ea5c1f2ebaf4a2b4668ac6"
},
"id": "1s5wjqPkztAEfZNJ",
"tags": []
}