{ "name": "Disparador 1.0.1", "nodes": [ { "parameters": { "rule": { "interval": [ { "field": "minutes", "minutesInterval": 1 } ] } }, "id": "6200dded-efbe-4735-a9a8-bf9846e7b17e", "name": "Schedule Trigger", "type": "n8n-nodes-base.scheduleTrigger", "typeVersion": 1, "position": [ -2180, 1040 ] }, { "parameters": { "conditions": { "dateTime": [ { "value1": "={{ $json.newDate }}", "operation": "before", "value2": "={{ $now }}" } ] } }, "id": "1ae6809d-0caa-457b-8bb6-42d462adcbe9", "name": "Horario", "type": "n8n-nodes-base.if", "typeVersion": 1, "position": [ -1460, 1040 ] }, { "parameters": { "content": "# Buscando Campanhas", "height": 456.3958547081602, "width": 1221.218469617133 }, "id": "4be04fbc-a001-4c70-b392-f5464e6b857a", "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.0.0", "height": 163.30528430133387, "width": 847.4993167412657, "color": 4 }, "id": "f08c4494-0cb6-40f9-ac6e-085a6c6b28f6", "name": "Sticky Note10", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ -2220, 540 ] }, { "parameters": { "operation": "subtractFromDate", "magnitude": "={{ $json.scheduled_at }}", "timeUnit": "hours", "duration": 3, "options": { "includeInputFields": true } }, "id": "ae7f2e2b-b1e4-45d3-8fb0-43579fe294b7", "name": "Altera fuso horário", "type": "n8n-nodes-base.dateTime", "typeVersion": 2, "position": [ -1640, 1040 ] }, { "parameters": { "keepOnlySet": true, "values": { "string": [ { "name": "chatwoot_url", "value": "https://suaurldochatwootaqui.com.br" }, { "name": "evolution_url", "value": "https://suaurldaevoaqui.com.br" }, { "name": "global_api_key", "value": "global api key da evolution" }, { "name": "instance_name", "value": "=Nome da caixa da Evo api" }, { "name": "chatwoot_token", "value": "=token da tenancia do chatwoot" } ], "number": [ { "name": "chatwoot_account_id", "value": "=id da tenancia" } ] }, "options": {} }, "id": "6ece6b5a-556d-4927-9bf6-1ecfc0aaa128", "name": "Info_Base", "type": "n8n-nodes-base.set", "typeVersion": 2, "position": [ -2000, 1040 ] }, { "parameters": { "content": "# Busca contatos / Envia campanha\n", "height": 580.894584655091, "width": 4534.358334878044, "color": 3 }, "id": "49aada24-1740-4101-b632-3722ea658927", "name": "Sticky Note", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ -166.29942964894326, 800 ] }, { "parameters": { "operation": "executeQuery", "query": "select * from campaigns c where campaign_type = 1 and status_envia = 0 LIMIT 1", "additionalFields": {} }, "id": "b8606e09-dd8a-43b6-9ba3-d71aa29f7f52", "name": "Buscar campanhas", "type": "n8n-nodes-base.postgres", "typeVersion": 1, "position": [ -1820, 1040 ] }, { "parameters": {}, "id": "916b3991-01c2-4db9-9cf0-6403fe978c8e", "name": "Merge6", "type": "n8n-nodes-base.merge", "typeVersion": 2.1, "position": [ 8180, 520 ] }, { "parameters": {}, "id": "532cf0ce-cc58-4758-86df-f475e331d23c", "name": "Repetir ação", "type": "n8n-nodes-base.noOp", "typeVersion": 1, "position": [ 4180, 1180 ] }, { "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": "1b9c8ef5-f86c-448f-9044-d440982092c2", "name": "Time Randon1", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 2040, 1080 ] }, { "parameters": { "amount": "={{ $json.waitTime }}" }, "id": "22f536aa-6927-4623-ae03-5d372e7b4825", "name": "Tempo de espera1", "type": "n8n-nodes-base.wait", "typeVersion": 1.1, "position": [ 2220, 1080 ], "webhookId": "6bc26e38-68a7-4962-8f74-5fdff94bfe5b" }, { "parameters": { "jsCode": "return items.map(item => {\n if (item.json.phone_number) {\n item.json.phone_number = item.json.phone_number.substring(1);\n }\n return item;\n});" }, "id": "cb126c5a-22dc-487b-b547-7c9ac4c7d066", "name": "Limpa numero1", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1680, 1080 ] }, { "parameters": { "operation": "executeQuery", "query": "SELECT c.*\nFROM contacts c\nJOIN taggings tg ON c.id = tg.taggable_id\nWHERE tg.tag_id = {{ $json.etiqueta }};", "options": {} }, "id": "f038636a-84a9-478f-8e22-409cbe7d5807", "name": "Busca contatos", "type": "n8n-nodes-base.postgres", "typeVersion": 2.4, "position": [ -120, 1040 ] }, { "parameters": { "conditions": { "string": [ { "value1": "={{ $('Buscar campanhas').item.json.campaign_type }}", "value2": "={{ 1 }}" } ] } }, "id": "5f8c9e2c-2e37-4cfb-92e1-20a0a55efbf4", "name": "IF6", "type": "n8n-nodes-base.if", "typeVersion": 1, "position": [ -840, 1000 ] }, { "parameters": { "fieldToSplitOut": "audience", "include": "allOtherFields", "options": {} }, "id": "d49e9ca5-2780-42b7-8f99-d8c72daadbff", "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": "90ab96a1-8593-4606-9784-a290d5892f3e", "name": "Sticky Note2", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ -940, 840 ] }, { "parameters": { "assignments": { "assignments": [ { "id": "de68590b-f364-42ca-96cb-f7a09d9c6395", "name": "numberdispara", "value": "={{ $json.phone_number }}", "type": "string" } ] }, "options": {} }, "id": "8b453827-03ff-472e-aaf3-868640d0f936", "name": "numero editado1", "type": "n8n-nodes-base.set", "typeVersion": 3.3, "position": [ 1860, 1080 ] }, { "parameters": { "options": {} }, "id": "206a9d0d-bd00-4a83-a64d-78a1e52fd80c", "name": "Loop Over Items", "type": "n8n-nodes-base.splitInBatches", "typeVersion": 3, "position": [ 60, 1040 ], "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": "935720e3-47b6-4d90-8b11-a3a4c41dc27a", "name": "If", "type": "n8n-nodes-base.if", "typeVersion": 2, "position": [ 1240, 1080 ] }, { "parameters": { "operation": "executeQuery", "query": "SELECT limite_disparo\nFROM accounts\nWHERE id ={{ $('Info_Base').item.json.chatwoot_account_id }};", "options": { "queryReplacement": "={{ $('Info_Base').item.json.chatwoot_account_id }}" } }, "id": "63aad44f-a567-4d10-863b-64329a76c5b4", "name": "Conta Disparo", "type": "n8n-nodes-base.postgres", "typeVersion": 2.4, "position": [ 1080, 1080 ] }, { "parameters": { "content": "## Limita disparo Diario", "height": 264.9413594226407, "width": 653.3075078799386, "color": 4 }, "id": "8974cf02-bc83-4e65-b92c-44039bc982dd", "name": "Sticky Note1", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 740, 1020 ] }, { "parameters": { "content": "## Dispara Mensagem", "height": 260.06359305339754, "width": 911.0441675732073, "color": 4 }, "id": "4511b20c-b9a9-43a3-8e4f-dae5a32b7fe9", "name": "Sticky Note3", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 1460, 1020 ] }, { "parameters": { "operation": "executeQuery", "query": "SELECT limite_disparo\nFROM accounts\nWHERE id ={{ $('Info_Base').item.json.chatwoot_account_id }};", "options": { "queryReplacement": "=" } }, "id": "61597641-77cc-46dd-b63a-c5425b701daf", "name": "Limitador", "type": "n8n-nodes-base.postgres", "typeVersion": 2.4, "position": [ 760, 1080 ] }, { "parameters": { "content": "## Contabiliza falhas", "height": 211.13093154244973, "width": 374.41687218580967, "color": 2 }, "id": "a598f9d9-7c75-461c-86e0-b94fd5083e8e", "name": "Sticky Note6", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 3020, 860 ] }, { "parameters": { "content": "## Contabiliza envios", "height": 215.09474919455494, "width": 382.34450749002, "color": 2 }, "id": "69e3aa34-cb8e-4005-890c-9c30dcb5d02c", "name": "Sticky Note7", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 3020, 1100 ] }, { "parameters": { "operation": "executeQuery", "query": "SELECT falhou\nFROM campaigns\nWHERE id = {{ $('IF6').item.json.id }};", "options": { "queryReplacement": "=" } }, "id": "7ddb1fe0-1cca-40f5-8c0f-25358d6c7934", "name": "Busca falhas", "type": "n8n-nodes-base.postgres", "typeVersion": 2.4, "position": [ 3060, 920 ] }, { "parameters": { "operation": "executeQuery", "query": "UPDATE accounts\nSET limite_disparo ={{ $json.limite_disparo -1 }}\nWHERE id ={{ $('Info_Base').item.json.chatwoot_account_id }};", "options": {} }, "id": "396e1190-ef6b-4295-ae34-695d77358173", "name": "Subtrair", "type": "n8n-nodes-base.postgres", "typeVersion": 2.4, "position": [ 920, 1080 ] }, { "parameters": { "operation": "executeQuery", "query": "UPDATE campaigns\nSET falhou = {{ $json.falhou +1 }}\nWHERE id = {{ $('IF6').item.json.id }};", "options": {} }, "id": "a8be1590-768a-415c-bb39-296a22076aaf", "name": "Adiciona falhas", "type": "n8n-nodes-base.postgres", "typeVersion": 2.4, "position": [ 3220, 920 ] }, { "parameters": { "operation": "executeQuery", "query": "SELECT enviou\nFROM campaigns\nWHERE id = {{ $('IF6').item.json.id }};", "options": {} }, "id": "25e075c0-b46e-4762-9dcb-af0fea44e389", "name": "Busca envios", "type": "n8n-nodes-base.postgres", "typeVersion": 2.4, "position": [ 3060, 1160 ] }, { "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": "anexo", "value": "={{ $('IF6').item.json.message.split('&anexo=')[1].split('&')[0] }}", "type": "string" }, { "id": "66e5ac5e-5cef-4737-81d8-9457f8fb8536", "name": "nomecontato", "value": "={{ $json.message.match(/&nome/)[0] }}", "type": "string" } ] }, "options": {} }, "id": "3164c4b6-18de-425e-acc9-827495522430", "name": "Campanha", "type": "n8n-nodes-base.set", "typeVersion": 3.3, "position": [ -420, 1000 ] }, { "parameters": { "content": "# Relatorio da campanha", "height": 272.1581724156961, "width": 500.60281237764696 }, "id": "0015f320-dc25-42f8-aca6-1db2386598a7", "name": "Sticky Note8", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 460, 460 ] }, { "parameters": { "operation": "executeQuery", "query": "SELECT falhou, enviou\nFROM campaigns\nWHERE id = {{ $('IF6').item.json.id }};", "options": { "queryReplacement": "=" } }, "id": "2ce2d02d-4b1c-448d-966c-664989b2770b", "name": "Resumo relatorio", "type": "n8n-nodes-base.postgres", "typeVersion": 2.4, "position": [ 600, 560 ] }, { "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": "={\"number\":\"{{ $('numero editado1').item.json.numberdispara }}@s.whatsapp.net\",\"options\":{\"delay\":3000,\"presence\":\"composing\"},\"mediaMessage\":{\"mediatype\":\"image\",\"caption\":\"{{ $json.mensagem }}\",\"media\":\"{{ $json[\"anexo\"] }}\"}}", "options": {} }, "id": "2d622329-4c3d-4256-bfec-1ca0ffd93d88", "name": "Envia msg2", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.1, "position": [ 2820, 1160 ], "retryOnFail": false, "maxTries": 2, "waitBetweenTries": 2000, "executeOnce": true, "onError": "continueErrorOutput" }, { "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\":\"{{ $('numero editado1').item.json.numberdispara }}@s.whatsapp.net\",\"options\":{\"delay\":3000,\"presence\":\"composing\"},\"textMessage\":{\"text\":\"{{ $('Edita Mensagem').item.json.var_msg }}\"}} ", "options": {} }, "id": "0d90b729-8882-44d1-9ed5-c6764fe47f47", "name": "Envia msg", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.1, "position": [ 2740, 880 ], "retryOnFail": false, "maxTries": 2, "waitBetweenTries": 2000, "executeOnce": true, "onError": "continueErrorOutput" }, { "parameters": { "content": "# Limite exedido", "height": 272.1581724156961, "width": 421.4323377312729 }, "id": "80d33d2f-fd6e-4ef1-a7af-3a07924735d6", "name": "Sticky Note9", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 1080, 460 ] }, { "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\":\"5511988884444@s.whatsapp.net\",\"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\\nObrigado por utilizar nossos serviços!\"}}", "options": {} }, "id": "5af8d13b-ec07-4678-a211-c56d4f0e3101", "name": "Envia relatorio", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.1, "position": [ 760, 560 ], "retryOnFail": false, "maxTries": 2, "waitBetweenTries": 2000, "executeOnce": true }, { "parameters": { "operation": "executeQuery", "query": "SELECT falhou, enviou\nFROM campaigns\nWHERE id = {{ $('IF6').item.json.id }};", "options": { "queryReplacement": "=" } }, "id": "8f36408b-d688-49e0-a8e1-ce72ad8f3625", "name": "Resumo relatorio1", "type": "n8n-nodes-base.postgres", "typeVersion": 2.4, "position": [ 1120, 560 ] }, { "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\":\"5511988884444@s.whatsapp.net\",\"options\":{\"delay\":3000,\"presence\":\"composing\"},\"textMessage\":{\"text\":\"⚠️ *Atenção!* Algumas mensagens da campanha podem não ter sido enviadas. ⚠️\\n\\n✔️ Total de envios: {{ $json[\"enviou\"] }}\\n❌ Número de falhas: {{ $json[\"falhou\"] }}\\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": "e6ebb80c-df69-4711-9b39-990c5bb547d2", "name": "Envia relatorio1", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.1, "position": [ 1280, 560 ], "retryOnFail": false, "maxTries": 2, "waitBetweenTries": 2000, "executeOnce": true }, { "parameters": { "operation": "executeQuery", "query": "=UPDATE campaigns SET status_envia = 1 WHERE id = {{ $json.id }}", "additionalFields": {} }, "id": "586aa133-ff10-4a08-8658-4caf40e6de71", "name": "Update Campanha", "type": "n8n-nodes-base.postgres", "typeVersion": 1, "position": [ -1160, 900 ], "alwaysOutputData": true }, { "parameters": { "assignments": { "assignments": [ { "id": "fbca67eb-842d-47de-a989-c1879a8141bc", "name": "phone_number", "value": "={{ $('Loop Over Items').item.json.phone_number }}", "type": "string" } ] }, "options": {} }, "id": "c8072727-522c-475a-8950-7bb13d7373e5", "name": "contato1", "type": "n8n-nodes-base.set", "typeVersion": 3.3, "position": [ 1520, 1080 ] }, { "parameters": { "operation": "executeQuery", "query": "UPDATE campaigns\nSET enviou = {{ $json.enviou +1 }}\nWHERE id = {{ $('IF6').item.json.id }};", "options": {} }, "id": "c74887ec-9e10-40a7-9787-6f29aed9e7b8", "name": "Adiciona envios", "type": "n8n-nodes-base.postgres", "typeVersion": 2.4, "position": [ 3220, 1160 ] }, { "parameters": { "content": "## Sem Anexo", "height": 199.63817652105178, "width": 313.99126283929667 }, "id": "ea0f760a-425a-41ae-a852-46ecdd63e332", "name": "Sticky Note4", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 2640, 820 ] }, { "parameters": { "content": "## Com Anexo", "height": 216.81471968017428, "width": 313.99126283929667 }, "id": "bb1da829-8a2e-477d-a1e4-cb5f7a641528", "name": "Sticky Note11", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 2640, 1100 ] }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict" }, "conditions": [ { "id": "daf39b75-a974-426f-a6f7-197497d2fa94", "leftValue": "={{ $('Campanha').item.json.anexo }}", "rightValue": "", "operator": { "type": "string", "operation": "empty", "singleValue": true } } ], "combinator": "and" }, "options": {} }, "id": "396ed791-bce3-44a5-bb27-df0b2085161a", "name": "If1", "type": "n8n-nodes-base.if", "typeVersion": 2, "position": [ 2440, 1080 ] }, { "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 } } ], "combinator": "and" }, "options": {} }, "id": "7620299b-abd7-4ec0-8d04-ae34719bbe2d", "name": "If2", "type": "n8n-nodes-base.if", "typeVersion": 2, "position": [ 260, 1060 ] }, { "parameters": { "assignments": { "assignments": [ { "id": "a588a036-88bc-4bc2-aefa-a2c0b9af2000", "name": "var_msg", "value": "={{ $('IF6').item.json.message.split('&nome').join($json.name) }}", "type": "string" } ] }, "options": {} }, "id": "e8441037-7278-448b-ad5e-031afab0a80c", "name": "Edita Mensagem", "type": "n8n-nodes-base.set", "typeVersion": 3.3, "position": [ 520, 1060 ] }, { "parameters": { "fields": { "values": [ { "name": "mensagem", "stringValue": "={{ $('Edita Mensagem').item.json.var_msg.split(\"&anexo=\")[0].replace(/\\n/g, \"\\\\n\") }}" }, { "name": "titulo", "stringValue": "={{ $('Campanha').item.json.msg.title }}" }, { "name": "anexo", "stringValue": "={{ $('Campanha').item.json.anexo }}" } ] }, "options": { "includeBinary": true } }, "id": "912a1ef5-8816-47f7-ade3-ba6fa3c477f7", "name": "Edit Fields2", "type": "n8n-nodes-base.set", "typeVersion": 3.2, "position": [ 2680, 1160 ] }, { "parameters": { "url": "={{ $('Info_Base').item.json.chatwoot_url }}/api/v1/accounts/{{ $('Info_Base').item.json.chatwoot_account_id }}/contacts/{{ $json.payload[0].id }}/conversations", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "api_access_token", "value": "={{ $('Info_Base').item.json.chatwoot_token }}" } ] }, "options": {} }, "id": "2a55749c-7ff1-4743-95e4-bdea0edaabe3", "name": "Abre conversa de contato existente", "type": "n8n-nodes-base.httpRequest", "typeVersion": 3, "position": [ 3680, 1040 ] }, { "parameters": { "url": "={{ $('Info_Base').item.json.chatwoot_url }}/api/v1/accounts/{{ $('Info_Base').item.json.chatwoot_account_id }}/contacts/search", "sendQuery": true, "queryParameters": { "parameters": [ { "name": "q", "value": "={{ $('contato1').item.json.phone_number }}" } ] }, "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "api_access_token", "value": "={{ $('Info_Base').item.json.chatwoot_token }}" } ] }, "options": {} }, "id": "bd0f4c9f-f04f-4fdf-806d-128f7cb95e6b", "name": "Busca Contato Existe", "type": "n8n-nodes-base.httpRequest", "typeVersion": 3, "position": [ 3520, 1040 ] }, { "parameters": { "method": "POST", "url": "={{ $('Info_Base').item.json.chatwoot_url }}/api/v1/accounts/{{ $('Info_Base').item.json.chatwoot_account_id }}/conversations/{{ $('Abre conversa de contato existente').item.json.payload[0].id }}/toggle_status", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "api_access_token", "value": "={{ $('Info_Base').item.json.chatwoot_token }}" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "={\n\"status\": \"resolved\"\n}", "options": {} }, "id": "53f7edfd-9a71-4938-8da8-e78c347dd61d", "name": "Resolve Conversa", "type": "n8n-nodes-base.httpRequest", "typeVersion": 3, "position": [ 4000, 1040 ] }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict" }, "conditions": [ { "id": "f36a7740-f515-41a5-8a06-0d8438005e11", "leftValue": "={{ $json.payload[0].status }}", "rightValue": "open", "operator": { "type": "string", "operation": "equals", "name": "filter.operator.equals" } }, { "id": "a9ee241b-e05e-4ffe-ba4f-98076524b5a4", "leftValue": "={{ $json.payload[0].status }}", "rightValue": "pending", "operator": { "type": "string", "operation": "equals", "name": "filter.operator.equals" } } ], "combinator": "or" }, "options": {} }, "id": "273480c3-7cc1-4c2b-a60d-4a1e9146778d", "name": "If3", "type": "n8n-nodes-base.if", "typeVersion": 2, "position": [ 3840, 1040 ] }, { "parameters": { "content": "## Resolve Conversa\n** Se a conversa estiver aberta mantém / Se não houver conversa aberta ele fecha", "height": 331.5360284004761, "width": 639.1511430088007 }, "id": "8410d7fa-4d01-4b6d-85d6-4816ba16a48d", "name": "Sticky Note12", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [ 3480, 940 ] } ], "pinData": {}, "connections": { "Schedule Trigger": { "main": [ [ { "node": "Info_Base", "type": "main", "index": 0 } ] ] }, "Horario": { "main": [ [ { "node": "Update Campanha", "type": "main", "index": 0 }, { "node": "IF6", "type": "main", "index": 0 } ] ] }, "Altera fuso horário": { "main": [ [ { "node": "Horario", "type": "main", "index": 0 } ] ] }, "Info_Base": { "main": [ [ { "node": "Buscar campanhas", "type": "main", "index": 0 } ] ] }, "Buscar campanhas": { "main": [ [ { "node": "Altera fuso horário", "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 } ] ] }, "Limpa numero1": { "main": [ [ { "node": "numero editado1", "type": "main", "index": 0 } ] ] }, "Busca contatos": { "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 } ] ] }, "numero editado1": { "main": [ [ { "node": "Time Randon1", "type": "main", "index": 0 } ] ] }, "Loop Over Items": { "main": [ [ { "node": "Resumo relatorio", "type": "main", "index": 0 } ], [ { "node": "If2", "type": "main", "index": 0 } ] ] }, "If": { "main": [ [ { "node": "contato1", "type": "main", "index": 0 } ], [ { "node": "Resumo relatorio1", "type": "main", "index": 0 } ] ] }, "Conta Disparo": { "main": [ [ { "node": "If", "type": "main", "index": 0 } ] ] }, "Limitador": { "main": [ [ { "node": "Subtrair", "type": "main", "index": 0 } ] ] }, "Busca falhas": { "main": [ [ { "node": "Adiciona falhas", "type": "main", "index": 0 } ] ] }, "Subtrair": { "main": [ [ { "node": "Conta Disparo", "type": "main", "index": 0 } ] ] }, "Adiciona falhas": { "main": [ [ { "node": "Busca Contato Existe", "type": "main", "index": 0 } ] ] }, "Busca envios": { "main": [ [ { "node": "Adiciona envios", "type": "main", "index": 0 } ] ] }, "Campanha": { "main": [ [ { "node": "Busca contatos", "type": "main", "index": 0 } ] ] }, "Resumo relatorio": { "main": [ [ { "node": "Envia relatorio", "type": "main", "index": 0 } ] ] }, "Envia msg2": { "main": [ [ { "node": "Busca envios", "type": "main", "index": 0 } ], [ { "node": "Busca falhas", "type": "main", "index": 0 } ] ] }, "Envia msg": { "main": [ [ { "node": "Busca envios", "type": "main", "index": 0 } ], [ { "node": "Busca falhas", "type": "main", "index": 0 } ] ] }, "Resumo relatorio1": { "main": [ [ { "node": "Envia relatorio1", "type": "main", "index": 0 } ] ] }, "contato1": { "main": [ [ { "node": "Limpa numero1", "type": "main", "index": 0 } ] ] }, "Adiciona envios": { "main": [ [ { "node": "Busca Contato Existe", "type": "main", "index": 0 } ] ] }, "If1": { "main": [ [ { "node": "Envia msg", "type": "main", "index": 0 } ], [ { "node": "Edit Fields2", "type": "main", "index": 0 } ] ] }, "If2": { "main": [ [ { "node": "Edita Mensagem", "type": "main", "index": 0 } ], [ { "node": "Edita Mensagem", "type": "main", "index": 0 } ] ] }, "Edita Mensagem": { "main": [ [ { "node": "Limitador", "type": "main", "index": 0 } ] ] }, "Edit Fields2": { "main": [ [ { "node": "Envia msg2", "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 } ] ] }, "If3": { "main": [ [ { "node": "Repetir ação", "type": "main", "index": 0 } ], [ { "node": "Resolve Conversa", "type": "main", "index": 0 } ] ] } }, "active": false, "settings": { "executionOrder": "v1" }, "versionId": "4098f114-0f4b-4a55-8290-b716149185bd", "meta": { "templateCredsSetupCompleted": true, "instanceId": "33738330930e3881dd5571eca013f36ddf8aab20e4ea5c1f2ebaf4a2b4668ac6" }, "id": "LLTG80erAd39vd1f", "tags": [ { "createdAt": "2024-06-24T17:54:45.734Z", "updatedAt": "2024-06-24T17:54:45.734Z", "id": "W4QFAwjDhUwUJMhH", "name": "Dev" } ] }