This workflow follows the Postgres → Telegram recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"name": "Premium / Lead events (lead.created \u2192 notify owner)",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "lead-events",
"responseMode": "responseNode",
"options": {
"responseHeaders": {
"values": []
},
"rawBody": false
}
},
"name": "Webhook (lead-events)",
"type": "n8n-nodes-base.webhook",
"typeVersion": 1,
"position": [
240,
300
]
},
{
"parameters": {
"conditions": {
"string": [
{
"value1": "={{$json.headers['x-premium-secret']}}",
"operation": "equals",
"value2": "={{$env.PREMIUM_INBOUND_SECRET}}"
}
]
}
},
"name": "IF (verify secret)",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
460,
300
]
},
{
"parameters": {
"respondWith": "text",
"responseBody": "Unauthorized",
"options": {
"responseCode": 401
}
},
"name": "Respond 401",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1,
"position": [
680,
460
]
},
{
"parameters": {
"conditions": {
"string": [
{
"value1": "={{$json.body.type}}",
"operation": "equals",
"value2": "lead.created"
}
]
}
},
"name": "Switch (event type)",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
680,
240
]
},
{
"parameters": {
"operation": "executeQuery",
"query": "select l.id as lead_id, l.service_kind, l.area_value, l.area_unit, l.district, l.description, l.metadata,\n c.id as contact_id, c.full_name, c.phone,\n ci.channel, ci.external_id\n from public.leads l\n join public.contacts c on c.id = l.contact_id\n left join public.contact_identities ci on ci.contact_id = c.id and ci.channel = l.channel\n where l.id = '{{$json.body.leadId}}'\n limit 1",
"options": {}
},
"name": "Postgres (load lead)",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.4,
"position": [
900,
200
],
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"values": {
"string": [
{
"name": "ownerText",
"value": "\ud83c\udd95 \u041d\u043e\u0432\u044b\u0439 \u043b\u0438\u0434\n\u0423\u0441\u043b\u0443\u0433\u0430: {{$json.service_kind}}\n\u041a\u043b\u0438\u0435\u043d\u0442: {{$json.full_name || '\u2014'}}\n\u0422\u0435\u043b\u0435\u0444\u043e\u043d: {{$json.phone || '\u2014'}}\n\u041f\u043b\u043e\u0449\u0430\u0434\u044c: {{$json.area_value}} {{$json.area_unit}}\n\u0420\u0430\u0439\u043e\u043d: {{$json.district || '\u2014'}}\n\u041a\u0430\u043d\u0430\u043b: {{$json.channel}}\n\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435: {{$json.description || '\u2014'}}"
}
]
},
"options": {}
},
"name": "Set (owner text)",
"type": "n8n-nodes-base.set",
"typeVersion": 3,
"position": [
1120,
200
]
},
{
"parameters": {
"chatId": "={{$env.TELEGRAM_OWNER_CHAT_ID}}",
"text": "={{$json.ownerText}}",
"additionalFields": {
"parse_mode": "HTML"
}
},
"name": "Telegram (notify owner)",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.1,
"position": [
1340,
120
],
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "executeQuery",
"query": "insert into public.events (type, contact_id, lead_id, payload)\nvalues ('owner.notified', '{{$json.contact_id}}', '{{$json.lead_id}}', '{}'::jsonb);"
},
"name": "Postgres (event: notified)",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.4,
"position": [
1340,
280
],
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={ \"ok\": true }"
},
"name": "Respond 200",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1,
"position": [
1560,
200
]
}
],
"connections": {
"Webhook (lead-events)": {
"main": [
[
{
"node": "IF (verify secret)",
"type": "main",
"index": 0
}
]
]
},
"IF (verify secret)": {
"main": [
[
{
"node": "Switch (event type)",
"type": "main",
"index": 0
}
],
[
{
"node": "Respond 401",
"type": "main",
"index": 0
}
]
]
},
"Switch (event type)": {
"main": [
[
{
"node": "Postgres (load lead)",
"type": "main",
"index": 0
}
],
[]
]
},
"Postgres (load lead)": {
"main": [
[
{
"node": "Set (owner text)",
"type": "main",
"index": 0
}
]
]
},
"Set (owner text)": {
"main": [
[
{
"node": "Telegram (notify owner)",
"type": "main",
"index": 0
},
{
"node": "Postgres (event: notified)",
"type": "main",
"index": 0
}
]
]
},
"Telegram (notify owner)": {
"main": [
[
{
"node": "Respond 200",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1"
},
"active": false,
"tags": [
"premium",
"leads"
]
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
postgrestelegramApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Premium / Lead events (lead.created → notify owner). Uses postgres, telegram. Webhook trigger; 9 nodes.
Source: https://github.com/alexdmitrievi/Premium/blob/claude/messenger-leadgen-architecture-xXMXM/n8n/workflows/01-lead-events.json — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
This workflow automates bulk email campaigns with built-in validation, deliverability protection, and smart send-time optimization.
Who is this for? Solo founders, sales teams, and event organizers who need email outreach without expensive tools but want full control from Telegram.
get-data-for-marketting-dashboard. Uses postgres, googleAnalytics, httpRequest. Webhook trigger; 20 nodes.
Enrich person L3. Uses executeWorkflowTrigger, postgres, perplexity, httpRequest. Webhook trigger; 12 nodes.
Enrich company L1. Uses executeWorkflowTrigger, postgres, perplexity. Webhook trigger; 9 nodes.