From 7a9e66d2b8f2d2e4b4aefeaedbb1c2e8c97a86ad Mon Sep 17 00:00:00 2001 From: Gabriel Augusto Date: Wed, 2 Oct 2024 22:30:15 -0300 Subject: [PATCH] Fluxos live Evolution --- .../Buffer_com_Tratativa_Audio.json | 776 ++++++++++++++++++ .../EvolutionAPI_Live.json | 706 ++++++++++++++++ .../README.md | 19 + 3 files changed, 1501 insertions(+) create mode 100644 Live 02-10-2024 Tratamento de Mensagens Recebidas na Evolution API/Buffer_com_Tratativa_Audio.json create mode 100644 Live 02-10-2024 Tratamento de Mensagens Recebidas na Evolution API/EvolutionAPI_Live.json create mode 100644 Live 02-10-2024 Tratamento de Mensagens Recebidas na Evolution API/README.md diff --git a/Live 02-10-2024 Tratamento de Mensagens Recebidas na Evolution API/Buffer_com_Tratativa_Audio.json b/Live 02-10-2024 Tratamento de Mensagens Recebidas na Evolution API/Buffer_com_Tratativa_Audio.json new file mode 100644 index 0000000..012983a --- /dev/null +++ b/Live 02-10-2024 Tratamento de Mensagens Recebidas na Evolution API/Buffer_com_Tratativa_Audio.json @@ -0,0 +1,776 @@ +{ + "name": "Buffer com Tratativa Audio", + "nodes": [ + { + "parameters": { + "operation": "get", + "propertyName": "messages", + "key": "={{ $('normalizacao').item.json.message.chat_id }}_buffer", + "options": {} + }, + "id": "d92776fd-0ef2-4993-a2af-1303f41c1ffe", + "name": "get messages buffer", + "type": "n8n-nodes-base.redis", + "typeVersion": 1, + "position": [ + -380, + 660 + ], + "credentials": { + "redis": { + "id": "ccEEcPDqUplE95d3", + "name": "Redis account" + } + } + }, + { + "parameters": { + "operation": "push", + "list": "={{ $('normalizacao').item.json.message.chat_id }}_buffer", + "messageData": "={{ JSON.stringify($('normalizacao').item.json.message) }}", + "tail": true + }, + "id": "4f680526-8042-4c28-b68f-826bda5c0941", + "name": "push message buffer", + "type": "n8n-nodes-base.redis", + "typeVersion": 1, + "position": [ + -600, + 660 + ], + "credentials": { + "redis": { + "id": "ccEEcPDqUplE95d3", + "name": "Redis account" + } + } + }, + { + "parameters": {}, + "id": "9264bf45-cf3b-4b4a-bac8-da965eedc4a7", + "name": "Wait", + "type": "n8n-nodes-base.wait", + "typeVersion": 1.1, + "position": [ + 200, + 840 + ], + "webhookId": "ac13eb12-ea29-4507-9539-ea41f8091b8f" + }, + { + "parameters": {}, + "id": "33692578-7a75-46ca-a6d1-d911f6bbccc7", + "name": "No Operation, do nothing", + "type": "n8n-nodes-base.noOp", + "typeVersion": 1, + "position": [ + 200, + 480 + ] + }, + { + "parameters": { + "operation": "delete", + "key": "={{ $('normalizacao').item.json.message.chat_id }}_buffer" + }, + "id": "10b2d7ac-c741-4d5b-8221-4436d9495922", + "name": "delete buffer", + "type": "n8n-nodes-base.redis", + "typeVersion": 1, + "position": [ + 200, + 660 + ], + "credentials": { + "redis": { + "id": "ccEEcPDqUplE95d3", + "name": "Redis account" + } + } + }, + { + "parameters": { + "assignments": { + "assignments": [ + { + "id": "db5cfe0a-7f43-4a61-8b27-bfd3a95deb8d", + "name": "chatInput", + "value": "={{ $json.messages.join('\\n') }}", + "type": "string" + } + ] + }, + "options": {} + }, + "id": "3a68f91f-a43b-43ef-85e0-acce6a7ed454", + "name": "chatInput", + "type": "n8n-nodes-base.set", + "typeVersion": 3.4, + "position": [ + 2680, + 660 + ] + }, + { + "parameters": { + "fieldToSplitOut": "messages", + "options": {} + }, + "id": "d07eb2dd-8b08-45b0-961b-80efcb73312c", + "name": "Split User messages", + "type": "n8n-nodes-base.splitOut", + "typeVersion": 1, + "position": [ + 440, + 660 + ] + }, + { + "parameters": { + "mode": "raw", + "jsonOutput": "={{ JSON.parse($json.messages) }}", + "options": {} + }, + "id": "f7fd6b08-16b9-4619-b506-27c3cf3257a0", + "name": "Parse message", + "type": "n8n-nodes-base.set", + "typeVersion": 3.4, + "position": [ + 660, + 660 + ] + }, + { + "parameters": { + "method": "POST", + "url": "={{ $('normalizacao').item.json.instance.server_url }}/chat/getBase64FromMediaMessage/{{ $('normalizacao').item.json.instance.name }}", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "apikey", + "value": "={{ $('normalizacao').item.json.instance.apikey }}" + } + ] + }, + "sendBody": true, + "bodyParameters": { + "parameters": [ + { + "name": "message.key.id", + "value": "={{ $json.message_id }}" + }, + { + "name": "convertToMp4", + "value": "={{ Boolean(false) }}" + } + ] + }, + "options": {} + }, + "id": "26dded75-ebb4-4e2e-bc05-6b8419b2f170", + "name": "Get audio base64 EvolutionAPI", + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.2, + "position": [ + 1100, + 480 + ] + }, + { + "parameters": { + "operation": "toBinary", + "sourceProperty": "base64", + "options": { + "mimeType": "={{ $json.mimetype }}" + } + }, + "id": "3f289623-df8f-44e4-af0a-da407cad51f8", + "name": "Convert to File", + "type": "n8n-nodes-base.convertToFile", + "typeVersion": 1.1, + "position": [ + 1320, + 480 + ] + }, + { + "parameters": { + "method": "POST", + "url": "={{ $('normalizacao').item.json.instance.server_url }}/message/sendText/{{ $('normalizacao').item.json.instance.name }}", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "apikey", + "value": "={{ $('normalizacao').item.json.instance.apikey }}" + } + ] + }, + "sendBody": true, + "bodyParameters": { + "parameters": [ + { + "name": "number", + "value": "={{ $('normalizacao').item.json.message.chat_id }}" + }, + { + "name": "text", + "value": "=*System info*: _Por favor, nos envie apenas mensagens de texto ou audio!_" + }, + { + "name": "delay", + "value": "={{ Number(1200) }}" + } + ] + }, + "options": {} + }, + "id": "525225e9-0e16-454e-a04d-ae55db9c672e", + "name": "Send System Info (Content Type) EvolutionAPI", + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.2, + "position": [ + 1100, + 840 + ] + }, + { + "parameters": { + "assignments": { + "assignments": [ + { + "id": "82cccc1e-3c1d-43fd-a4e9-7d2794cb23eb", + "name": "content", + "value": "=", + "type": "string" + }, + { + "id": "d96cf6b7-02ea-464f-862d-fa0518848297", + "name": "message_id", + "value": "={{ $('Parse message').item.json.message_id }}", + "type": "string" + }, + { + "id": "51aee4e3-5e8c-4f0e-8afc-13ba65e2094c", + "name": "chat_id", + "value": "={{ $('Parse message').item.json.chat_id }}", + "type": "string" + }, + { + "id": "f854354f-711f-4809-ade2-8d4f5d17921d", + "name": "content_type", + "value": "={{ $('Parse message').item.json.content_type }}", + "type": "string" + }, + { + "id": "4dbd77f8-6346-4eb5-ba45-5e0a88266c05", + "name": "timestamp", + "value": "={{ $('Parse message').item.json.timestamp }}", + "type": "string" + }, + { + "id": "1d7de295-bd0f-4640-90da-4580e408c40a", + "name": "content_url", + "value": "={{ $('Parse message').item.json.content_url }}", + "type": "string" + }, + { + "id": "8b712f9c-bb3f-48b1-b9af-4109ef1c8858", + "name": "event", + "value": "={{ $('Parse message').item.json.event }}", + "type": "string" + } + ] + }, + "options": {} + }, + "id": "5dfc7735-ade7-460b-a67a-354a9a3e1091", + "name": "Message audio content", + "type": "n8n-nodes-base.set", + "typeVersion": 3.4, + "position": [ + 1760, + 480 + ] + }, + { + "parameters": { + "fieldsToAggregate": { + "fieldToAggregate": [ + { + "fieldToAggregate": "content", + "renameField": true, + "outputFieldName": "messages" + } + ] + }, + "options": {} + }, + "id": "ef17ff78-3543-49c8-9c1a-c6edc8c66d5c", + "name": "Aggregate", + "type": "n8n-nodes-base.aggregate", + "typeVersion": 1, + "position": [ + 2460, + 660 + ] + }, + { + "parameters": { + "sortFieldsUi": { + "sortField": [ + { + "fieldName": "timestamp" + } + ] + }, + "options": {} + }, + "id": "ab28d317-4b5b-4a1c-a38c-a5daf8ef8556", + "name": "Sort", + "type": "n8n-nodes-base.sort", + "typeVersion": 1, + "position": [ + 2240, + 660 + ] + }, + { + "parameters": { + "assignments": { + "assignments": [ + { + "id": "c3f5615e-1294-4a6a-81f5-59448b8a0d0c", + "name": "content", + "value": "=\n{{ $('Parse message').item.json.content }}\n", + "type": "string" + } + ] + }, + "includeOtherFields": true, + "options": {} + }, + "id": "3a7c63c2-a8bc-4a25-a4de-5b8547449200", + "name": "Message text content", + "type": "n8n-nodes-base.set", + "typeVersion": 3.4, + "position": [ + 1100, + 660 + ] + }, + { + "parameters": { + "rules": { + "values": [ + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict" + }, + "conditions": [ + { + "leftValue": "={{ JSON.parse($json.messages.first()).message_id }}", + "rightValue": "={{ $('normalizacao').item.json.message.message_id }}", + "operator": { + "type": "string", + "operation": "notEquals" + } + } + ], + "combinator": "and" + }, + "renameOutput": true, + "outputKey": "nada a fazer" + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict" + }, + "conditions": [ + { + "id": "fdd1e894-df1c-4ebd-8f56-82f66dad03be", + "leftValue": "={{ JSON.parse($json.messages.last()).timestamp }}", + "rightValue": "={{ $now.minus(15, 'seconds') }}", + "operator": { + "type": "dateTime", + "operation": "before" + } + } + ], + "combinator": "and" + }, + "renameOutput": true, + "outputKey": "prosseguir" + } + ] + }, + "options": { + "fallbackOutput": "extra", + "renameFallbackOutput": "esperar" + } + }, + "id": "a2991979-ce26-4b5c-b98e-6fc52a3b8c2c", + "name": "Switch1", + "type": "n8n-nodes-base.switch", + "typeVersion": 3, + "position": [ + -160, + 660 + ] + }, + { + "parameters": { + "resource": "audio", + "operation": "transcribe", + "options": {} + }, + "id": "ce9e77d6-a136-4ba1-ac12-11cd03706dd5", + "name": "OpenAI Transcribe", + "type": "@n8n/n8n-nodes-langchain.openAi", + "typeVersion": 1.4, + "position": [ + 1540, + 480 + ], + "credentials": { + "openAiApi": { + "id": "EwQcFaVNnvQlPhPk", + "name": "OpenAi account" + } + } + }, + { + "parameters": {}, + "id": "8bd98cd7-9806-487d-9546-d4f69041f18d", + "name": "Merge Append", + "type": "n8n-nodes-base.merge", + "typeVersion": 3, + "position": [ + 2000, + 660 + ] + }, + { + "parameters": { + "rules": { + "values": [ + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict" + }, + "conditions": [ + { + "leftValue": "={{ $json.content_type }}", + "rightValue": "audio", + "operator": { + "type": "string", + "operation": "equals" + } + } + ], + "combinator": "and" + }, + "renameOutput": true, + "outputKey": "audio" + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict" + }, + "conditions": [ + { + "id": "a1dfeee8-7927-4419-b091-e5b1930c011e", + "leftValue": "={{ $json.content_type }}", + "rightValue": "text", + "operator": { + "type": "string", + "operation": "equals", + "name": "filter.operator.equals" + } + } + ], + "combinator": "and" + }, + "renameOutput": true, + "outputKey": "text" + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict" + }, + "conditions": [ + { + "id": "7431ffc4-1ee4-4556-8053-d8b2480450b8", + "leftValue": "={{ $json.content_type }}", + "rightValue": "image", + "operator": { + "type": "string", + "operation": "equals", + "name": "filter.operator.equals" + } + } + ], + "combinator": "and" + }, + "renameOutput": true, + "outputKey": "image" + } + ] + }, + "options": { + "fallbackOutput": "extra", + "renameFallbackOutput": "other" + } + }, + "id": "896983d6-fbcb-465c-a050-65164108cd45", + "name": "Switch Content Type", + "type": "n8n-nodes-base.switch", + "typeVersion": 3, + "position": [ + 880, + 660 + ] + } + ], + "pinData": {}, + "connections": { + "get messages buffer": { + "main": [ + [ + { + "node": "Switch1", + "type": "main", + "index": 0 + } + ] + ] + }, + "push message buffer": { + "main": [ + [ + { + "node": "get messages buffer", + "type": "main", + "index": 0 + } + ] + ] + }, + "Wait": { + "main": [ + [ + { + "node": "get messages buffer", + "type": "main", + "index": 0 + } + ] + ] + }, + "delete buffer": { + "main": [ + [ + { + "node": "Split User messages", + "type": "main", + "index": 0 + } + ] + ] + }, + "Split User messages": { + "main": [ + [ + { + "node": "Parse message", + "type": "main", + "index": 0 + } + ] + ] + }, + "Parse message": { + "main": [ + [ + { + "node": "Switch Content Type", + "type": "main", + "index": 0 + } + ] + ] + }, + "Get audio base64 EvolutionAPI": { + "main": [ + [ + { + "node": "Convert to File", + "type": "main", + "index": 0 + } + ] + ] + }, + "Convert to File": { + "main": [ + [ + { + "node": "OpenAI Transcribe", + "type": "main", + "index": 0 + } + ] + ] + }, + "Message audio content": { + "main": [ + [ + { + "node": "Merge Append", + "type": "main", + "index": 0 + } + ] + ] + }, + "Aggregate": { + "main": [ + [ + { + "node": "chatInput", + "type": "main", + "index": 0 + } + ] + ] + }, + "Sort": { + "main": [ + [ + { + "node": "Aggregate", + "type": "main", + "index": 0 + } + ] + ] + }, + "Message text content": { + "main": [ + [ + { + "node": "Merge Append", + "type": "main", + "index": 1 + } + ] + ] + }, + "Switch1": { + "main": [ + [ + { + "node": "No Operation, do nothing", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "delete buffer", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Wait", + "type": "main", + "index": 0 + } + ] + ] + }, + "OpenAI Transcribe": { + "main": [ + [ + { + "node": "Message audio content", + "type": "main", + "index": 0 + } + ] + ] + }, + "Merge Append": { + "main": [ + [ + { + "node": "Sort", + "type": "main", + "index": 0 + } + ] + ] + }, + "Switch Content Type": { + "main": [ + [ + { + "node": "Get audio base64 EvolutionAPI", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Message text content", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Send System Info (Content Type) EvolutionAPI", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Send System Info (Content Type) EvolutionAPI", + "type": "main", + "index": 0 + } + ] + ] + } + }, + "active": false, + "settings": { + "executionOrder": "v1" + }, + "versionId": "0836ce04-c9c6-4bc9-86cf-8ea1406c29d3", + "meta": { + "templateCredsSetupCompleted": true, + "instanceId": "2ad20c637f548d7b1e09cbae0383c6644aca87b4f0fe8deda2de937f77c2be79" + }, + "id": "RK76f1CdtABobq2G", + "tags": [] +} \ No newline at end of file diff --git a/Live 02-10-2024 Tratamento de Mensagens Recebidas na Evolution API/EvolutionAPI_Live.json b/Live 02-10-2024 Tratamento de Mensagens Recebidas na Evolution API/EvolutionAPI_Live.json new file mode 100644 index 0000000..4334157 --- /dev/null +++ b/Live 02-10-2024 Tratamento de Mensagens Recebidas na Evolution API/EvolutionAPI_Live.json @@ -0,0 +1,706 @@ +{ + "name": "EvolutionAPI Live", + "nodes": [ + { + "parameters": { + "options": {} + }, + "id": "a88cacc3-970b-44f1-b381-d74ec724fb1e", + "name": "MENSAGEM DE TEXTO", + "type": "n8n-nodes-base.set", + "typeVersion": 3.4, + "position": [ + 820, + 160 + ] + }, + { + "parameters": { + "options": {} + }, + "id": "2eb4085c-e5d5-4b0b-9d32-79c9e0a88a62", + "name": "IMAGEM SEM LEGENDA", + "type": "n8n-nodes-base.set", + "typeVersion": 3.4, + "position": [ + 820, + 340 + ] + }, + { + "parameters": { + "options": {} + }, + "id": "2e5084dc-889d-4c74-8012-72ac9b24bb66", + "name": "IMAGEM COM LEGENDA", + "type": "n8n-nodes-base.set", + "typeVersion": 3.4, + "position": [ + 820, + 520 + ] + }, + { + "parameters": { + "httpMethod": "POST", + "path": "evolution-live", + "options": {} + }, + "id": "57341b5a-318c-4210-8888-f6621f6a3c27", + "name": "Webhook", + "type": "n8n-nodes-base.webhook", + "typeVersion": 2, + "position": [ + 480, + 460 + ], + "webhookId": "c8963ab5-6995-48a3-bdc6-ff5e411fdc09" + }, + { + "parameters": { + "options": {} + }, + "id": "e42874ed-46eb-4add-8e38-9d6c1126b508", + "name": "AUDIO", + "type": "n8n-nodes-base.set", + "typeVersion": 3.4, + "position": [ + 820, + 720 + ] + }, + { + "parameters": { + "assignments": { + "assignments": [ + { + "id": "8f16b1bf-1a3e-4029-8d7a-1bccb919ee43", + "name": "message.message_id", + "value": "={{ $json.body?.data?.key?.id || '' }}", + "type": "string" + }, + { + "id": "11800d83-ecca-4f9c-a878-a2419db0c8e9", + "name": "message.chat_id", + "value": "={{ $json.body.data.key.remoteJid || '' }}", + "type": "string" + }, + { + "id": "c33f9527-e661-49e5-8e5e-64f3b430928a", + "name": "message.content_type", + "value": "={{ $json.body.data.message.extendedTextMessage ? 'text' : '' }}{{ $json.body.data.message.conversation ? 'text' : '' }}{{ $json.body.data.message.audioMessage ? 'audio' : '' }}{{ $json.body.data.message.imageMessage ? 'image' : '' }}", + "type": "string" + }, + { + "id": "06eba1c9-cff0-4f68-b6da-6bb0092466b7", + "name": "message.content", + "value": "={{ $json.body.data.message.extendedTextMessage?.text || '' }}{{ $json.body.data.message.imageMessage?.caption || '' }}{{ $json.body.data.message.conversation || '' }}", + "type": "string" + }, + { + "id": "b97f1af3-5361-46fc-9303-d644921231d8", + "name": "message.timestamp", + "value": "={{ $json.body.data.messageTimestamp.toDateTime('s').toISO() }}", + "type": "string" + }, + { + "id": "dc3dc59c-90a3-4a45-bea2-de092c91083b", + "name": "message.content_url", + "value": "={{ $json.body.data.message.audioMessage?.url || '' }}{{ $json.body.data.message.imageMessage?.url || '' }}", + "type": "string" + }, + { + "id": "8b01a818-a456-476e-bace-adefe2f04eb4", + "name": "message.event", + "value": "={{ $json.body.data.key.fromMe ? 'outcoming' : 'incoming' }}", + "type": "string" + }, + { + "id": "b2f1f6b5-292f-4695-9e41-be200c6d7053", + "name": "instance.name", + "value": "={{ $json.body.instance }}", + "type": "string" + }, + { + "id": "572fcce5-8a26-4e8f-a48a-ef0bee569dcd", + "name": "instance.apikey", + "value": "={{ $json.body.apikey }}", + "type": "string" + }, + { + "id": "e90043db-657b-461c-b040-2d6089abfbdb", + "name": "instance.server_url", + "value": "={{ $json.body.server_url }}", + "type": "string" + } + ] + }, + "options": {} + }, + "id": "eb3b97f5-cdac-43f5-82b7-e87cdf98d292", + "name": "normalizacao", + "type": "n8n-nodes-base.set", + "typeVersion": 3.4, + "position": [ + 1120, + 440 + ] + }, + { + "parameters": { + "method": "POST", + "url": "={{ $('normalizacao').item.json.instance.server_url }}/chat/getBase64FromMediaMessage/{{ $('normalizacao').item.json.instance.name }}", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "apikey", + "value": "={{ $('normalizacao').item.json.instance.apikey }}" + } + ] + }, + "sendBody": true, + "bodyParameters": { + "parameters": [ + { + "name": "message.key.id", + "value": "={{ $json.message.message_id }}" + }, + { + "name": "convertToMp4", + "value": "={{ Boolean(false) }}" + } + ] + }, + "options": {} + }, + "id": "57eacc0c-0c1c-4152-a732-f5795ad704eb", + "name": "Get audio base64 EvolutionAPI", + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.2, + "position": [ + 1700, + 740 + ] + }, + { + "parameters": { + "rules": { + "values": [ + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict" + }, + "conditions": [ + { + "leftValue": "={{ $json.message.content_type }}", + "rightValue": "audio", + "operator": { + "type": "string", + "operation": "equals" + } + } + ], + "combinator": "and" + }, + "renameOutput": true, + "outputKey": "audio" + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict" + }, + "conditions": [ + { + "id": "a1dfeee8-7927-4419-b091-e5b1930c011e", + "leftValue": "={{ $json.message.content_type }}", + "rightValue": "text", + "operator": { + "type": "string", + "operation": "equals", + "name": "filter.operator.equals" + } + } + ], + "combinator": "and" + }, + "renameOutput": true, + "outputKey": "text" + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict" + }, + "conditions": [ + { + "id": "ab4d4cfb-b90f-4fda-96e2-9397e0fbd4c2", + "leftValue": "={{ $json.message.content_type }}", + "rightValue": "image", + "operator": { + "type": "string", + "operation": "equals", + "name": "filter.operator.equals" + } + } + ], + "combinator": "and" + }, + "renameOutput": true, + "outputKey": "image" + } + ] + }, + "options": { + "fallbackOutput": "extra", + "renameFallbackOutput": "other" + } + }, + "id": "76ea90cb-25fc-4847-ac6d-775500ab5b45", + "name": "Switch Content Type", + "type": "n8n-nodes-base.switch", + "typeVersion": 3, + "position": [ + 1380, + 440 + ] + }, + { + "parameters": { + "operation": "toBinary", + "sourceProperty": "base64", + "options": { + "fileName": "imagem", + "mimeType": "={{ $json.mimetype }}" + } + }, + "id": "d6c3c596-fa3c-4012-8a72-131346127cef", + "name": "Convert to File", + "type": "n8n-nodes-base.convertToFile", + "typeVersion": 1.1, + "position": [ + 1920, + 740 + ] + }, + { + "parameters": { + "resource": "image", + "operation": "analyze", + "modelId": { + "__rl": true, + "value": "gpt-4o-mini", + "mode": "list", + "cachedResultName": "GPT-4O-MINI" + }, + "inputType": "base64", + "options": {} + }, + "id": "e2518570-4f7b-41ff-8b83-061e221ab1f1", + "name": "OpenAI", + "type": "@n8n/n8n-nodes-langchain.openAi", + "typeVersion": 1.4, + "position": [ + 2120, + 740 + ], + "credentials": { + "openAiApi": { + "id": "EwQcFaVNnvQlPhPk", + "name": "OpenAi account" + } + } + }, + { + "parameters": { + "content": "Alguns tipos de mensagens\n", + "height": 894.6046511627903, + "width": 265.88372093023236 + }, + "id": "c3bf99df-6ecb-4da3-9ef3-850c2a50e4eb", + "name": "Sticky Note", + "type": "n8n-nodes-base.stickyNote", + "typeVersion": 1, + "position": [ + 740, + 80 + ] + }, + { + "parameters": { + "content": "Audio para texto\n", + "height": 336.2558139534884, + "width": 672.6279069767438 + }, + "id": "37dff657-a2d7-4b2b-8385-df46697e5074", + "name": "Sticky Note1", + "type": "n8n-nodes-base.stickyNote", + "typeVersion": 1, + "position": [ + 1640, + 600 + ] + } + ], + "pinData": { + "MENSAGEM DE TEXTO": [ + { + "json": { + "headers": { + "host": "applications-n8n-editor.hzwlsv.easypanel.host", + "user-agent": "axios/1.6.7", + "content-length": "920", + "accept": "application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, image/*;q=0.8, */*;q=0.7", + "accept-encoding": "gzip, compress, deflate, br", + "content-type": "application/json", + "x-forwarded-for": "172.18.0.1", + "x-forwarded-host": "applications-n8n-editor.hzwlsv.easypanel.host", + "x-forwarded-port": "443", + "x-forwarded-proto": "https", + "x-forwarded-server": "d57e35ed6adc", + "x-real-ip": "172.18.0.1" + }, + "params": {}, + "query": {}, + "body": { + "event": "messages.upsert", + "instance": "Guto Bot", + "data": { + "key": { + "remoteJid": "554488581702@s.whatsapp.net", + "fromMe": false, + "id": "3AE08C5473A51DC3BE13" + }, + "pushName": "Gabriel Costa", + "message": { + "conversation": "MENSAGEM DE TEXTO", + "messageContextInfo": { + "deviceListMetadata": { + "senderKeyHash": "UhZcO5WXFcFggQ==", + "senderTimestamp": "1726696358", + "recipientKeyHash": "E/D9jrPfGn2rEA==", + "recipientTimestamp": "1727136227" + }, + "deviceListMetadataVersion": 2, + "messageSecret": "6lUPAuCQuy+dI4c7+6npkHe/RzNxZLoVhjwnYy1Im4s=" + } + }, + "messageType": "conversation", + "messageTimestamp": 1727912544, + "instanceId": "3451597b-7332-4b26-973d-9078af3ad9d6", + "source": "ios" + }, + "destination": "https://applications-n8n-webhook.hzwlsv.easypanel.host/webhook/evolution/router", + "date_time": "2024-10-02T20:42:24.188Z", + "sender": "554498600066@s.whatsapp.net", + "server_url": "https://applications-evolution-01.hzwlsv.easypanel.host", + "apikey": "FDF95E3733C6-436E-9B0E-1BFAC2BA4319" + }, + "webhookUrl": "https://applications-n8n-webhook.hzwlsv.easypanel.host/webhook-test/evolution-live", + "executionMode": "test" + } + } + ], + "IMAGEM SEM LEGENDA": [ + { + "json": { + "headers": { + "host": "applications-n8n-editor.hzwlsv.easypanel.host", + "user-agent": "axios/1.6.7", + "content-length": "3066", + "accept": "application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, image/*;q=0.8, */*;q=0.7", + "accept-encoding": "gzip, compress, deflate, br", + "content-type": "application/json", + "x-forwarded-for": "172.18.0.1", + "x-forwarded-host": "applications-n8n-editor.hzwlsv.easypanel.host", + "x-forwarded-port": "443", + "x-forwarded-proto": "https", + "x-forwarded-server": "d57e35ed6adc", + "x-real-ip": "172.18.0.1" + }, + "params": {}, + "query": {}, + "body": { + "event": "messages.upsert", + "instance": "Guto Bot", + "data": { + "key": { + "remoteJid": "554488581702@s.whatsapp.net", + "fromMe": false, + "id": "3A6675C1053EAB415DE8" + }, + "pushName": "Gabriel Costa", + "message": { + "imageMessage": { + "url": "https://mmg.whatsapp.net/v/t62.7118-24/12441748_1278835919956676_970704609290929687_n.enc?ccb=11-4&oh=01_Q5AaIN9oBao38-7y0NtrlSvtlvBKMNKAZ4GrOEWnPZhnu8Cf&oe=672553C0&_nc_sid=5e03e0&mms3=true", + "mimetype": "image/jpeg", + "fileSha256": "DIeYwLaeMETv20wKycLu0KAMrVVAqJIFGNggEykGqCA=", + "fileLength": "43832", + "height": 735, + "width": 1280, + "mediaKey": "pBkD3dwgRJOckmB8oJ8Y8wUPUhP0qS2HQWbyvUwSTHw=", + "fileEncSha256": "vHVkAfFKYagBYpblA6dErOxzosl0KbPKsXbKeJp/O0o=", + "directPath": "/v/t62.7118-24/12441748_1278835919956676_970704609290929687_n.enc?ccb=11-4&oh=01_Q5AaIN9oBao38-7y0NtrlSvtlvBKMNKAZ4GrOEWnPZhnu8Cf&oe=672553C0&_nc_sid=5e03e0", + "mediaKeyTimestamp": "1727912661", + "jpegThumbnail": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDABsSFBcUERsXFhceHBsgKEIrKCUlKFE6PTBCYFVlZF9VXVtqeJmBanGQc1tdhbWGkJ6jq62rZ4C8ybqmx5moq6T/2wBDARweHigjKE4rK06kbl1upKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKT/wgARCABIAEgDASIAAhEBAxEB/8QAGQABAQEBAQEAAAAAAAAAAAAAAAIBBQME/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAH/2gAMAwEAAhADEAAAAPPebh0HPHQc+j7nPHQc8Ru6RoaqzwaDBSdDNGVJ7TApQ8gAFUvmEpI7YALoXyCAf//EABQRAQAAAAAAAAAAAAAAAAAAAED/2gAIAQIBAT8AT//EABgRAAIDAAAAAAAAAAAAAAAAAAERECBA/9oACAEDAQE/AMKNWZ//xAApEAABAwIDCAMBAQAAAAAAAAABAAIDERIEFWEFEBYgITFRUyJBcRMw/9oACAEBAAE/AG7cxhNPiEdtYwMuuZ+LPcb4as9xvhqz3G+GrPcb4as9xvhqz3G+GrPcb4anS3HsFfor9Ffor0Xtp0HVX6K/RX6cpaQKkd0Gkiv1yFpDrU+Ms7q3pXc9zTGAK3BNkZ/K11a/VFTeXVNU55d3VelNxBA3QlpBDnBupUgaHG1wKewNA61ryBF1RTeFK+4D4hv5/iXV5WRukNGNJOidDIwVcwgcnD0nsXD0nsXD0nsXD0nsUWxJ4XXRy0Kk2PiZG2unqFw9J7Fw9J7Fw9J7F//+AAMA/9k=", + "firstScanSidecar": "Wh7q59pGetjrvA==", + "firstScanLength": 4676, + "scansSidecar": "Wh7q59pGetjrvJe5wCBKu6gcsTIyWVOCsNf4UdlNC2uVR8KZmw9bvw==", + "scanLengths": [ + 4676, + 16697, + 7740, + 14717 + ] + }, + "messageContextInfo": { + "deviceListMetadata": { + "senderKeyHash": "UhZcO5WXFcFggQ==", + "senderTimestamp": "1726696358", + "recipientKeyHash": "E/D9jrPfGn2rEA==", + "recipientTimestamp": "1727136227" + }, + "deviceListMetadataVersion": 2, + "messageSecret": "oeDlDgFixZ+UfDedrwInXc8NGxhev3EFW36PPSLtrSQ=" + }, + "mediaUrl": "https://databases-minio.hzwlsv.easypanel.host/evolution-01/evolution-api/3451597b-7332-4b26-973d-9078af3ad9d6/554488581702%40s.whatsapp.net/imageMessage/3A6675C1053EAB415DE8.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=OaBCHYCxI0fRaFYA2uop%2F20241002%2Feu-west-3%2Fs3%2Faws4_request&X-Amz-Date=20241002T234553Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=61779722798b3e0cda008a4b24ea348433c2edd0883851a6cc299980320a69ad" + }, + "contextInfo": null, + "messageType": "imageMessage", + "messageTimestamp": 1727912753, + "instanceId": "3451597b-7332-4b26-973d-9078af3ad9d6", + "source": "ios" + }, + "destination": "https://applications-n8n-webhook.hzwlsv.easypanel.host/webhook/evolution/router", + "date_time": "2024-10-02T20:45:53.171Z", + "sender": "554498600066@s.whatsapp.net", + "server_url": "https://applications-evolution-01.hzwlsv.easypanel.host", + "apikey": "FDF95E3733C6-436E-9B0E-1BFAC2BA4319" + }, + "webhookUrl": "https://applications-n8n-webhook.hzwlsv.easypanel.host/webhook-test/evolution-live", + "executionMode": "test" + } + } + ], + "IMAGEM COM LEGENDA": [ + { + "json": { + "headers": { + "host": "applications-n8n-webhook.hzwlsv.easypanel.host", + "user-agent": "axios/1.6.7", + "content-length": "3086", + "accept": "application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, image/*;q=0.8, */*;q=0.7", + "accept-encoding": "gzip, compress, deflate, br", + "content-type": "application/json", + "x-forwarded-for": "172.18.0.1", + "x-forwarded-host": "applications-n8n-webhook.hzwlsv.easypanel.host", + "x-forwarded-port": "443", + "x-forwarded-proto": "https", + "x-forwarded-server": "d57e35ed6adc", + "x-real-ip": "172.18.0.1" + }, + "params": {}, + "query": {}, + "body": { + "event": "messages.upsert", + "instance": "Guto Bot", + "data": { + "key": { + "remoteJid": "554488581702@s.whatsapp.net", + "fromMe": false, + "id": "3A9BD5F156B2766FD029" + }, + "pushName": "Gabriel Costa", + "message": { + "imageMessage": { + "url": "https://mmg.whatsapp.net/v/t62.7118-24/12441748_1278835919956676_970704609290929687_n.enc?ccb=11-4&oh=01_Q5AaIN9oBao38-7y0NtrlSvtlvBKMNKAZ4GrOEWnPZhnu8Cf&oe=672553C0&_nc_sid=5e03e0&mms3=true", + "mimetype": "image/jpeg", + "caption": "LEGENDA", + "fileSha256": "DIeYwLaeMETv20wKycLu0KAMrVVAqJIFGNggEykGqCA=", + "fileLength": "43832", + "height": 735, + "width": 1280, + "mediaKey": "pBkD3dwgRJOckmB8oJ8Y8wUPUhP0qS2HQWbyvUwSTHw=", + "fileEncSha256": "vHVkAfFKYagBYpblA6dErOxzosl0KbPKsXbKeJp/O0o=", + "directPath": "/v/t62.7118-24/12441748_1278835919956676_970704609290929687_n.enc?ccb=11-4&oh=01_Q5AaIN9oBao38-7y0NtrlSvtlvBKMNKAZ4GrOEWnPZhnu8Cf&oe=672553C0&_nc_sid=5e03e0", + "mediaKeyTimestamp": "1727912661", + "jpegThumbnail": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDABsSFBcUERsXFhceHBsgKEIrKCUlKFE6PTBCYFVlZF9VXVtqeJmBanGQc1tdhbWGkJ6jq62rZ4C8ybqmx5moq6T/2wBDARweHigjKE4rK06kbl1upKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKT/wgARCABIAEgDASIAAhEBAxEB/8QAGQABAQEBAQEAAAAAAAAAAAAAAAIBBQME/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAH/2gAMAwEAAhADEAAAAPPebh0HPHQc+j7nPHQc8Ru6RoaqzwaDBSdDNGVJ7TApQ8gAFUvmEpI7YALoXyCAf//EABQRAQAAAAAAAAAAAAAAAAAAAED/2gAIAQIBAT8AT//EABgRAAIDAAAAAAAAAAAAAAAAAAERECBA/9oACAEDAQE/AMKNWZ//xAApEAABAwIDCAMBAQAAAAAAAAABAAIDERIEFWEFEBYgITFRUyJBcRMw/9oACAEBAAE/AG7cxhNPiEdtYwMuuZ+LPcb4as9xvhqz3G+GrPcb4as9xvhqz3G+GrPcb4anS3HsFfor9Ffor0Xtp0HVX6K/RX6cpaQKkd0Gkiv1yFpDrU+Ms7q3pXc9zTGAK3BNkZ/K11a/VFTeXVNU55d3VelNxBA3QlpBDnBupUgaHG1wKewNA61ryBF1RTeFK+4D4hv5/iXV5WRukNGNJOidDIwVcwgcnD0nsXD0nsXD0nsXD0nsUWxJ4XXRy0Kk2PiZG2unqFw9J7Fw9J7Fw9J7F//+AAMA/9k=", + "firstScanSidecar": "Wh7q59pGetjrvA==", + "firstScanLength": 4676, + "scansSidecar": "Wh7q59pGetjrvJe5wCBKu6gcsTIyWVOCsNf4UdlNC2uVR8KZmw9bvw==", + "scanLengths": [ + 4676, + 16697, + 7740, + 14717 + ] + }, + "messageContextInfo": { + "deviceListMetadata": { + "senderKeyHash": "UhZcO5WXFcFggQ==", + "senderTimestamp": "1726696358", + "recipientKeyHash": "E/D9jrPfGn2rEA==", + "recipientTimestamp": "1727136227" + }, + "deviceListMetadataVersion": 2, + "messageSecret": "U3i0DK09fkawLTeMxEZzQYmYfJi9eJ2TE2tVyqPWtwY=" + }, + "mediaUrl": "https://databases-minio.hzwlsv.easypanel.host/evolution-01/evolution-api/3451597b-7332-4b26-973d-9078af3ad9d6/554488581702%40s.whatsapp.net/imageMessage/3A9BD5F156B2766FD029.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=OaBCHYCxI0fRaFYA2uop%2F20241002%2Feu-west-3%2Fs3%2Faws4_request&X-Amz-Date=20241002T234706Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=7629e957e61b9e372caa2b1c64b551c06aa7b7294a3e3e79cede21a51f2dd399" + }, + "contextInfo": null, + "messageType": "imageMessage", + "messageTimestamp": 1727912826, + "instanceId": "3451597b-7332-4b26-973d-9078af3ad9d6", + "source": "ios" + }, + "destination": "https://applications-n8n-webhook.hzwlsv.easypanel.host/webhook/evolution/router", + "date_time": "2024-10-02T20:47:06.137Z", + "sender": "554498600066@s.whatsapp.net", + "server_url": "https://applications-evolution-01.hzwlsv.easypanel.host", + "apikey": "FDF95E3733C6-436E-9B0E-1BFAC2BA4319" + }, + "webhookUrl": "https://applications-n8n-webhook.hzwlsv.easypanel.host/webhook/evolution-live", + "executionMode": "production" + } + } + ], + "AUDIO": [ + { + "json": { + "headers": { + "host": "applications-n8n-editor.hzwlsv.easypanel.host", + "user-agent": "axios/1.6.7", + "content-length": "2185", + "accept": "application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, image/*;q=0.8, */*;q=0.7", + "accept-encoding": "gzip, compress, deflate, br", + "content-type": "application/json", + "x-forwarded-for": "172.18.0.1", + "x-forwarded-host": "applications-n8n-editor.hzwlsv.easypanel.host", + "x-forwarded-port": "443", + "x-forwarded-proto": "https", + "x-forwarded-server": "d57e35ed6adc", + "x-real-ip": "172.18.0.1" + }, + "params": {}, + "query": {}, + "body": { + "event": "messages.upsert", + "instance": "Guto Bot", + "data": { + "key": { + "remoteJid": "554488581702@s.whatsapp.net", + "fromMe": false, + "id": "3AAB25EE1C6D0D08CD93" + }, + "pushName": "Gabriel Costa", + "message": { + "audioMessage": { + "url": "https://mmg.whatsapp.net/v/t62.7117-24/31825364_954974049980888_2418381174862333264_n.enc?ccb=11-4&oh=01_Q5AaIEJI7JN6h8pd-U0So_UUP8n2Fjbaj1zc5v55fyTD_CFU&oe=67253593&_nc_sid=5e03e0&mms3=true", + "mimetype": "audio/ogg; codecs=opus", + "fileSha256": "wGAdWcf5Zjl+F4kM37GHMkQx0Jf49dbcSSWX+WzUPM4=", + "fileLength": "6380", + "seconds": 3, + "ptt": true, + "mediaKey": "iBy2r7yMjiSWD9P4a1uS1rEun7WaNpYp/EbvgaJ/Ojc=", + "fileEncSha256": "5HFisay9B+kGeI1tABEZ1+rrvqU2Kr/QMZ27EkMfZnI=", + "directPath": "/v/t62.7117-24/31825364_954974049980888_2418381174862333264_n.enc?ccb=11-4&oh=01_Q5AaIEJI7JN6h8pd-U0So_UUP8n2Fjbaj1zc5v55fyTD_CFU&oe=67253593&_nc_sid=5e03e0", + "mediaKeyTimestamp": "1727912861", + "streamingSidecar": "ovzV9+rsCASgBw==", + "waveform": "AAAAAAAAAAAAAAAAAAAAAgQFBgYJCw0MCwoIBgUEBAMBAQcNDwwJCAgIBwYFBQQDAgEDBwoJBwUEAgIDBAQDAg==" + }, + "messageContextInfo": { + "deviceListMetadata": { + "senderKeyHash": "UhZcO5WXFcFggQ==", + "senderTimestamp": "1726696358", + "recipientKeyHash": "E/D9jrPfGn2rEA==", + "recipientTimestamp": "1727136227" + }, + "deviceListMetadataVersion": 2, + "messageSecret": "ljBBOY5spWVvZZGbnbL9d7iJ7up+ggxGsKkd2Qh8zn4=" + }, + "mediaUrl": "https://databases-minio.hzwlsv.easypanel.host/evolution-01/evolution-api/3451597b-7332-4b26-973d-9078af3ad9d6/554488581702%40s.whatsapp.net/audioMessage/3AAB25EE1C6D0D08CD93.oga?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=OaBCHYCxI0fRaFYA2uop%2F20241002%2Feu-west-3%2Fs3%2Faws4_request&X-Amz-Date=20241002T234746Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=9fe6bfe1dc45325107e44c62c0217e25d84d47d8dd43aab2f90a04cbef2b022c" + }, + "contextInfo": null, + "messageType": "audioMessage", + "messageTimestamp": 1727912866, + "instanceId": "3451597b-7332-4b26-973d-9078af3ad9d6", + "source": "ios" + }, + "destination": "https://applications-n8n-webhook.hzwlsv.easypanel.host/webhook/evolution/router", + "date_time": "2024-10-02T20:47:46.224Z", + "sender": "554498600066@s.whatsapp.net", + "server_url": "https://applications-evolution-01.hzwlsv.easypanel.host", + "apikey": "FDF95E3733C6-436E-9B0E-1BFAC2BA4319" + }, + "webhookUrl": "https://applications-n8n-webhook.hzwlsv.easypanel.host/webhook-test/evolution-live", + "executionMode": "test" + } + } + ] + }, + "connections": { + "normalizacao": { + "main": [ + [ + { + "node": "Switch Content Type", + "type": "main", + "index": 0 + } + ] + ] + }, + "IMAGEM COM LEGENDA": { + "main": [ + [ + { + "node": "normalizacao", + "type": "main", + "index": 0 + } + ] + ] + }, + "Get audio base64 EvolutionAPI": { + "main": [ + [ + { + "node": "Convert to File", + "type": "main", + "index": 0 + } + ] + ] + }, + "Convert to File": { + "main": [ + [ + { + "node": "OpenAI", + "type": "main", + "index": 0 + } + ] + ] + } + }, + "active": true, + "settings": { + "executionOrder": "v1" + }, + "versionId": "08975c92-b09a-4dcc-94f6-8d607a6b8cd2", + "meta": { + "templateCredsSetupCompleted": true, + "instanceId": "2ad20c637f548d7b1e09cbae0383c6644aca87b4f0fe8deda2de937f77c2be79" + }, + "id": "lLJPWiYlBv6zE0nd", + "tags": [] +} \ No newline at end of file diff --git a/Live 02-10-2024 Tratamento de Mensagens Recebidas na Evolution API/README.md b/Live 02-10-2024 Tratamento de Mensagens Recebidas na Evolution API/README.md new file mode 100644 index 0000000..a9f3250 --- /dev/null +++ b/Live 02-10-2024 Tratamento de Mensagens Recebidas na Evolution API/README.md @@ -0,0 +1,19 @@ +# Tratamento de Mensagens Recebidas na Evolution API com n8n + +Este repositório contém os fluxos desenvolvidos durante a live [Tratamento de Mensagens Recebidas na Evolution API - Texto, Imagem, Áudio e Mais com n8n](https://www.youtube.com/live/94d6hRRjY4g). A live mostra como configurar fluxos no **n8n** para tratar automaticamente diferentes tipos de mensagens recebidas pela **Evolution API**, incluindo textos, imagens, áudios, vídeos e documentos. + +## Descrição + +Durante a live, aprendemos a integrar a **Evolution API** ao **n8n** para processar conteúdos multimídia recebidos via API de forma automatizada. A configuração foi feita utilizando **webhooks** para tratar diferentes formatos de mensagem. + +## O que você vai aprender + +- **Configurar um fluxo automatizado** para receber e processar mensagens multimídia pela Evolution API. +- **Usar o n8n** para organizar e tratar dados de textos, imagens, áudios, vídeos e documentos. +- **Criar webhooks no n8n** para cada tipo de mensagem, permitindo personalização no processamento de cada mídia. + +## Como usar este repositório + +1. **Clonar o Repositório** + + Baixe o Json do fluxo escolhido e importe no N8N. \ No newline at end of file