This workflow corresponds to n8n.io template #3612 — we link there as the canonical source.
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 →
{
"id": "Tetxh8UaZ85ELSAL",
"meta": {
"templateCredsSetupCompleted": true
},
"name": "TG-Bot-Module-Quiz-v4-db-sell-full",
"tags": [
{
"id": "EwFGeL3ePPNgm0R7",
"name": "telegram",
"createdAt": "2025-02-10T18:10:47.435Z",
"updatedAt": "2025-02-10T18:10:47.435Z"
},
{
"id": "XPad0ERjSdqfxG52",
"name": "module",
"createdAt": "2025-03-31T08:11:00.151Z",
"updatedAt": "2025-03-31T08:11:00.151Z"
},
{
"id": "2ocrWSzdKoCOU2AC",
"name": "sell",
"createdAt": "2025-04-19T15:39:51.859Z",
"updatedAt": "2025-04-19T15:39:51.859Z"
}
],
"nodes": [
{
"id": "c6772c56-7373-46f6-b550-106b0912f725",
"name": "For Tests",
"type": "n8n-nodes-base.switch",
"position": [
1560,
-380
],
"parameters": {},
"typeVersion": 3.2
},
{
"id": "8bc83292-4eb2-4580-aedb-14ff3f66c40a",
"name": "Test",
"type": "n8n-nodes-base.telegram",
"position": [
2040,
-580
],
"parameters": {},
"executeOnce": true,
"typeVersion": 1.2
},
{
"id": "57fe6fd6-476c-4516-b230-c8e01d0c9ffb",
"name": "Randomize questions",
"type": "n8n-nodes-base.sort",
"position": [
2260,
-580
],
"parameters": {},
"executeOnce": false,
"typeVersion": 1
},
{
"id": "8c36a7a3-c912-4d3f-87a6-6b700795c8ef",
"name": "Wait",
"type": "n8n-nodes-base.wait",
"position": [
3140,
-580
],
"parameters": {},
"typeVersion": 1.1
},
{
"id": "69461198-edcf-451c-9847-1f359d109c7a",
"name": "Variables",
"type": "n8n-nodes-base.set",
"position": [
2480,
-780
],
"parameters": {},
"executeOnce": true,
"typeVersion": 3.4
},
{
"id": "0c9b0b8d-70af-4716-b675-9bb3dd426466",
"name": "Merge",
"type": "n8n-nodes-base.merge",
"position": [
2700,
-580
],
"parameters": {},
"typeVersion": 3
},
{
"id": "7d5994d0-fb8b-45f3-ae5a-515075b5228d",
"name": "Question",
"type": "n8n-nodes-base.telegram",
"position": [
2920,
-580
],
"parameters": {},
"executeOnce": true,
"retryOnFail": false,
"typeVersion": 1.2
},
{
"id": "f277d6f3-8fa0-4704-b82e-e9508cfe92b0",
"name": "Commands",
"type": "n8n-nodes-base.switch",
"position": [
1180,
20
],
"parameters": {},
"retryOnFail": false,
"typeVersion": 3.2
},
{
"id": "465e22be-5d23-4889-8a5e-aca17c4b9a11",
"name": "Buttons",
"type": "n8n-nodes-base.switch",
"position": [
1180,
-380
],
"parameters": {},
"typeVersion": 3.2
},
{
"id": "f972e09f-4a96-45e8-977f-62ac6e479613",
"name": "Switch",
"type": "n8n-nodes-base.switch",
"position": [
900,
-180
],
"parameters": {},
"typeVersion": 3.2
},
{
"id": "00300fed-0dfc-469f-a58e-6428f7f97141",
"name": "List tests",
"type": "n8n-nodes-base.telegram",
"position": [
2480,
-40
],
"parameters": {},
"executeOnce": true,
"typeVersion": 1.2
},
{
"id": "091321f2-80e4-4fe0-8118-b7b0464989d9",
"name": "Main Menu",
"type": "n8n-nodes-base.telegram",
"position": [
1560,
-780
],
"parameters": {},
"executeOnce": true,
"typeVersion": 1.2
},
{
"id": "4b372e39-86dc-494d-9479-1416564e450a",
"name": "Update Bot Status on start",
"type": "n8n-nodes-base.postgres",
"position": [
1820,
-780
],
"parameters": {},
"typeVersion": 2.5
},
{
"id": "b760dbfd-6415-4099-baa0-2d65c6107882",
"name": "Telegram Trigger",
"type": "n8n-nodes-base.telegramTrigger",
"position": [
0,
-180
],
"parameters": {},
"typeVersion": 1.1
},
{
"id": "d517ac45-bfc1-4499-92b0-ebd884ccaf95",
"name": "Initialization",
"type": "n8n-nodes-base.set",
"position": [
460,
-180
],
"parameters": {},
"typeVersion": 3.4
},
{
"id": "faa1c338-6312-4bfe-a94e-f19dc021bf79",
"name": "Any questions?",
"type": "n8n-nodes-base.if",
"position": [
2260,
-380
],
"parameters": {},
"typeVersion": 2.2
},
{
"id": "881939f8-27e9-4b76-8bf0-bb827b058aa6",
"name": "Delete message",
"type": "n8n-nodes-base.telegram",
"position": [
3360,
-580
],
"parameters": {},
"typeVersion": 1.2
},
{
"id": "d1142c38-0438-4b00-ae0f-edfc9d40b339",
"name": "Code",
"type": "n8n-nodes-base.code",
"position": [
2480,
-580
],
"parameters": {},
"executeOnce": true,
"typeVersion": 2
},
{
"id": "b7ef9d15-b4ba-437a-b1ce-c6c91620366b",
"name": "Get Questions AND Answers",
"type": "n8n-nodes-base.postgres",
"position": [
2040,
-780
],
"parameters": {},
"typeVersion": 2.5
},
{
"id": "b76407ba-058d-47a2-9e34-4e934baf9a24",
"name": "Update Answer",
"type": "n8n-nodes-base.postgres",
"position": [
1820,
-380
],
"parameters": {},
"executeOnce": true,
"typeVersion": 2.5
},
{
"id": "de961e0f-cfc8-4d3d-a22c-bd60bbaeea93",
"name": "Get Non-Answered Questions",
"type": "n8n-nodes-base.postgres",
"position": [
2040,
-380
],
"parameters": {},
"typeVersion": 2.5,
"alwaysOutputData": true
},
{
"id": "4b242a0a-96b3-4e68-901f-5a51203a1aab",
"name": "Get Tests",
"type": "n8n-nodes-base.postgres",
"position": [
1820,
-40
],
"parameters": {},
"typeVersion": 2.5
},
{
"id": "d4578eb5-351e-42da-b8aa-dd7b31cd273a",
"name": "Union Number with Question",
"type": "n8n-nodes-base.set",
"position": [
2040,
-40
],
"parameters": {},
"typeVersion": 3.4
},
{
"id": "c41aad19-b64d-4b65-9897-9db4dbe4d173",
"name": "Union list",
"type": "n8n-nodes-base.summarize",
"position": [
2260,
-40
],
"parameters": {},
"typeVersion": 1.1
},
{
"id": "34ce463e-0a46-4c18-ad0c-93eb27451d1a",
"name": "Get Test",
"type": "n8n-nodes-base.postgres",
"position": [
1820,
-580
],
"parameters": {},
"typeVersion": 2.5
},
{
"id": "c352c16b-c407-4a66-9157-26b8b7ccf2e2",
"name": "Result Test",
"type": "n8n-nodes-base.telegram",
"position": [
2700,
-380
],
"parameters": {},
"executeOnce": true,
"retryOnFail": false,
"typeVersion": 1.2
},
{
"id": "3cd53065-2bb5-42e6-8052-e0d8145a6d33",
"name": "Calculate answers",
"type": "n8n-nodes-base.postgres",
"position": [
2480,
-380
],
"parameters": {},
"typeVersion": 2.5
},
{
"id": "fd55a57b-e510-4f5e-9739-a83a7eca457b",
"name": "Upsert pred Answer",
"type": "n8n-nodes-base.postgres",
"position": [
2920,
-780
],
"parameters": {},
"executeOnce": true,
"typeVersion": 2.5
},
{
"id": "0fcc8a1d-f643-4999-9508-6992149d913b",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-20,
160
],
"parameters": {
"content": ""
},
"typeVersion": 1
},
{
"id": "abdcb075-fe51-4ae0-b7c5-14c42b8db097",
"name": "Variables TG",
"type": "n8n-nodes-base.set",
"position": [
220,
-180
],
"parameters": {},
"typeVersion": 3.4
},
{
"id": "d8ed0d39-d250-436f-b5fb-ef727d4e4fb0",
"name": "Is Start?",
"type": "n8n-nodes-base.if",
"position": [
680,
-180
],
"parameters": {},
"typeVersion": 2.2
},
{
"id": "b9db0964-0e46-4335-859e-5a9d11b2132c",
"name": "Welcome Message",
"type": "n8n-nodes-base.telegram",
"position": [
680,
-380
],
"parameters": {},
"executeOnce": true,
"typeVersion": 1.2
},
{
"id": "f3319cfd-6d30-4efd-b322-1c8eb46302a3",
"name": "Error",
"type": "n8n-nodes-base.telegram",
"position": [
1560,
160
],
"parameters": {},
"executeOnce": true,
"typeVersion": 1.2
},
{
"id": "5cf3c126-a6a9-4d25-98d2-191af91b12d9",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-440,
-420
],
"parameters": {
"content": ""
},
"typeVersion": 1
},
{
"id": "40325b66-5ac3-4275-b00b-d097834dfe15",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-440,
-180
],
"parameters": {
"content": ""
},
"typeVersion": 1
},
{
"id": "f31c4ec7-3651-4c02-8c3c-8dd2f135a291",
"name": "Sticky Note6",
"type": "n8n-nodes-base.stickyNote",
"position": [
-440,
160
],
"parameters": {
"content": ""
},
"typeVersion": 1
}
],
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "f377e631-c16e-4bc3-a4f5-4c66d314fe5d",
"connections": {
"Code": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 1
}
]
]
},
"Test": {
"main": [
[
{
"node": "Get Questions AND Answers",
"type": "main",
"index": 0
}
]
]
},
"Wait": {
"main": [
[
{
"node": "Delete message",
"type": "main",
"index": 0
}
]
]
},
"Merge": {
"main": [
[
{
"node": "Upsert pred Answer",
"type": "main",
"index": 0
}
]
]
},
"Switch": {
"main": [
[
{
"node": "Buttons",
"type": "main",
"index": 0
}
],
[
{
"node": "Commands",
"type": "main",
"index": 0
}
]
]
},
"Buttons": {
"main": [
[
{
"node": "Main Menu",
"type": "main",
"index": 0
}
],
[
{
"node": "For Tests",
"type": "main",
"index": 0
}
]
]
},
"Commands": {
"main": [
[
{
"node": "Get Tests",
"type": "main",
"index": 0
}
],
[
{
"node": "Error",
"type": "main",
"index": 0
}
],
[
{
"node": "Error",
"type": "main",
"index": 0
}
]
]
},
"Get Test": {
"main": [
[
{
"node": "Test",
"type": "main",
"index": 0
}
]
]
},
"Question": {
"main": [
[
{
"node": "Wait",
"type": "main",
"index": 0
}
]
]
},
"For Tests": {
"main": [
[
{
"node": "Get Tests",
"type": "main",
"index": 0
}
],
[
{
"node": "Get Test",
"type": "main",
"index": 0
}
],
[
{
"node": "Update Answer",
"type": "main",
"index": 0
}
]
]
},
"Get Tests": {
"main": [
[
{
"node": "Union Number with Question",
"type": "main",
"index": 0
}
]
]
},
"Is Start?": {
"main": [
[
{
"node": "Welcome Message",
"type": "main",
"index": 0
}
],
[
{
"node": "Switch",
"type": "main",
"index": 0
}
]
]
},
"Main Menu": {
"main": [
[
{
"node": "Update Bot Status on start",
"type": "main",
"index": 0
}
]
]
},
"Variables": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 0
}
]
]
},
"Union list": {
"main": [
[
{
"node": "List tests",
"type": "main",
"index": 0
}
]
]
},
"Variables TG": {
"main": [
[
{
"node": "Initialization",
"type": "main",
"index": 0
}
]
]
},
"Update Answer": {
"main": [
[
{
"node": "Get Non-Answered Questions",
"type": "main",
"index": 0
}
]
]
},
"Any questions?": {
"main": [
[
{
"node": "Randomize questions",
"type": "main",
"index": 0
}
],
[
{
"node": "Calculate answers",
"type": "main",
"index": 0
}
]
]
},
"Initialization": {
"main": [
[
{
"node": "Is Start?",
"type": "main",
"index": 0
}
]
]
},
"Telegram Trigger": {
"main": [
[
{
"node": "Variables TG",
"type": "main",
"index": 0
}
]
]
},
"Calculate answers": {
"main": [
[
{
"node": "Result Test",
"type": "main",
"index": 0
}
]
]
},
"Upsert pred Answer": {
"main": [
[
{
"node": "Question",
"type": "main",
"index": 0
}
]
]
},
"Randomize questions": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
},
{
"node": "Variables",
"type": "main",
"index": 0
}
]
]
},
"Get Questions AND Answers": {
"main": [
[
{
"node": "Randomize questions",
"type": "main",
"index": 0
}
]
]
},
"Get Non-Answered Questions": {
"main": [
[
{
"node": "Any questions?",
"type": "main",
"index": 0
}
]
]
},
"Union Number with Question": {
"main": [
[
{
"node": "Union list",
"type": "main",
"index": 0
}
]
]
}
}
}
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
This template is ideal for educators, HR professionals, and anyone looking to automate testing and collect responses through Telegram, while storing results in a Postgres database.
Source: https://n8n.io/workflows/3612/ — 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.
Telegram Code. Uses stickyNote, telegramTrigger, telegram, googleDrive. Event-driven trigger; 37 nodes.
Memory sessions with FlowiseAI and Zep. Uses telegram, redis, telegramTrigger, httpRequest. Event-driven trigger; 37 nodes.
Workflow1-2-3. Uses httpRequest, gmail, telegram, postgres. Webhook trigger; 34 nodes.
Instant enquiry/booking system. Uses telegramTrigger, googleSheets, telegram, gmail. Event-driven trigger; 28 nodes.
This template allows you to easily update the response of a Dialogflow intent by simply typing a keyword in Telegram. Ideal for those who need to edit responses without accessing the Dialogflow consol