Adiciona ao repo os scripts e configs reais do motor que estavam fora do git,
e remove arquivos legados/abandonados.
Adicionados (30):
- scripts/docker-compose.m5.yml, openwa-compose.yml, minio-compose.yml
- scripts/openwa.env (sem secrets)
- scripts/{entrypoint,saleor-entrypoint,saleor-start}.sh
- scripts/{chatwoot-setup,compliance-check,health-check,resumo-diario}.sh
- scripts/{insert_workflow,telegram_user_login,telegram_user_monitor}.py
- scripts/requirements.txt
- scripts/traefik-conf/{traefik.yml,dynamic-config.yml}
- scripts/compliance/, scripts/calculators/, scripts/backups/
- scripts/{README.md,README-INSTALL.md,WHATSAPP-SETUP.md,.gitignore}
- .gitignore (atualizado)
Removidos (ja' em backup/untracked-lixo-2026-07-06/):
- agents/, crm/, hermes_skills_backup/, api-complive/, docs/ (legados)
- scripts/{wrapper.py,wrapper.sh}
- scripts/docker-compose.m5.yml.backup, traefik-conf/routes.yml.bak2
- scripts/saleor-media/RSA_*.{bak,old_*}
- scripts/n8n-workflows/webhook-saleor.json.bak2
- scripts/backups/20260622_0300/saleor_db.sql
- integracao_completa.sh, monitoramento_vps.sh
- ruvector.db (vazio)
Ignorados via .gitignore:
- vault/ (Obsidian KB)
- skills/ (duplicado de ~/.hermes/skills/)
- scripts/{saleor-media,traefik-acme,yt-pub-livesx,minio,n8n-workflows,skills}/
- scripts/backups/2026*_*/
111 lines
3.6 KiB
Python
111 lines
3.6 KiB
Python
#!/usr/bin/env python3
|
|
import json
|
|
import uuid
|
|
import psycopg2
|
|
|
|
WORKFLOW_ID = "fa489bed-a0ac-4856-a38e-e78bed2adf9d"
|
|
WEBHOOK_ID = "whatsapp-messages"
|
|
PROJECT_ID = "NHIYHwVpHURSGRFV"
|
|
|
|
nodes = [
|
|
{
|
|
"parameters": {"httpMethod": "POST", "path": "whatsapp-messages", "responseMode": "lastNode", "options": {}},
|
|
"id": "wh1", "name": "Webhook WhatsApp", "type": "n8n-nodes-base.webhook",
|
|
"typeVersion": 2, "position": [250, 300], "webhookId": WEBHOOK_ID
|
|
},
|
|
{
|
|
"parameters": {"jsCode": "const d=$input.item.json;const e=d.event||'';const m=d.data||{};const t=m.hasMedia?'media':m.body?'text':e.includes('session')?'session':'other';return[{json:{...d,messageType:t}}];"},
|
|
"id": "cl1", "name": "Classificar Mensagem", "type": "n8n-nodes-base.code",
|
|
"typeVersion": 2, "position": [500, 300]
|
|
},
|
|
{
|
|
"parameters": {"jsCode": "console.log(JSON.stringify($input.item.json));return $input.all();"},
|
|
"id": "db1", "name": "Log Mensagem", "type": "n8n-nodes-base.code",
|
|
"typeVersion": 2, "position": [750, 300]
|
|
},
|
|
{
|
|
"parameters": {"jsCode": "return[{json:{received:true,timestamp:new Date().toISOString()}}];"},
|
|
"id": "ok1", "name": "Responder 200", "type": "n8n-nodes-base.code",
|
|
"typeVersion": 2, "position": [1000, 300]
|
|
}
|
|
]
|
|
|
|
connections = {
|
|
"Webhook WhatsApp": {"main": [[{"node": "Classificar Mensagem", "type": "main", "index": 0}]]},
|
|
"Classificar Mensagem": {"main": [[{"node": "Log Mensagem", "type": "main", "index": 0}]]},
|
|
"Log Mensagem": {"main": [[{"node": "Responder 200", "type": "main", "index": 0}]]}
|
|
}
|
|
|
|
settings = {"executionOrder": "v1", "saveManualExecutions": True, "callerPolicy": "workflowsFromSameOwner"}
|
|
|
|
conn = psycopg2.connect(
|
|
host="m5_postgres",
|
|
dbname="n8n",
|
|
user="m5user",
|
|
password="YXnJMMqAZ5uZrFj2lMo_AnhEmQq4uVoCfOuXaG7pU0Y",
|
|
port=5432
|
|
)
|
|
cur = conn.cursor()
|
|
|
|
# Insert workflow
|
|
cur.execute("""
|
|
INSERT INTO workflow_entity (
|
|
name, active, nodes, connections, settings, staticData, pinData,
|
|
versionId, triggerCount, id, meta, parentFolderId, isArchived, versionCounter,
|
|
description, activeVersionId, createdAt, updatedAt
|
|
) VALUES (
|
|
%s, %s, %s, %s, %s, NULL, NULL,
|
|
%s, %s, %s, NULL, NULL, %s, %s,
|
|
%s, NULL, NOW(), NOW()
|
|
)
|
|
ON CONFLICT (id) DO UPDATE SET
|
|
name = EXCLUDED.name,
|
|
active = EXCLUDED.active,
|
|
nodes = EXCLUDED.nodes,
|
|
connections = EXCLUDED.connections,
|
|
settings = EXCLUDED.settings,
|
|
updatedAt = NOW()
|
|
""", (
|
|
"WhatsApp Messages - OpenWA",
|
|
True,
|
|
json.dumps(nodes),
|
|
json.dumps(connections),
|
|
json.dumps(settings),
|
|
"1", 1, WORKFLOW_ID,
|
|
False, 1,
|
|
"Recebe webhooks do OpenWA e salva no banco"
|
|
))
|
|
|
|
# Insert webhook entity
|
|
wh_entity_id = str(uuid.uuid4())
|
|
cur.execute("""
|
|
INSERT INTO webhook_entity (
|
|
id, webhookId, workflowId, method, path, node, conditions, position,
|
|
retries, timeout, keywords, redactUrl, redactHeaders, redactBody, createdAt
|
|
) VALUES (
|
|
%s, %s, %s, %s, %s, %s, NULL, %s,
|
|
3, NULL, NULL, false, NULL, false, NOW()
|
|
)
|
|
ON CONFLICT (webhookId) DO UPDATE SET
|
|
workflowId = EXCLUDED.workflowId,
|
|
updatedAt = NOW()
|
|
""", (
|
|
wh_entity_id, WEBHOOK_ID, WORKFLOW_ID,
|
|
"POST", "/webhook/whatsapp-messages", "Webhook WhatsApp",
|
|
json.dumps([250, 300])
|
|
))
|
|
|
|
# Insert shared_workflow
|
|
cur.execute("""
|
|
INSERT INTO shared_workflow (workflowId, projectId, role, createdAt, updatedAt)
|
|
VALUES (%s, %s, %s, NOW(), NOW())
|
|
ON CONFLICT (workflowId, projectId) DO NOTHING
|
|
""", (WORKFLOW_ID, PROJECT_ID, "workflow"))
|
|
|
|
conn.commit()
|
|
cur.close()
|
|
conn.close()
|
|
print(f"Workflow criado: {WORKFLOW_ID}")
|
|
print(f"Webhook ID: {WEBHOOK_ID}")
|
|
print("Pronto!")
|