Skip to main content
Glama

Uazapi WhatsApp MCP Server

by pabloweyne
workflow-scheduler.json3.92 kB
{ "name": "UAZAPI Scheduler - Mensagens Agendadas", "nodes": [ { "parameters": { "rule": { "interval": [{ "field": "minutes", "minutesInterval": 1 }] } }, "id": "cron", "name": "A cada minuto", "type": "n8n-nodes-base.scheduleTrigger", "typeVersion": 1.2, "position": [240, 300] }, { "parameters": { "operation": "get", "key": "uazapi:schedule" }, "id": "redis-get", "name": "Buscar Agendamentos", "type": "n8n-nodes-base.redis", "typeVersion": 1, "position": [460, 300], "credentials": { "redis": { "id": "REDIS_CREDENTIAL_ID", "name": "Redis" } } }, { "parameters": { "jsCode": "const now = new Date();\nlet schedules = [];\n\ntry {\n const data = $input.first().json;\n if (data && typeof data === 'string') {\n schedules = JSON.parse(data);\n } else if (Array.isArray(data)) {\n schedules = data;\n } else if (data?.value) {\n schedules = JSON.parse(data.value);\n }\n} catch (e) {\n return [];\n}\n\nif (!Array.isArray(schedules)) schedules = [schedules].filter(Boolean);\n\n// Filtrar mensagens que devem ser enviadas agora\nconst toSend = [];\nconst toKeep = [];\n\nschedules.forEach(sched => {\n if (!sched || sched.status === 'enviado') return;\n \n try {\n const schedDate = new Date(sched.data_hora);\n if (schedDate <= now) {\n toSend.push({ ...sched, status: 'enviando' });\n } else {\n toKeep.push(sched);\n }\n } catch (e) {\n toKeep.push(sched);\n }\n});\n\nif (toSend.length === 0) {\n return []; // Nada para enviar\n}\n\nreturn toSend.map(s => ({\n json: {\n ...s,\n toKeep: toKeep,\n toKeepJson: JSON.stringify(toKeep)\n }\n}));" }, "id": "filter-ready", "name": "Filtrar Prontos", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [680, 300] }, { "parameters": { "method": "POST", "url": "=https://api.uazapi.com/instances/{{ $env.UAZAPI_INSTANCE_ID }}/messages/send/text", "authentication": "genericCredentialType", "genericAuthType": "httpHeaderAuth", "sendBody": true, "specifyBody": "json", "jsonBody": "={ \"phone\": \"{{ $json.numero }}\", \"message\": \"{{ $json.mensagem }}\" }" }, "id": "send-scheduled", "name": "Enviar Agendada", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [900, 300], "credentials": { "httpHeaderAuth": { "id": "UAZAPI_CREDENTIAL_ID", "name": "UAZAPI Auth" } } }, { "parameters": { "operation": "set", "key": "uazapi:schedule", "value": "={{ $('Filtrar Prontos').first().json.toKeepJson }}", "expire": false }, "id": "redis-update", "name": "Atualizar Lista", "type": "n8n-nodes-base.redis", "typeVersion": 1, "position": [1120, 300], "credentials": { "redis": { "id": "REDIS_CREDENTIAL_ID", "name": "Redis" } } }, { "parameters": { "jsCode": "const sent = $('Enviar Agendada').all();\nreturn [{ json: { enviadas: sent.length, timestamp: new Date().toISOString() } }];" }, "id": "log", "name": "Log", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [1340, 300] } ], "connections": { "A cada minuto": { "main": [[{ "node": "Buscar Agendamentos", "type": "main", "index": 0 }]] }, "Buscar Agendamentos": { "main": [[{ "node": "Filtrar Prontos", "type": "main", "index": 0 }]] }, "Filtrar Prontos": { "main": [[{ "node": "Enviar Agendada", "type": "main", "index": 0 }]] }, "Enviar Agendada": { "main": [[{ "node": "Atualizar Lista", "type": "main", "index": 0 }]] }, "Atualizar Lista": { "main": [[{ "node": "Log", "type": "main", "index": 0 }]] } }, "settings": { "executionOrder": "v1" } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pabloweyne/uazapi-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server