├── contatos-woot.xls ├── README.md ├── Cadastrar_contatos_typebot.json └── Cadastrar_contatos_n8n.json /contatos-woot.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rodtanci/Chatwoot-cadastrar-contatos/HEAD/contatos-woot.xls -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Automação Inteligente de Cadastro de Contatos com Etiquetas no Chatwoot 🤖✨ 2 | 3 | ### Descrição 4 | Este projeto foi criado para facilitar a gestão de contatos no Chatwoot, permitindo o cadastro automático de uma lista de contatos a partir de uma tabela Excel em formato XLS. Com essa automação, você pode adicionar etiquetas personalizadas ou selecionar etiquetas que já existam no sistema, proporcionando uma organização eficiente e prática. Tudo isso, sem complicações e com total flexibilidade, tornando o processo de gerenciamento de contatos muito mais ágil e automatizado. 5 | 6 | ## 🚀 Funcionalidades 7 | - **Cadastro Automático**: Importa contatos diretamente de uma planilha Excel (XLS) para o Chatwoot. 8 | - **Etiquetas Dinâmicas**: Crie novas etiquetas na hora ou selecione uma existente para organizar seus contatos. 9 | - **Praticidade e Agilidade**: Reduz o tempo de cadastramento manual e garante uma organização estruturada. 10 | 11 | ## 📲 Links úteis 12 | - [**Junte-se ao grupo no WhatsApp**](https://chat.whatsapp.com/H2as2v9yHre8U2gjNaCWRc) para tirar dúvidas e obter suporte. 13 | - [**Assista nossos tutoriais e novidades no YouTube**](https://www.youtube.com/@RodrigoTanci/) para ficar por dentro das atualizações. 14 | - **Apoie o projeto via Pix**: Chave Pix: `a0db6d5c-625b-4846-ba9a-3e06ccc6b1d4` 15 | 16 | --- 17 | 18 | Facilite seu atendimento e melhore a eficiência do seu Chatwoot com essa automação inteligente! 19 | -------------------------------------------------------------------------------- /Cadastrar_contatos_typebot.json: -------------------------------------------------------------------------------- 1 | {"version":"6","id":"cm0px9use000otluj1owjrhl3","name":"Cadastro de contatos","events":[{"id":"yds29t0jjzesn3gh13hkxohj","outgoingEdgeId":"s0n68pkipgje5i92rebawrc9","graphCoordinates":{"x":-80,"y":-10},"type":"start"}],"groups":[{"id":"ly1q759pe1ssf688zwxk1nkf","title":"Cadastrar contatos","graphCoordinates":{"x":1591,"y":481.66},"blocks":[{"id":"zbnwepnqnxypi77i2lnw02js","type":"text","content":{"richText":[{"type":"p","children":[{"text":"Agora vamos importar a lista de contatos em XLS."}]}]}},{"id":"ufomdp44ecn8yu4qy97itkvh","type":"text","content":{"richText":[{"type":"p","children":[{"text":"É importante utilizar o modelo de templete disponibilizado pelo nossso time!"}]}]}},{"id":"me9620rxni55ipvn3k65etse","type":"file input","options":{"variableId":"vgcibi3l4sdjycgeizywtxcer"}},{"id":"h4juxeiwag8q3vmocdtlxc2l","type":"Webhook","options":{"responseVariableMapping":[{"id":"s6gooddx0p941c63qx3y8pan","variableId":"vzbfxxw3evfozpgna1hcws1wj","bodyPath":"data[0].error.status"}],"isAdvancedConfig":true,"isCustomBody":true,"webhook":{"url":"https://n8n.setabot.com.br/webhook-test/f0c2e2b1-92f4-47b6-8957-50d136e4ded8","body":"{\n \"arquivo\":\"{{var_arquivo}}\",\n \"etiqueta\":\"{{var_etiqueta_selecionada}}\"\n}"}}},{"id":"nzf3w0q221xyovacrebvdkf3","type":"text","content":{"richText":[{"type":"p","children":[{"text":"Todos os contatos foram cadastrados."}]}]}}]},{"id":"lvey1ifd6gl3b1zkhmmgavmo","title":"Inicio","graphCoordinates":{"x":227,"y":-8},"blocks":[{"id":"e6h666kmayhh6yia1qfyp3pe","outgoingEdgeId":"axj5rtrc2kxq9poqfz20el8w","type":"text","content":{"richText":[{"type":"p","children":[{"text":"Para o cadastro de contatos siga os passos abaixo:"}]}]}},{"id":"kdkbzd703c0bv45oiouyfop2","type":"text","content":{"richText":[{"type":"p","children":[{"text":"Escolha uma das opções abaixo"}]}]}},{"id":"cjludqkqyu8pkczwill9yxss","type":"choice input","items":[{"id":"edln4zjm1b3w744nm1wgog6n","outgoingEdgeId":"tz2o3etocnx0iiz3m8zlgtoj","content":"Cadastrar Etiqueta"},{"id":"mj2osmkiig9s61af752tpikc","outgoingEdgeId":"lekfgde9tbkaxx0r551hbb4s","content":"Usar Etiqueta Cadastrada"}]}]},{"id":"r6shkrgdtevieifql1w6se67","title":"Cadastrar etiqueta","graphCoordinates":{"x":595.66,"y":1.35},"blocks":[{"id":"l38m3n9s1hfa2yt4lcio4l33","type":"text","content":{"richText":[{"type":"p","children":[{"text":"Agora insira o nome da etiqueta que você deseja colocar para esta lista de contatos."}]}]}},{"id":"amfieios7jog823wljlrdidv","type":"text input","options":{"labels":{"placeholder":"Digite aqui","button":"Enviar"},"variableId":"veaoex5lk9pyr79c2u6o3q2hr"}},{"id":"n95x36x9zdv3mvtjkn7evaxx","type":"Webhook","options":{"responseVariableMapping":[{"id":"sl6agrc77z1kg4asogbz2xc9","variableId":"vx1on0gkipx0cs9z9hrxilxph","bodyPath":"data[0].error.status"}],"isAdvancedConfig":true,"isCustomBody":true,"webhook":{"url":"https://n8n.setabot.com.br/webhook-test/c25a5895-9e8a-42fd-8bc5-6c4c3f59830e","body":"{\n \"etiqueta\":\"{{var_cria_etiqueta}}\"\n}"}}},{"id":"ke51324ycathr33qcg3cnsr1","outgoingEdgeId":"ksox3rcvo65bytjdfiqikl65","type":"Condition","items":[{"id":"wp0f9sq1j68z7b56pvkodvpk","outgoingEdgeId":"v1zueyo4jhgks6psphotrr3g","content":{"comparisons":[{"id":"lqtwmphyt14pdnt2abtwnnni","variableId":"vx1on0gkipx0cs9z9hrxilxph","comparisonOperator":"Equal to","value":"422"}]}}]}]},{"id":"ew7daqufbg73aqzv6dez8otr","title":"Erro ao criar etiqueta","graphCoordinates":{"x":980.65,"y":-0.37},"blocks":[{"id":"mruza2uhwnavhrmv51lvgxwg","outgoingEdgeId":"h2fiqndos2ujvnjh5pannaur","type":"text","content":{"richText":[{"type":"p","children":[{"text":"a etiqueta {{var_cria_etiqueta}}, já existe por favor insira outro nome. "}]}]}}]},{"id":"hu3t8kfhezwbnhat425rfitj","title":"Etiqueta criada","graphCoordinates":{"x":980.64,"y":259.64},"blocks":[{"id":"y80n85hrhdu6y1l1xinjo7i6","type":"text","content":{"richText":[{"type":"p","children":[{"text":"A {{var_cria_etiqueta}} foi criada com sucesso!"}]}]}},{"id":"yyzlevlnytdhxniix4ywfrsu","outgoingEdgeId":"eus7u9rdl3i5fyvc9s9qw2jv","type":"Set variable","options":{"variableId":"vlb1cjvnn3yaq0e8688all80n","expressionToEvaluate":"{{var_cria_etiqueta}}","isCode":true}}]},{"id":"nl0oe912467o3urzsj2bkw3z","title":"Busca etiquetas","graphCoordinates":{"x":595.66,"y":616.33},"blocks":[{"id":"ua7z4df9ftecppf5250gk3so","type":"text","content":{"richText":[{"type":"p","children":[{"text":"Aguarde enquanto buscamos as etiquetas cadastradas em seu sistema."}]}]}},{"id":"dwvehkmgyzdvhf07rippqjtf","type":"Webhook","options":{"responseVariableMapping":[{"id":"vnaajgz0x6mt4i1szb7irv9o","variableId":"vhtvs3ww2pwpg43mgvepyu8w9","bodyPath":"data[0].etiquetas"}],"isAdvancedConfig":true,"webhook":{"url":"https://n8n.setabot.com.br/webhook-test/4ddb03a5-f78f-4f77-a2bd-d2d210eabe02"}}},{"id":"oeiot9cxxyqrw2c1mkmwp9ae","outgoingEdgeId":"v5m63hc2xf0d57qiujrfj4al","type":"Condition","items":[{"id":"m6hsq328rxmb5yipret6ecnz","outgoingEdgeId":"e2t2kqkfmtobydtuvkxhbamt","content":{"comparisons":[{"id":"ajd5w42fcl3g7ynbmakk8u6v","variableId":"vhtvs3ww2pwpg43mgvepyu8w9","comparisonOperator":"Equal to","value":"null"}]}}]}]},{"id":"cyto07tw8jufxbzb7mjgga2r","title":"Etiqueta nao encontrada","graphCoordinates":{"x":1000.67,"y":612.97},"blocks":[{"id":"tdeja7cxqr2gtxd9r046dnsy","type":"text","content":{"richText":[{"type":"p","children":[{"text":"Infelizmente você não possui etiquetas cadastradas no sistema."}]}]}},{"id":"zkm4slphgptntbqqbz5evjsa","outgoingEdgeId":"fe5qyk0cq92z4jrwld4zrrd7","type":"text","content":{"richText":[{"type":"p","children":[{"text":"Mas não se preocupe vamos cadastrar agora"}]}]}}]},{"id":"fgaxdi4mz7oktj2hxe0hajx2","title":"Selecionar etiqueta","graphCoordinates":{"x":1000.68,"y":942.98},"blocks":[{"id":"jgbf0j8idabklijogzy6218q","type":"text","content":{"richText":[{"type":"p","children":[{"text":"Selecione uma das etiquetas abaixo:"}]}]}},{"id":"t8qmiadun2cwb5wtd7gepywe","type":"choice input","items":[{"id":"pvyswlo4f5auz82xtmf3gwss","content":"Clique para editar"}],"options":{"variableId":"vlb1cjvnn3yaq0e8688all80n","dynamicVariableId":"vhtvs3ww2pwpg43mgvepyu8w9"}},{"id":"it5zt1qr3k9mksnijuban07k","outgoingEdgeId":"egr8edgc0hm337tqtorke3vq","type":"text","content":{"richText":[{"type":"p","children":[{"text":"Maravilha, vamos cadastrar os contatos com a etiqueta {{var_etiqueta_selecionada}}"}]}]}}]}],"edges":[{"id":"s0n68pkipgje5i92rebawrc9","from":{"eventId":"yds29t0jjzesn3gh13hkxohj"},"to":{"groupId":"lvey1ifd6gl3b1zkhmmgavmo"}},{"id":"te9iobs57fkai4bybypsf0ty","from":{"blockId":"yj6a336o8dhrw34ldu1waqy6"},"to":{"groupId":"lvey1ifd6gl3b1zkhmmgavmo","blockId":"kdkbzd703c0bv45oiouyfop2"}},{"id":"tz2o3etocnx0iiz3m8zlgtoj","from":{"blockId":"cjludqkqyu8pkczwill9yxss","itemId":"edln4zjm1b3w744nm1wgog6n"},"to":{"groupId":"r6shkrgdtevieifql1w6se67"}},{"id":"v1zueyo4jhgks6psphotrr3g","from":{"blockId":"ke51324ycathr33qcg3cnsr1","itemId":"wp0f9sq1j68z7b56pvkodvpk"},"to":{"groupId":"ew7daqufbg73aqzv6dez8otr"}},{"id":"h2fiqndos2ujvnjh5pannaur","from":{"blockId":"mruza2uhwnavhrmv51lvgxwg"},"to":{"groupId":"r6shkrgdtevieifql1w6se67"}},{"id":"ksox3rcvo65bytjdfiqikl65","from":{"blockId":"ke51324ycathr33qcg3cnsr1"},"to":{"groupId":"hu3t8kfhezwbnhat425rfitj"}},{"id":"e2t2kqkfmtobydtuvkxhbamt","from":{"blockId":"oeiot9cxxyqrw2c1mkmwp9ae","itemId":"m6hsq328rxmb5yipret6ecnz"},"to":{"groupId":"cyto07tw8jufxbzb7mjgga2r"}},{"id":"fe5qyk0cq92z4jrwld4zrrd7","from":{"blockId":"zkm4slphgptntbqqbz5evjsa"},"to":{"groupId":"r6shkrgdtevieifql1w6se67"}},{"id":"v5m63hc2xf0d57qiujrfj4al","from":{"blockId":"oeiot9cxxyqrw2c1mkmwp9ae"},"to":{"groupId":"fgaxdi4mz7oktj2hxe0hajx2"}},{"id":"egr8edgc0hm337tqtorke3vq","from":{"blockId":"it5zt1qr3k9mksnijuban07k"},"to":{"groupId":"ly1q759pe1ssf688zwxk1nkf"}},{"id":"lekfgde9tbkaxx0r551hbb4s","from":{"blockId":"cjludqkqyu8pkczwill9yxss","itemId":"mj2osmkiig9s61af752tpikc"},"to":{"groupId":"nl0oe912467o3urzsj2bkw3z"}},{"id":"eus7u9rdl3i5fyvc9s9qw2jv","from":{"blockId":"yyzlevlnytdhxniix4ywfrsu"},"to":{"groupId":"ly1q759pe1ssf688zwxk1nkf"}}],"variables":[{"id":"vzbfxxw3evfozpgna1hcws1wj","name":"var_error_cadastro","isSessionVariable":true},{"id":"vlb1cjvnn3yaq0e8688all80n","name":"var_etiqueta_selecionada","isSessionVariable":true},{"id":"vhtvs3ww2pwpg43mgvepyu8w9","name":"var_etiquetas","isSessionVariable":true},{"id":"vgcibi3l4sdjycgeizywtxcer","name":"var_arquivo","isSessionVariable":true},{"id":"vx1on0gkipx0cs9z9hrxilxph","name":"var_status_etiqueta","isSessionVariable":true},{"id":"vu5l6h1tg82plq9z3yvjafohu","name":"var_status","isSessionVariable":true},{"id":"veaoex5lk9pyr79c2u6o3q2hr","name":"var_cria_etiqueta","isSessionVariable":true},{"id":"vwiws7sxw8yfidt23t9v6clle","name":"arquivo","isSessionVariable":true}],"theme":{},"selectedThemeTemplateId":null,"settings":{},"createdAt":"2024-09-05T23:32:31.646Z","updatedAt":"2024-09-06T14:12:58.730Z","icon":null,"folderId":null,"publicId":"meu-typebot-owjrhl3","customDomain":null,"workspaceId":"clx1epb3m000560qc8t2tiihv","resultsTablePreferences":null,"isArchived":false,"isClosed":false,"whatsAppCredentialsId":null,"riskLevel":null} -------------------------------------------------------------------------------- /Cadastrar_contatos_n8n.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Cadastrar contatos", 3 | "nodes": [ 4 | { 5 | "parameters": {}, 6 | "id": "d4af08f8-9a49-453a-8d5b-8d2bd337957a", 7 | "name": "Replace Me", 8 | "type": "n8n-nodes-base.noOp", 9 | "typeVersion": 1, 10 | "position": [ 11 | 2480, 12 | 700 13 | ] 14 | }, 15 | { 16 | "parameters": { 17 | "operation": "xls", 18 | "options": {} 19 | }, 20 | "id": "ae39dc1b-a911-410b-b0d9-cc722b39571e", 21 | "name": "Extract from File", 22 | "type": "n8n-nodes-base.extractFromFile", 23 | "typeVersion": 1, 24 | "position": [ 25 | 1420, 26 | 660 27 | ] 28 | }, 29 | { 30 | "parameters": { 31 | "jsCode": "// Cria uma variável 'caixa' que será uma lista de nomes\nlet etiquetas = [];\n\n// Itera sobre os registros encontrados\nfor (let item of items) {\n // Adiciona cada nome encontrado à variável 'caixa'\n etiquetas.push(item.json.title);\n}\n\n// Retorna a variável 'caixa' como um item\nreturn [{ json: { etiquetas } }];\n" 32 | }, 33 | "id": "b4d3a1a7-e67b-46d4-9855-33c76cd7ddd7", 34 | "name": "Code", 35 | "type": "n8n-nodes-base.code", 36 | "typeVersion": 2, 37 | "position": [ 38 | 1400, 39 | 100 40 | ] 41 | }, 42 | { 43 | "parameters": { 44 | "respondWith": "allIncomingItems", 45 | "options": { 46 | "responseCode": 200 47 | } 48 | }, 49 | "id": "b9e232d0-4605-47cf-8481-912393b8c999", 50 | "name": "Respond to Webhook1", 51 | "type": "n8n-nodes-base.respondToWebhook", 52 | "typeVersion": 1.1, 53 | "position": [ 54 | 1400, 55 | -180 56 | ] 57 | }, 58 | { 59 | "parameters": { 60 | "respondWith": "allIncomingItems", 61 | "options": { 62 | "responseCode": 200 63 | } 64 | }, 65 | "id": "bbb173de-3da1-4959-a596-8a1fdf641d8d", 66 | "name": "Respond to Webhook", 67 | "type": "n8n-nodes-base.respondToWebhook", 68 | "typeVersion": 1.1, 69 | "position": [ 70 | 1580, 71 | 100 72 | ] 73 | }, 74 | { 75 | "parameters": { 76 | "assignments": { 77 | "assignments": [ 78 | { 79 | "id": "c149a790-2940-4774-a8c0-270db8834fb5", 80 | "name": "chatwoot_url", 81 | "value": "url chatwoot", 82 | "type": "string" 83 | }, 84 | { 85 | "id": "7c534eba-8917-4bc8-ba2a-79012d0eb379", 86 | "name": "chatwoot_id", 87 | "value": "id chatwoot", 88 | "type": "string" 89 | }, 90 | { 91 | "id": "f4d35ed8-2c7f-487c-bf26-0100243133a3", 92 | "name": "chatwoot_token", 93 | "value": "token chatwoot", 94 | "type": "string" 95 | } 96 | ] 97 | }, 98 | "options": {} 99 | }, 100 | "id": "997db39a-7f37-481d-8e11-33bfd858e8c6", 101 | "name": "Dados", 102 | "type": "n8n-nodes-base.set", 103 | "typeVersion": 3.3, 104 | "position": [ 105 | 1040, 106 | -180 107 | ] 108 | }, 109 | { 110 | "parameters": { 111 | "httpMethod": "POST", 112 | "path": "15b0c066-0f48-4268-9a2e-8966d76e2d6c", 113 | "responseMode": "responseNode", 114 | "options": {} 115 | }, 116 | "id": "9ccfa0a6-1928-4cae-adde-e8741e2d2ff9", 117 | "name": "Cadastra contatos", 118 | "type": "n8n-nodes-base.webhook", 119 | "typeVersion": 2, 120 | "position": [ 121 | 860, 122 | 660 123 | ], 124 | "webhookId": "15b0c066-0f48-4268-9a2e-8966d76e2d6c" 125 | }, 126 | { 127 | "parameters": { 128 | "httpMethod": "POST", 129 | "path": "d4b264b6-9a4b-4332-bea0-c5222b54a46d", 130 | "responseMode": "responseNode", 131 | "options": {} 132 | }, 133 | "id": "330be66d-fc30-4ed1-bcea-703ddcfacd4a", 134 | "name": "Busca etiquetas", 135 | "type": "n8n-nodes-base.webhook", 136 | "typeVersion": 2, 137 | "position": [ 138 | 860, 139 | 100 140 | ], 141 | "webhookId": "d4b264b6-9a4b-4332-bea0-c5222b54a46d" 142 | }, 143 | { 144 | "parameters": { 145 | "httpMethod": "POST", 146 | "path": "990c4323-6eb4-4556-a4ca-d7330ab94e47", 147 | "responseMode": "responseNode", 148 | "options": {} 149 | }, 150 | "id": "3d3b10fa-528c-4f03-97ff-7cec31fa8680", 151 | "name": "Cadastra etiqueta2", 152 | "type": "n8n-nodes-base.webhook", 153 | "typeVersion": 2, 154 | "position": [ 155 | 860, 156 | -180 157 | ], 158 | "webhookId": "990c4323-6eb4-4556-a4ca-d7330ab94e47" 159 | }, 160 | { 161 | "parameters": { 162 | "method": "POST", 163 | "url": "={{ $json.chatwoot_url }}/api/v1/accounts/{{ $json.chatwoot_id }}/labels ", 164 | "sendHeaders": true, 165 | "headerParameters": { 166 | "parameters": [ 167 | { 168 | "name": "api_access_token", 169 | "value": "={{ $json.chatwoot_token }}" 170 | }, 171 | { 172 | "name": "Content-Type", 173 | "value": "application/json" 174 | } 175 | ] 176 | }, 177 | "sendBody": true, 178 | "specifyBody": "json", 179 | "jsonBody": "={\n \"title\": \"{{ $('Cadastra etiqueta2').item.json.body.etiqueta }}\",\n \"color\": \"#ff5733\",\n \"show_on_sidebar\": true\n }", 180 | "options": {} 181 | }, 182 | "id": "f3fb8f6f-5b8b-44a9-9d07-bf2bd1dc18de", 183 | "name": "Cadastra etiqueta", 184 | "type": "n8n-nodes-base.httpRequest", 185 | "typeVersion": 3, 186 | "position": [ 187 | 1220, 188 | -180 189 | ], 190 | "onError": "continueRegularOutput" 191 | }, 192 | { 193 | "parameters": { 194 | "respondWith": "allIncomingItems", 195 | "options": { 196 | "responseCode": 200 197 | } 198 | }, 199 | "id": "37a9874f-9b6c-4f6f-b321-f81b4563f434", 200 | "name": "Respond to Webhook2", 201 | "type": "n8n-nodes-base.respondToWebhook", 202 | "typeVersion": 1.1, 203 | "position": [ 204 | 1860, 205 | 380 206 | ] 207 | }, 208 | { 209 | "parameters": { 210 | "assignments": { 211 | "assignments": [ 212 | { 213 | "id": "c149a790-2940-4774-a8c0-270db8834fb5", 214 | "name": "chatwoot_url", 215 | "value": "url chatwoot", 216 | "type": "string" 217 | }, 218 | { 219 | "id": "7c534eba-8917-4bc8-ba2a-79012d0eb379", 220 | "name": "chatwoot_id", 221 | "value": "id chatwoot", 222 | "type": "string" 223 | }, 224 | { 225 | "id": "f4d35ed8-2c7f-487c-bf26-0100243133a3", 226 | "name": "chatwoot_token", 227 | "value": "token chatwoot", 228 | "type": "string" 229 | } 230 | ] 231 | }, 232 | "options": {} 233 | }, 234 | "id": "f5a26d93-a280-4ac4-a2de-1a4b75aebeaa", 235 | "name": "Dados1", 236 | "type": "n8n-nodes-base.set", 237 | "typeVersion": 3.3, 238 | "position": [ 239 | 1040, 240 | 100 241 | ] 242 | }, 243 | { 244 | "parameters": { 245 | "assignments": { 246 | "assignments": [ 247 | { 248 | "id": "c149a790-2940-4774-a8c0-270db8834fb5", 249 | "name": "chatwoot_url", 250 | "value": "url chatwoot", 251 | "type": "string" 252 | }, 253 | { 254 | "id": "7c534eba-8917-4bc8-ba2a-79012d0eb379", 255 | "name": "chatwoot_id", 256 | "value": "id chatwoot", 257 | "type": "string" 258 | }, 259 | { 260 | "id": "f4d35ed8-2c7f-487c-bf26-0100243133a3", 261 | "name": "chatwoot_token", 262 | "value": "token chatwoot", 263 | "type": "string" 264 | } 265 | ] 266 | }, 267 | "options": {} 268 | }, 269 | "id": "31ba6516-5ea2-4758-8210-2aa7cb22a896", 270 | "name": "Dados2", 271 | "type": "n8n-nodes-base.set", 272 | "typeVersion": 3.3, 273 | "position": [ 274 | 1040, 275 | 660 276 | ] 277 | }, 278 | { 279 | "parameters": { 280 | "url": "= {{ $('Cadastra contatos').item.json.body.arquivo }}", 281 | "options": {} 282 | }, 283 | "id": "66735776-898a-4dc6-90f7-649dbad0d14d", 284 | "name": "HTTP Request", 285 | "type": "n8n-nodes-base.httpRequest", 286 | "typeVersion": 4.2, 287 | "position": [ 288 | 1240, 289 | 660 290 | ] 291 | }, 292 | { 293 | "parameters": { 294 | "operation": "executeQuery", 295 | "query": "SELECT title, account_id\nFROM labels\nWHERE account_id = {{ $json.chatwoot_id }}", 296 | "options": { 297 | "queryReplacement": "={{ $json.chatwoot_id }}" 298 | } 299 | }, 300 | "id": "3bd785d3-1b5d-410f-b3b3-b60c76839998", 301 | "name": "Postgres", 302 | "type": "n8n-nodes-base.postgres", 303 | "typeVersion": 2.4, 304 | "position": [ 305 | 1220, 306 | 100 307 | ], 308 | "alwaysOutputData": true, 309 | "credentials": { 310 | "postgres": { 311 | "id": "CbrIGpLnj1oilB4h", 312 | "name": "Chatwoot" 313 | } 314 | } 315 | }, 316 | { 317 | "parameters": { 318 | "options": {} 319 | }, 320 | "id": "fe44dcc2-7f33-4bf0-921b-b55c1fde9d0b", 321 | "name": "Loop Over Items", 322 | "type": "n8n-nodes-base.splitInBatches", 323 | "typeVersion": 3, 324 | "position": [ 325 | 1600, 326 | 680 327 | ] 328 | }, 329 | { 330 | "parameters": { 331 | "method": "POST", 332 | "url": "={{ $('Dados2').item.json.chatwoot_url }}/api/v1/accounts/{{ $('Dados2').item.json.chatwoot_id }}/contacts", 333 | "sendHeaders": true, 334 | "headerParameters": { 335 | "parameters": [ 336 | { 337 | "name": "api_access_token", 338 | "value": "={{ $('Dados2').item.json.chatwoot_token }}" 339 | }, 340 | { 341 | "name": "Content-Type", 342 | "value": "application/json" 343 | } 344 | ] 345 | }, 346 | "sendBody": true, 347 | "specifyBody": "json", 348 | "jsonBody": "={\n\"name\": \"{{ $json.nome }}\",\n\"email\": \"{{ $json.email }}\",\n\"phone_number\": \"+{{ $json.telefone }}\"\n}", 349 | "options": {} 350 | }, 351 | "id": "0cd16855-5a75-46e6-8204-38f2066bddd6", 352 | "name": "Cadastra contato", 353 | "type": "n8n-nodes-base.httpRequest", 354 | "typeVersion": 4.2, 355 | "position": [ 356 | 1860, 357 | 580 358 | ], 359 | "onError": "continueRegularOutput" 360 | }, 361 | { 362 | "parameters": { 363 | "method": "POST", 364 | "url": "={{ $('Dados2').item.json.chatwoot_url }}/api/v1/accounts/{{ $('Dados2').item.json.chatwoot_id }}/contacts/{{ $json.payload[0].id }}/labels", 365 | "sendHeaders": true, 366 | "headerParameters": { 367 | "parameters": [ 368 | { 369 | "name": "api_access_token", 370 | "value": "={{ $('Dados2').item.json.chatwoot_token }}" 371 | }, 372 | { 373 | "name": "Content-Type", 374 | "value": "application/json" 375 | } 376 | ] 377 | }, 378 | "sendBody": true, 379 | "specifyBody": "json", 380 | "jsonBody": "={\n \"labels\": [\"{{ $('Cadastra contatos').item.json.body.etiqueta }}\"]\n}", 381 | "options": {} 382 | }, 383 | "id": "a99cc82c-1e27-4eed-9604-df2826d87f10", 384 | "name": "atribui etiqueta", 385 | "type": "n8n-nodes-base.httpRequest", 386 | "typeVersion": 3, 387 | "position": [ 388 | 2260, 389 | 580 390 | ], 391 | "onError": "continueRegularOutput" 392 | }, 393 | { 394 | "parameters": { 395 | "url": "={{ $('Dados2').item.json.chatwoot_url }}/api/v1/accounts/{{ $('Dados2').item.json.chatwoot_id }}/contacts/search ", 396 | "sendQuery": true, 397 | "queryParameters": { 398 | "parameters": [ 399 | { 400 | "name": "q", 401 | "value": "={{ $('Loop Over Items').item.json.telefone }}" 402 | } 403 | ] 404 | }, 405 | "sendHeaders": true, 406 | "headerParameters": { 407 | "parameters": [ 408 | { 409 | "name": "api_access_token", 410 | "value": "={{ $('Dados2').item.json.chatwoot_token }}" 411 | } 412 | ] 413 | }, 414 | "options": {} 415 | }, 416 | "id": "93412fd0-e265-4275-82e8-6df660e7c42d", 417 | "name": "Busca contato", 418 | "type": "n8n-nodes-base.httpRequest", 419 | "typeVersion": 3, 420 | "position": [ 421 | 2060, 422 | 580 423 | ], 424 | "onError": "continueRegularOutput" 425 | }, 426 | { 427 | "parameters": { 428 | "content": "## Cadastra etiqueta\n**Criado por Rodrigo Tanci**", 429 | "height": 287.8707074425289, 430 | "width": 766.5264424104137 431 | }, 432 | "id": "246a7eca-1021-4a97-84bf-b1ae5e28b21f", 433 | "name": "Sticky Note", 434 | "type": "n8n-nodes-base.stickyNote", 435 | "typeVersion": 1, 436 | "position": [ 437 | 820, 438 | -300 439 | ] 440 | }, 441 | { 442 | "parameters": { 443 | "content": "## Seleciona etiqueta\n**Criado por Rodrigo Tanci**", 444 | "height": 287.8707074425289, 445 | "width": 947.0497940939842 446 | }, 447 | "id": "6cb7dcf7-d251-4078-8c82-b3f7f2a64f6f", 448 | "name": "Sticky Note1", 449 | "type": "n8n-nodes-base.stickyNote", 450 | "typeVersion": 1, 451 | "position": [ 452 | 820, 453 | 20 454 | ] 455 | }, 456 | { 457 | "parameters": { 458 | "content": "## Cadastra contato\n**Criado por Rodrigo Tanci**", 459 | "height": 560.5361865479214, 460 | "width": 1815.8184240711662 461 | }, 462 | "id": "8300d594-0254-4546-984d-562afffe095e", 463 | "name": "Sticky Note2", 464 | "type": "n8n-nodes-base.stickyNote", 465 | "typeVersion": 1, 466 | "position": [ 467 | 820, 468 | 340 469 | ] 470 | } 471 | ], 472 | "pinData": {}, 473 | "connections": { 474 | "Replace Me": { 475 | "main": [ 476 | [ 477 | { 478 | "node": "Loop Over Items", 479 | "type": "main", 480 | "index": 0 481 | } 482 | ] 483 | ] 484 | }, 485 | "Extract from File": { 486 | "main": [ 487 | [ 488 | { 489 | "node": "Loop Over Items", 490 | "type": "main", 491 | "index": 0 492 | } 493 | ] 494 | ] 495 | }, 496 | "Code": { 497 | "main": [ 498 | [ 499 | { 500 | "node": "Respond to Webhook", 501 | "type": "main", 502 | "index": 0 503 | } 504 | ] 505 | ] 506 | }, 507 | "Dados": { 508 | "main": [ 509 | [ 510 | { 511 | "node": "Cadastra etiqueta", 512 | "type": "main", 513 | "index": 0 514 | } 515 | ] 516 | ] 517 | }, 518 | "Cadastra etiqueta2": { 519 | "main": [ 520 | [ 521 | { 522 | "node": "Dados", 523 | "type": "main", 524 | "index": 0 525 | } 526 | ] 527 | ] 528 | }, 529 | "Cadastra etiqueta": { 530 | "main": [ 531 | [ 532 | { 533 | "node": "Respond to Webhook1", 534 | "type": "main", 535 | "index": 0 536 | } 537 | ] 538 | ] 539 | }, 540 | "Dados1": { 541 | "main": [ 542 | [ 543 | { 544 | "node": "Postgres", 545 | "type": "main", 546 | "index": 0 547 | } 548 | ] 549 | ] 550 | }, 551 | "Dados2": { 552 | "main": [ 553 | [ 554 | { 555 | "node": "HTTP Request", 556 | "type": "main", 557 | "index": 0 558 | } 559 | ] 560 | ] 561 | }, 562 | "Busca etiquetas": { 563 | "main": [ 564 | [ 565 | { 566 | "node": "Dados1", 567 | "type": "main", 568 | "index": 0 569 | } 570 | ] 571 | ] 572 | }, 573 | "HTTP Request": { 574 | "main": [ 575 | [ 576 | { 577 | "node": "Extract from File", 578 | "type": "main", 579 | "index": 0 580 | } 581 | ] 582 | ] 583 | }, 584 | "Postgres": { 585 | "main": [ 586 | [ 587 | { 588 | "node": "Code", 589 | "type": "main", 590 | "index": 0 591 | } 592 | ] 593 | ] 594 | }, 595 | "Loop Over Items": { 596 | "main": [ 597 | [ 598 | { 599 | "node": "Respond to Webhook2", 600 | "type": "main", 601 | "index": 0 602 | } 603 | ], 604 | [ 605 | { 606 | "node": "Cadastra contato", 607 | "type": "main", 608 | "index": 0 609 | } 610 | ] 611 | ] 612 | }, 613 | "Cadastra contato": { 614 | "main": [ 615 | [ 616 | { 617 | "node": "Busca contato", 618 | "type": "main", 619 | "index": 0 620 | } 621 | ] 622 | ] 623 | }, 624 | "atribui etiqueta": { 625 | "main": [ 626 | [ 627 | { 628 | "node": "Replace Me", 629 | "type": "main", 630 | "index": 0 631 | } 632 | ] 633 | ] 634 | }, 635 | "Busca contato": { 636 | "main": [ 637 | [ 638 | { 639 | "node": "atribui etiqueta", 640 | "type": "main", 641 | "index": 0 642 | } 643 | ] 644 | ] 645 | }, 646 | "Cadastra contatos": { 647 | "main": [ 648 | [ 649 | { 650 | "node": "Dados2", 651 | "type": "main", 652 | "index": 0 653 | } 654 | ] 655 | ] 656 | } 657 | }, 658 | "active": false, 659 | "settings": { 660 | "executionOrder": "v1" 661 | }, 662 | "versionId": "b560cab0-8f60-4c5c-b738-dc8039fb40f2", 663 | "meta": { 664 | "templateCredsSetupCompleted": true, 665 | "instanceId": "33738330930e3881dd5571eca013f36ddf8aab20e4ea5c1f2ebaf4a2b4668ac6" 666 | }, 667 | "id": "ToZSJZZgdU7bCHDw", 668 | "tags": [ 669 | { 670 | "createdAt": "2024-06-24T17:54:45.734Z", 671 | "updatedAt": "2024-06-24T17:54:45.734Z", 672 | "id": "W4QFAwjDhUwUJMhH", 673 | "name": "Dev" 674 | } 675 | ] 676 | } 677 | --------------------------------------------------------------------------------