d5a304ebe9
Both flows now POST into the smb-crm DB API instead of appending to Sheets, so Postgres stays the source of truth and the DB->Sheets mirror keeps the Sheet current. Telegram notifications unchanged. - lead-intake: Webhook -> Build lead row -> POST /api/leads -> Telegram (dropped the direct Sheets append + the redundant activity-log nodes; the DB service logs + mirrors activity itself). - onboarding: Webhook -> Compute -> POST /api/clients (DB assigns C-id) -> Build project w/ returned id -> POST /api/projects -> Telegram. DB computes renewal_date; go-live = start + 14d. - Token injected at deploy time; repo keeps the __CRM_TOKEN__ placeholder. Verified end-to-end on the live webhooks: lead and client+project land in the DB and mirror to Sheets; test data cleaned; DB/Sheets consistent. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
94 lines
3.2 KiB
JSON
94 lines
3.2 KiB
JSON
{
|
|
"name": "SMB · Lead Intake",
|
|
"nodes": [
|
|
{
|
|
"parameters": {
|
|
"httpMethod": "POST",
|
|
"path": "lead-intake",
|
|
"responseMode": "onReceived",
|
|
"options": {
|
|
"allowedOrigins": "*"
|
|
}
|
|
},
|
|
"id": "f60ee339-9809-4962-9c5d-68ad9a5ec452",
|
|
"name": "Webhook",
|
|
"type": "n8n-nodes-base.webhook",
|
|
"typeVersion": 2,
|
|
"position": [240, 300],
|
|
"webhookId": "bb5f87d2-4647-4f38-9d6b-82a863158937"
|
|
},
|
|
{
|
|
"parameters": {
|
|
"jsCode": "const i=$input.first().json; const b=i.body||i;\nconst now=new Date().toISOString().replace('T',' ').slice(0,16);\nconst s=v=>{v=(v==null?'':String(v)); return /^[=+\\-@\\t\\r]/.test(v)?\"'\"+v:v;};\nreturn [{ json:{ lead_id:'L-'+Date.now(), received_at:now, client_id:s(b.client_id),\n source:s(b.source), name:s(b.name), contact:s(b.contact||b.email||b.phone),\n service_interest:s(b.service_interest||b.service), message:s(b.message), status:'new',\n notified:true }}];"
|
|
},
|
|
"id": "a5d0db99-93c2-46aa-8c0f-af1f4ee7300c",
|
|
"name": "Build lead row",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 2,
|
|
"position": [460, 300]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"method": "POST",
|
|
"url": "http://smb-crm:8080/api/leads",
|
|
"sendHeaders": true,
|
|
"headerParameters": {
|
|
"parameters": [
|
|
{ "name": "X-CRM-Token", "value": "__CRM_TOKEN__" }
|
|
]
|
|
},
|
|
"sendBody": true,
|
|
"specifyBody": "json",
|
|
"jsonBody": "={{ JSON.stringify($json) }}",
|
|
"options": {}
|
|
},
|
|
"id": "11111111-2222-3333-4444-555555555555",
|
|
"name": "Save to CRM (DB)",
|
|
"type": "n8n-nodes-base.httpRequest",
|
|
"typeVersion": 4.2,
|
|
"position": [680, 300],
|
|
"retryOnFail": true,
|
|
"maxTries": 4,
|
|
"waitBetweenTries": 3000
|
|
},
|
|
{
|
|
"parameters": {
|
|
"resource": "message",
|
|
"operation": "sendMessage",
|
|
"chatId": "5499280257",
|
|
"text": "=🆕 Neue Anfrage\nName: {{ $('Build lead row').item.json.name || '—' }}\nKontakt: {{ $('Build lead row').item.json.contact || '—' }}\nInteresse: {{ $('Build lead row').item.json.service_interest || '—' }}\nQuelle: {{ $('Build lead row').item.json.source || '—' }}\nClient: {{ $('Build lead row').item.json.client_id || '—' }}\nNachricht: {{ $('Build lead row').item.json.message || '—' }}",
|
|
"additionalFields": {
|
|
"appendAttribution": false
|
|
}
|
|
},
|
|
"id": "4734816a-f253-44e4-9158-4038e4011142",
|
|
"name": "Notify Telegram",
|
|
"type": "n8n-nodes-base.telegram",
|
|
"typeVersion": 1.2,
|
|
"position": [900, 300],
|
|
"credentials": {
|
|
"telegramApi": {
|
|
"id": "d9s4Ec5ocEH8FAxh",
|
|
"name": "SMB Telegram (leads bot)"
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"connections": {
|
|
"Webhook": {
|
|
"main": [[{ "node": "Build lead row", "type": "main", "index": 0 }]]
|
|
},
|
|
"Build lead row": {
|
|
"main": [[{ "node": "Save to CRM (DB)", "type": "main", "index": 0 }]]
|
|
},
|
|
"Save to CRM (DB)": {
|
|
"main": [[{ "node": "Notify Telegram", "type": "main", "index": 0 }]]
|
|
}
|
|
},
|
|
"settings": {
|
|
"executionOrder": "v1",
|
|
"callerPolicy": "workflowsFromSameOwner",
|
|
"availableInMCP": false
|
|
}
|
|
}
|