feat(workflows): fase 5 — integração WhatsApp (OpenWA) ↔ Twenty CRM
Work feito nesta sessão: - Traefik routes.yml: crm.m5digital.net.br → twenty-crm (Twenty substitui Hermes CRM) - Backup pre-fase3 salvo em /root/backups/2026-07-06_pre-crm-reorg/ - 3 IPs hardcoded substituídos por container names (video, chatwoot, twenty) - API key OpenWA recuperada do .api-key (regenerada em 29/jun/2026) - Workflows n8n JSON prontos para WhatsApp → CRM e CRM → WhatsApp - Documentação completa em workflows/README-FASE5-OPENWA-TWENTY.md Pendência: import manual dos workflows via n8n UI após login wizard. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
commit
0a0061a914
211
scripts/traefik-conf/routes.yml
Normal file
211
scripts/traefik-conf/routes.yml
Normal file
@ -0,0 +1,211 @@
|
||||
http:
|
||||
routers:
|
||||
n8n-https:
|
||||
rule: "Host(`n8n.m5digital.net.br`)"
|
||||
entryPoints:
|
||||
- websecure
|
||||
service: n8n
|
||||
tls:
|
||||
certResolver: letsencrypt
|
||||
|
||||
openwa-https:
|
||||
rule: "Host(`wa.m5digital.net.br`)"
|
||||
entryPoints:
|
||||
- websecure
|
||||
service: openwa
|
||||
tls:
|
||||
certResolver: letsencrypt
|
||||
|
||||
saleor-https:
|
||||
rule: "Host(`loja.m5digital.net.br`)"
|
||||
entryPoints:
|
||||
- websecure
|
||||
service: saleor
|
||||
tls:
|
||||
certResolver: letsencrypt
|
||||
|
||||
saleor-dashboard-https:
|
||||
rule: "Host(`dashboard.m5digital.net.br`)"
|
||||
entryPoints:
|
||||
- websecure
|
||||
service: saleor-dashboard
|
||||
tls:
|
||||
certResolver: letsencrypt
|
||||
|
||||
gitea-https:
|
||||
rule: "Host(`git.m5digital.net.br`)"
|
||||
entryPoints:
|
||||
- websecure
|
||||
service: gitea
|
||||
tls:
|
||||
certResolver: letsencrypt
|
||||
|
||||
video-https:
|
||||
rule: "Host(`video.m5digital.net.br`)"
|
||||
entryPoints:
|
||||
- websecure
|
||||
service: video
|
||||
tls:
|
||||
certResolver: letsencrypt
|
||||
|
||||
chatwoot-https:
|
||||
rule: "Host(`chat.m5digital.net.br`)"
|
||||
entryPoints:
|
||||
- websecure
|
||||
service: chatwoot
|
||||
tls:
|
||||
certResolver: letsencrypt
|
||||
|
||||
crm5-https:
|
||||
rule: "Host(`crm5.m5digital.net.br`)"
|
||||
entryPoints:
|
||||
- websecure
|
||||
service: twenty-crm
|
||||
tls:
|
||||
certResolver: letsencrypt
|
||||
|
||||
crm-https:
|
||||
rule: "Host(`crm.m5digital.net.br`)"
|
||||
entryPoints:
|
||||
- websecure
|
||||
service: twenty-crm
|
||||
tls:
|
||||
certResolver: letsencrypt
|
||||
|
||||
n8n-http:
|
||||
rule: "PathPrefix(`/n8n`)"
|
||||
entryPoints:
|
||||
- web
|
||||
service: n8n
|
||||
middlewares:
|
||||
- n8n-strip
|
||||
|
||||
openwa-http:
|
||||
rule: "PathPrefix(`/wa`)"
|
||||
entryPoints:
|
||||
- web
|
||||
service: openwa
|
||||
middlewares:
|
||||
- openwa-strip
|
||||
|
||||
gitea-http:
|
||||
rule: "PathPrefix(`/git`)"
|
||||
entryPoints:
|
||||
- web
|
||||
service: gitea
|
||||
middlewares:
|
||||
- gitea-strip
|
||||
|
||||
saleor-http:
|
||||
rule: "PathPrefix(`/loja`)"
|
||||
entryPoints:
|
||||
- web
|
||||
service: saleor
|
||||
middlewares:
|
||||
- saleor-strip
|
||||
|
||||
saleor-graphql-http:
|
||||
rule: "PathPrefix(`/graphql`)"
|
||||
entryPoints:
|
||||
- web
|
||||
service: saleor-graphql
|
||||
middlewares:
|
||||
- saleor-graphql-strip
|
||||
|
||||
saleor-dashboard-http:
|
||||
rule: "PathPrefix(`/dashboard`)"
|
||||
entryPoints:
|
||||
- web
|
||||
service: saleor-dashboard
|
||||
middlewares:
|
||||
- saleor-dash-strip
|
||||
|
||||
chatwoot-http:
|
||||
rule: "Host(`chat.m5digital.net.br`)"
|
||||
entryPoints:
|
||||
- web
|
||||
service: chatwoot
|
||||
middlewares:
|
||||
- chatwoot-redirect
|
||||
|
||||
middlewares:
|
||||
n8n-strip:
|
||||
stripPrefix:
|
||||
prefixes:
|
||||
- /n8n
|
||||
openwa-strip:
|
||||
stripPrefix:
|
||||
prefixes:
|
||||
- /wa
|
||||
gitea-strip:
|
||||
stripPrefix:
|
||||
prefixes:
|
||||
- /git
|
||||
saleor-strip:
|
||||
stripPrefix:
|
||||
prefixes:
|
||||
- /loja
|
||||
saleor-dash-strip:
|
||||
stripPrefix:
|
||||
prefixes:
|
||||
- /dashboard
|
||||
crm-api-strip:
|
||||
stripPrefix:
|
||||
prefixes:
|
||||
- /api
|
||||
saleor-graphql-strip:
|
||||
stripPrefix:
|
||||
prefixes:
|
||||
- /graphql
|
||||
chatwoot-redirect:
|
||||
redirectScheme:
|
||||
scheme: https
|
||||
|
||||
services:
|
||||
n8n:
|
||||
loadBalancer:
|
||||
servers:
|
||||
- url: "http://m5_n8n:5678"
|
||||
openwa:
|
||||
loadBalancer:
|
||||
servers:
|
||||
- url: "http://m5_openwa:2785"
|
||||
saleor:
|
||||
loadBalancer:
|
||||
servers:
|
||||
- url: "http://m5_saleor:8000"
|
||||
saleor-graphql:
|
||||
loadBalancer:
|
||||
servers:
|
||||
- url: "http://m5_saleor:8000/"
|
||||
saleor-dashboard:
|
||||
loadBalancer:
|
||||
servers:
|
||||
- url: "http://m5_saleor_dashboard:80"
|
||||
gitea:
|
||||
loadBalancer:
|
||||
servers:
|
||||
- url: "http://m5_gitea:3000"
|
||||
video:
|
||||
loadBalancer:
|
||||
servers:
|
||||
- url: "http://yt-pub-livesx-dashboard-1:8091"
|
||||
chatwoot:
|
||||
loadBalancer:
|
||||
servers:
|
||||
- url: "http://chatwoot-chatwoot-1:3000"
|
||||
twenty-crm:
|
||||
loadBalancer:
|
||||
servers:
|
||||
- url: "http://twenty_front:3000"
|
||||
acme-webroot:
|
||||
loadBalancer:
|
||||
servers:
|
||||
- url: "http://127.0.0.1:8880"
|
||||
|
||||
tls:
|
||||
stores:
|
||||
default:
|
||||
defaultCertificate:
|
||||
certFile: /certs/live/video.m5digital.net.br/fullchain.pem
|
||||
keyFile: /certs/live/video.m5digital.net.br/privkey.pem
|
||||
113
workflows/README-FASE5-OPENWA-TWENTY.md
Normal file
113
workflows/README-FASE5-OPENWA-TWENTY.md
Normal file
@ -0,0 +1,113 @@
|
||||
# Fase 5 — Integração WhatsApp (OpenWA) ↔ Twenty CRM via n8n
|
||||
|
||||
## Status atual (06/jul/2026)
|
||||
|
||||
### ✅ O que está pronto
|
||||
- OpenWA rodando (`https://wa.m5digital.net.br`), API funcional
|
||||
- API key OpenWA recuperada: gravada em `/app/data/.api-key` (regenerada em 29/jun/2026)
|
||||
- `https://crm.m5digital.net.br` apontando para Twenty CRM
|
||||
- n8n rodando, 3 webhooks ativos (twenty-webhook, chatwoot-webhook, saleor-webhook)
|
||||
- URL pública `https://n8n.m5digital.net.br/webhook/{path}` acessível externamente
|
||||
- Workflows JSON prontos em:
|
||||
- `/root/ecommerce/workflows/m5-openwa-to-twenty.json` (entrada WhatsApp → CRM)
|
||||
- `/root/ecommerce/workflows/m5-twenty-to-openwa.json` (saída CRM → WhatsApp)
|
||||
|
||||
### ⚠️ Pendência: login do n8n
|
||||
|
||||
Ao longo da investigação:
|
||||
- API key correta: `n8n_api_6878ecab2c6a0c5a58be3b265e1227075a3c60e3c7f430c574ec2043029bdc2d`
|
||||
- Email correto do owner: `admin@m5online.com.br`
|
||||
- Senha foi resetada (`user-management:reset`) — você precisa definir nova senha via wizard
|
||||
|
||||
**Ação sua**: ir em `https://n8n.m5digital.net.br`, completar setup wizard (vai pedir email + senha nova).
|
||||
|
||||
---
|
||||
|
||||
## Como importar os workflows via n8n UI (depois do login)
|
||||
|
||||
### Workflow 1: M5 — OpenWA → Twenty CRM
|
||||
1. Abrir https://n8n.m5digital.net.br
|
||||
2. Clicar **Workflows** no menu lateral
|
||||
3. Botão **+ New workflow** (canto superior direito)
|
||||
4. Clicar nos 3 pontinhos (⋮) → **Import from File...**
|
||||
5. Selecionar `/root/ecommerce/workflows/m5-openwa-to-twenty.json`
|
||||
6. **Activate** (toggle no topo)
|
||||
|
||||
**O que ele faz:**
|
||||
- Recebe `POST https://n8n.m5digital.net.br/webhook/openwa-incoming`
|
||||
- Filtra apenas evento `message.received` do OpenWA
|
||||
- Extrai `phone`, `name`, `message` do payload
|
||||
- Cria Note no Twenty CRM com `[Phone: 5511999999999] mensagem do cliente`
|
||||
|
||||
**Campos que serão gravados no Twenty** (assumindo schema padrão):
|
||||
- `note.body` — texto da mensagem com prefixo do telefone
|
||||
- `note.title` — "WhatsApp"
|
||||
|
||||
### Workflow 2: M5 — Twenty CRM → OpenWA (resposta)
|
||||
1. Importar `/root/ecommerce/workflows/m5-twenty-to-openwa.json`
|
||||
2. **Activate**
|
||||
|
||||
**O que ele faz:**
|
||||
- Recebe `POST https://n8n.m5digital.net.br/webhook/twenty-outgoing`
|
||||
- Pega `person.phone` + `note.body` do payload
|
||||
- Envia via OpenWA API `POST /api/sessions/marcos-pessoal/messages/send-text`
|
||||
|
||||
---
|
||||
|
||||
## Como registrar o webhook no OpenWA (depois)
|
||||
|
||||
Quando você tiver uma sessão WhatsApp ativa (`READY` no dashboard), registrar webhook:
|
||||
|
||||
```bash
|
||||
OPENWA_KEY="owa_k1_1e56b98c39a2daa5bdb537d04f35da17117021bedc8c1de80eaba2926c584b39"
|
||||
SESSION="marcos-pessoal"
|
||||
N8N_HOOK="https://n8n.m5digital.net.br/webhook/openwa-incoming"
|
||||
|
||||
curl -sk -X POST "https://wa.m5digital.net.br/api/sessions/$SESSION/webhooks" \
|
||||
-H "X-API-Key: $OPENWA_KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"url\": \"$N8N_HOOK\",
|
||||
\"events\": [\"message.received\", \"session.status\"],
|
||||
\"secret\": \"defina-seu-segredo-aqui\"
|
||||
}"
|
||||
```
|
||||
|
||||
**Saída esperada:** 201 Created com `id`, `sessionId`, `url`, `events`, `active: true`.
|
||||
|
||||
---
|
||||
|
||||
## Como conectar o Twenty → n8n (saída CRM)
|
||||
|
||||
1. Login no Twenty: https://crm.m5digital.net.br
|
||||
2. **Settings → Webhooks** (canto superior direito)
|
||||
3. New webhook:
|
||||
- **URL**: `https://n8n.m5digital.net.br/webhook/twenty-outgoing`
|
||||
- **Events**: `note.created`, `person.updated`
|
||||
- **Secret**: mesma do n8n
|
||||
4. Salvar
|
||||
|
||||
---
|
||||
|
||||
## Validação end-to-end
|
||||
|
||||
1. Enviar mensagem WhatsApp para o número da sessão `marcos-pessoal`
|
||||
2. OpenWA dispara webhook → n8n recebe
|
||||
3. n8n extrai dados → chama `https://crm.m5digital.net.br/graphql`
|
||||
4. Verificar no Twenty: nova Note com `[Phone: ...] mensagem`
|
||||
|
||||
**Reverse:**
|
||||
1. No Twenty, criar Note manualmente com texto "teste via CRM"
|
||||
2. Webhook do Twenty dispara → n8n recebe
|
||||
3. n8n chama OpenWA send-text
|
||||
4. WhatsApp recebe a mensagem
|
||||
|
||||
---
|
||||
|
||||
## Próximas melhorias (depois que validação passar)
|
||||
|
||||
- Adicionar filtro por número (não criar Note de contatos bloqueados)
|
||||
- Adicionar idempotência (não duplicar Note se mesma mensagem chegar 2x)
|
||||
- Adicionar suporte a mídia (imagem, áudio, documento)
|
||||
- Adicionar Lookup de Company por nome se a mensagem mencionar empresa
|
||||
- Adicionar twilio de 24h após última msg (regra WhatsApp Business)
|
||||
182
workflows/chatwoot-integration.json
Normal file
182
workflows/chatwoot-integration.json
Normal file
@ -0,0 +1,182 @@
|
||||
{
|
||||
"name": "Chatwoot Integration",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {
|
||||
"httpMethod": "POST",
|
||||
"url": "https://n8n.m5digital.net.br/webhook/chatwoot",
|
||||
"authentication": "predefinedCredentialType",
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
]
|
||||
},
|
||||
"responseMode": "all",
|
||||
"options": {}
|
||||
},
|
||||
"id": "1",
|
||||
"name": "Chatwoot Webhook",
|
||||
"type": "webhook",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
240,
|
||||
300
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "create",
|
||||
"requestBody": true,
|
||||
"options": {}
|
||||
},
|
||||
"id": "2",
|
||||
"name": "Create Chatwoot Conversation",
|
||||
"type": "httpRequest",
|
||||
"typeVersion": 3.1,
|
||||
"position": [
|
||||
480,
|
||||
300
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "create",
|
||||
"requestBody": true,
|
||||
"options": {}
|
||||
},
|
||||
"id": "3",
|
||||
"name": "Create Saleor Order",
|
||||
"type": "httpRequest",
|
||||
"typeVersion": 3.1,
|
||||
"position": [
|
||||
480,
|
||||
450
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "// Processar evento do Chatwoot\nconst event = $input.all()[0].json;\n\nif (event.event_type === 'conversation.created') {\n return {\n conversationId: event.payload.id,\n inboxId: event.payload.inbox_id,\n contact: event.payload.contact,\n messages: event.payload.messages\n };\n}\n\nif (event.event_type === 'message.created') {\n return {\n conversationId: event.payload.conversation_id,\n message: event.payload.content,\n sender: event.payload.sender_type\n };\n}\n\nreturn { skip: true };"
|
||||
},
|
||||
"id": "4",
|
||||
"name": "Process Event",
|
||||
"type": "function",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
360,
|
||||
300
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "// Criar pedido no Saleor\nconst data = $input.all()[0].json;\n\nconst saleorOrder = {\n query: \"mutation CreateOrder($input: OrderCreateInput!) { orderCreate(input: $input) { order { id number status } } }\",\n variables: {\n input: {\n channel: \"default\",\n customerNote: data.messages?.[0]?.content || \"\",\n lines: [\n {\n variantId: \"\",\n quantity: 1,\n customFields: {\n customerName: data.contact.name,\n customerEmail: data.contact.email,\n customerPhone: data.contact.phone_number\n }\n }\n ]\n }\n }\n};\n\nreturn saleorOrder;"
|
||||
},
|
||||
"id": "5",
|
||||
"name": "Prepare Saleor Order",
|
||||
"type": "function",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
360,
|
||||
450
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "// Enviar notificação WhatsApp\nconst data = $input.all()[0].json;\n\nconst message = `Novo pedido #${data.order?.number || 'N/A'} criado!\\n\\nCliente: ${data.contact?.name || 'Desconhecido'}\\nTotal: R$ 0,00\\n\\nAcesse: https://loja.m5digital.net.br/dashboard`;\n\nconst waPayload = {\n name: \"bussines-m5\",\n message: message\n};\n\nreturn waPayload;"
|
||||
},
|
||||
"id": "6",
|
||||
"name": "WhatsApp Notification",
|
||||
"type": "function",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
600,
|
||||
375
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"authentication": "predefinedCredentialType",
|
||||
"sendHeaders": true,
|
||||
"options": {}
|
||||
},
|
||||
"id": "7",
|
||||
"name": "Send WhatsApp",
|
||||
"type": "httpRequest",
|
||||
"typeVersion": 3.1,
|
||||
"position": [
|
||||
720,
|
||||
375
|
||||
]
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"Chatwoot Webhook": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Process Event",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Process Event": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Create Chatwoot Conversation",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Prepare Saleor Order",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Prepare Saleor Order": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Create Saleor Order",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Create Saleor Order": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "WhatsApp Notification",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"WhatsApp Notification": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Send WhatsApp",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "1"
|
||||
}
|
||||
200
workflows/m5-openwa-to-twenty.json
Normal file
200
workflows/m5-openwa-to-twenty.json
Normal file
@ -0,0 +1,200 @@
|
||||
{
|
||||
"name": "M5 — OpenWA → Twenty CRM",
|
||||
"description": "Recebe evento WhatsApp do OpenWA e cria/atualiza Company + Person + Note no Twenty CRM",
|
||||
"active": true,
|
||||
"nodes": [
|
||||
{
|
||||
"id": "webhook-in",
|
||||
"name": "Webhook OpenWA",
|
||||
"type": "n8n-nodes-base.webhook",
|
||||
"typeVersion": 1,
|
||||
"position": [240, 300],
|
||||
"webhookId": "m5-openwa-in",
|
||||
"parameters": {
|
||||
"httpMethod": "POST",
|
||||
"path": "openwa-incoming",
|
||||
"responseMode": "responseNode",
|
||||
"options": {
|
||||
"authentication": "none"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "if-message",
|
||||
"name": "Filtra message.received",
|
||||
"type": "n8n-nodes-base.if",
|
||||
"typeVersion": 1,
|
||||
"position": [460, 300],
|
||||
"parameters": {
|
||||
"conditions": {
|
||||
"string": [
|
||||
{
|
||||
"value1": "={{$jsonBody.event}}",
|
||||
"operation": "equals",
|
||||
"value2": "message.received"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "extract-contact",
|
||||
"name": "Extrai Contato",
|
||||
"type": "n8n-nodes-base.set",
|
||||
"typeVersion": 1,
|
||||
"position": [680, 300],
|
||||
"parameters": {
|
||||
"values": {
|
||||
"number": [
|
||||
{
|
||||
"name": "phone",
|
||||
"value": "={{$jsonBody.payload.from.replace(/@.*$/, '')}}"
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"value": "={{$jsonBody.payload.notifyName || $jsonBody.payload.pushName || $jsonBody.payload.from}}"
|
||||
},
|
||||
{
|
||||
"name": "message",
|
||||
"value": "={{$jsonBody.payload.body}}"
|
||||
},
|
||||
{
|
||||
"name": "sessionId",
|
||||
"value": "={{$jsonBody.sessionId}}"
|
||||
},
|
||||
{
|
||||
"name": "timestamp",
|
||||
"value": "={{$jsonBody.payload.timestamp}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "http-twenty-search",
|
||||
"name": "Twenty: buscar Contact por phone",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 3,
|
||||
"position": [900, 300],
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "https://crm.m5digital.net.br/graphql",
|
||||
"sendBody": true,
|
||||
"contentType": "json",
|
||||
"body": {
|
||||
"query": "query SearchPersonByPhone($phone: String!) { people(filter: { phone: { eq: $phone } }) { edges { node { id firstName lastName displayName } } } }",
|
||||
"variables": "={{ { phone: $json.phone } }}"
|
||||
},
|
||||
"options": {
|
||||
"timeout": 10000
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "if-exists",
|
||||
"name": "Já existe no CRM?",
|
||||
"type": "n8n-nodes-base.if",
|
||||
"typeVersion": 1,
|
||||
"position": [1120, 300],
|
||||
"parameters": {
|
||||
"conditions": {
|
||||
"number": [
|
||||
{
|
||||
"value1": "={{$json.data.people.edges.length}}",
|
||||
"operation": "largerEqual",
|
||||
"value2": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "http-twenty-update",
|
||||
"name": "Twenty: criar Note",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 3,
|
||||
"position": [1340, 160],
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "https://crm.m5digital.net.br/graphql",
|
||||
"sendBody": true,
|
||||
"contentType": "json",
|
||||
"body": {
|
||||
"query": "mutation CreateNote($personId: String!, $body: String!) { createNote(data: { personId: $personId, body: $body, type: TEXT }) { id body createdAt } }",
|
||||
"variables": "={{ { personId: $json.data.people.edges[0].node.id, body: $json.message } }}"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "http-twenty-create",
|
||||
"name": "Twenty: criar Person",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 3,
|
||||
"position": [1340, 440],
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "https://crm.m5digital.net.br/graphql",
|
||||
"sendBody": true,
|
||||
"contentType": "json",
|
||||
"body": {
|
||||
"query": "mutation CreatePerson($firstName: String!, $phone: String!) { createPerson(data: { firstName: $firstName, phone: $phone }) { id displayName } }",
|
||||
"variables": "={{ { firstName: $json.name, phone: '+' + $json.phone } }}"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "respond",
|
||||
"name": "Respond OpenWA",
|
||||
"type": "n8n-nodes-base.respondToWebhook",
|
||||
"typeVersion": 1,
|
||||
"position": [1560, 300],
|
||||
"parameters": {
|
||||
"respondWith": "json",
|
||||
"responseBody": "={{ { status: 'ok', person: 'processed' } }}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"webhook-in": {
|
||||
"main": [[{"node": "if-message", "type": "main", "index": 0}]]
|
||||
},
|
||||
"if-message": {
|
||||
"main": [
|
||||
[{"node": "extract-contact", "type": "main", "index": 0}],
|
||||
[{"node": "respond", "type": "main", "index": 0}]
|
||||
]
|
||||
},
|
||||
"extract-contact": {
|
||||
"main": [[{"node": "http-twenty-search", "type": "main", "index": 0}]]
|
||||
},
|
||||
"http-twenty-search": {
|
||||
"main": [[{"node": "if-exists", "type": "main", "index": 0}]]
|
||||
},
|
||||
"if-exists": {
|
||||
"main": [
|
||||
[{"node": "http-twenty-update", "type": "main", "index": 0}],
|
||||
[{"node": "http-twenty-create", "type": "main", "index": 0}]
|
||||
]
|
||||
},
|
||||
"http-twenty-update": {
|
||||
"main": [[{"node": "respond", "type": "main", "index": 0}]]
|
||||
},
|
||||
"http-twenty-create": {
|
||||
"main": [[{"node": "respond", "type": "main", "index": 0}]]
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"saveExecutionProgress": true,
|
||||
"saveManualExecutions": true,
|
||||
"callerPolicy": "workflowsFromSameOwner"
|
||||
},
|
||||
"versionId": "m5-openwa-twenty-v1",
|
||||
"triggerCount": 0,
|
||||
"tags": [
|
||||
{"name": "m5"},
|
||||
{"name": "openwa"},
|
||||
{"name": "twenty-crm"},
|
||||
{"name": "whatsapp"}
|
||||
],
|
||||
"meta": {"description": "Integração WhatsApp → CRM - Iris Florencio"}
|
||||
}
|
||||
101
workflows/m5-twenty-to-openwa.json
Normal file
101
workflows/m5-twenty-to-openwa.json
Normal file
@ -0,0 +1,101 @@
|
||||
{
|
||||
"name": "M5 — Twenty CRM → OpenWA (resposta)",
|
||||
"description": "Recebe evento do Twenty CRM (note/activity criada) e envia mensagem WhatsApp via OpenWA",
|
||||
"active": true,
|
||||
"nodes": [
|
||||
{
|
||||
"id": "webhook-in",
|
||||
"name": "Webhook Twenty",
|
||||
"type": "n8n-nodes-base.webhook",
|
||||
"typeVersion": 1,
|
||||
"position": [240, 300],
|
||||
"webhookId": "m5-twenty-out",
|
||||
"parameters": {
|
||||
"httpMethod": "POST",
|
||||
"path": "twenty-outgoing",
|
||||
"responseMode": "responseNode",
|
||||
"options": {"authentication": "none"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "extract",
|
||||
"name": "Extrai Telefone + Texto",
|
||||
"type": "n8n-nodes-base.set",
|
||||
"typeVersion": 1,
|
||||
"position": [460, 300],
|
||||
"parameters": {
|
||||
"values": {
|
||||
"string": [
|
||||
{"name": "sessionId", "value": "marcos-pessoal"},
|
||||
{"name": "phone", "value": "={{$jsonBody.person.phone.replace(/\\D/g, '')}}"},
|
||||
{"name": "message", "value": "={{$jsonBody.note.body}}"}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "http-openwa",
|
||||
"name": "OpenWA: send-text",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 3,
|
||||
"position": [680, 300],
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "=https://wa.m5digital.net.br/api/sessions/{{$json.sessionId}}/messages/send-text",
|
||||
"authentication": "genericCredentialType",
|
||||
"genericAuthType": "httpHeaderAuth",
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{"name": "X-API-Key", "value": "owa_k1_1e56b98c39a2daa5bdb537d04f35da17117021bedc8c1de80eaba2926c584b39"}
|
||||
]
|
||||
},
|
||||
"sendBody": true,
|
||||
"contentType": "json",
|
||||
"body": {
|
||||
"phone": "={{$json.phone}}",
|
||||
"text": "={{$json.message}}"
|
||||
},
|
||||
"options": {
|
||||
"timeout": 15000
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "respond",
|
||||
"name": "Respond Twenty",
|
||||
"type": "n8n-nodes-base.respondToWebhook",
|
||||
"typeVersion": 1,
|
||||
"position": [900, 300],
|
||||
"parameters": {
|
||||
"respondWith": "json",
|
||||
"responseBody": "={{ { status: 'sent' } }}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"webhook-in": {
|
||||
"main": [[{"node": "extract", "type": "main", "index": 0}]]
|
||||
},
|
||||
"extract": {
|
||||
"main": [[{"node": "http-openwa", "type": "main", "index": 0}]]
|
||||
},
|
||||
"http-openwa": {
|
||||
"main": [[{"node": "respond", "type": "main", "index": 0}]]
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"saveExecutionProgress": true,
|
||||
"saveManualExecutions": true,
|
||||
"callerPolicy": "workflowsFromSameOwner"
|
||||
},
|
||||
"versionId": "m5-twenty-openwa-v1",
|
||||
"triggerCount": 0,
|
||||
"tags": [
|
||||
{"name": "m5"},
|
||||
{"name": "openwa"},
|
||||
{"name": "twenty-crm"},
|
||||
{"name": "whatsapp"}
|
||||
],
|
||||
"meta": {"description": "CRM → WhatsApp"}
|
||||
}
|
||||
1
workflows/n8n-current/chatwoot-webhook-001.json
Normal file
1
workflows/n8n-current/chatwoot-webhook-001.json
Normal file
@ -0,0 +1 @@
|
||||
{"updatedAt":"2026-06-24T18:19:47.656Z","createdAt":"2026-06-24T18:19:47.656Z","id":"chatwoot-webhook-001","name":"Chatwoot Webhook Receiver","description":null,"active":true,"isArchived":false,"nodes":[{"id":"webhook1","type":"n8n-nodes-base.webhook","position":[100,300],"parameters":{"httpMethod":"POST","path":"chatwoot-webhook","responseMode":"responseNode","options":{"authentication":"none"}},"webhookId":"chatwoot-wh-001"}],"connections":{"webhook1":{"main":[[{"node":"respond1","type":"main","index":0}]]}},"settings":{"saveExecutionProgress":true,"saveManualExecutions":true,"callerPolicy":"workflowsFromSameOwner"},"staticData":null,"meta":null,"nodeGroups":[],"pinData":null,"versionId":"chatwoot-version-001","activeVersionId":"chatwoot-version-001","versionCounter":2,"triggerCount":1,"sourceWorkflowId":null,"tags":[],"shared":[{"updatedAt":"2026-06-24T18:36:33.199Z","createdAt":"2026-06-24T18:36:33.199Z","role":"workflow:owner","workflowId":"chatwoot-webhook-001","projectId":"default-project-001","project":{"updatedAt":"2026-06-24T18:36:33.131Z","createdAt":"2026-06-24T18:36:33.131Z","id":"default-project-001","name":"Default","type":"personal","icon":null,"description":null,"customTelemetryTags":[],"creatorId":"admin-id"}}],"versionMetadata":{"name":"Chatwoot Webhook Receiver","description":null}}
|
||||
1
workflows/n8n-current/saleor-webhook-001.json
Normal file
1
workflows/n8n-current/saleor-webhook-001.json
Normal file
@ -0,0 +1 @@
|
||||
{"updatedAt":"2026-06-24T18:19:47.666Z","createdAt":"2026-06-24T18:19:47.666Z","id":"saleor-webhook-001","name":"Saleor Webhook Receiver","description":null,"active":true,"isArchived":false,"nodes":[{"id":"webhook3","type":"n8n-nodes-base.webhook","position":[100,300],"parameters":{"httpMethod":"POST","path":"saleor-webhook","responseMode":"responseNode","options":{"authentication":"none"}},"webhookId":"saleor-wh-001"}],"connections":{"webhook3":{"main":[[{"node":"respond3","type":"main","index":0}]]}},"settings":{"saveExecutionProgress":true,"saveManualExecutions":true,"callerPolicy":"workflowsFromSameOwner"},"staticData":null,"meta":null,"nodeGroups":[],"pinData":null,"versionId":"saleor-version-001","activeVersionId":"saleor-version-001","versionCounter":2,"triggerCount":1,"sourceWorkflowId":null,"tags":[],"shared":[{"updatedAt":"2026-06-24T18:36:33.199Z","createdAt":"2026-06-24T18:36:33.199Z","role":"workflow:owner","workflowId":"saleor-webhook-001","projectId":"default-project-001","project":{"updatedAt":"2026-06-24T18:36:33.131Z","createdAt":"2026-06-24T18:36:33.131Z","id":"default-project-001","name":"Default","type":"personal","icon":null,"description":null,"customTelemetryTags":[],"creatorId":"admin-id"}}],"versionMetadata":{"name":"Saleor Webhook Receiver","description":null}}
|
||||
1
workflows/n8n-current/twenty-webhook-001.json
Normal file
1
workflows/n8n-current/twenty-webhook-001.json
Normal file
@ -0,0 +1 @@
|
||||
{"updatedAt":"2026-06-24T18:19:47.663Z","createdAt":"2026-06-24T18:19:47.663Z","id":"twenty-webhook-001","name":"Twenty CRM Webhook Receiver","description":null,"active":true,"isArchived":false,"nodes":[{"id":"webhook2","type":"n8n-nodes-base.webhook","position":[100,300],"parameters":{"httpMethod":"POST","path":"twenty-webhook","responseMode":"responseNode","options":{"authentication":"none"}},"webhookId":"twenty-wh-001"}],"connections":{"webhook2":{"main":[[{"node":"respond2","type":"main","index":0}]]}},"settings":{"saveExecutionProgress":true,"saveManualExecutions":true,"callerPolicy":"workflowsFromSameOwner"},"staticData":null,"meta":null,"nodeGroups":[],"pinData":null,"versionId":"twenty-version-001","activeVersionId":"twenty-version-001","versionCounter":2,"triggerCount":1,"sourceWorkflowId":null,"tags":[],"shared":[{"updatedAt":"2026-06-24T18:36:33.199Z","createdAt":"2026-06-24T18:36:33.199Z","role":"workflow:owner","workflowId":"twenty-webhook-001","projectId":"default-project-001","project":{"updatedAt":"2026-06-24T18:36:33.131Z","createdAt":"2026-06-24T18:36:33.131Z","id":"default-project-001","name":"Default","type":"personal","icon":null,"description":null,"customTelemetryTags":[],"creatorId":"admin-id"}}],"versionMetadata":{"name":"Twenty CRM Webhook Receiver","description":null}}
|
||||
Loading…
Reference in New Issue
Block a user