This workflow follows the Google Sheets → HTTP Request 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": "IR-CLU \u2014 \u0631\u0628\u0627\u062a \u0641\u0631\u0648\u0634 (\u0627\u062d\u0631\u0627\u0632 \u0647\u0648\u06cc\u062a + \u0647\u0648\u0634 \u0645\u0635\u0646\u0648\u0639\u06cc + \u067e\u0631\u062f\u0627\u062e\u062a \u06a9\u0627\u0631\u062a\u200c\u0628\u0647\u200c\u06a9\u0627\u0631\u062a)",
"nodes": [
{
"id": "tg-trigger",
"name": "\u067e\u06cc\u0627\u0645 \u062c\u062f\u06cc\u062f \u062f\u0631 \u0631\u0628\u0627\u062a \u0641\u0631\u0648\u0634",
"type": "n8n-nodes-base.telegramTrigger",
"typeVersion": 1.1,
"position": [
-1600,
0
],
"parameters": {
"updates": [
"message",
"callback_query"
]
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"id": "code-classify",
"name": "\u062a\u0634\u062e\u06cc\u0635 \u0646\u0648\u0639 \u067e\u06cc\u0627\u0645",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-1360,
0
],
"parameters": {
"jsCode": "const msg = $json.message || {};\nconst cq = $json.callback_query || null;\n\n// \u0627\u06af\u0647 \u06cc\u0647 \u0631\u0648\u0632 \u062e\u0648\u0627\u0633\u062a\u06cc \u0686\u0646\u062f \u0646\u0641\u0631 \u062f\u06cc\u06af\u0647 \u0647\u0645 \u0628\u062a\u0648\u0646\u0646 \u0633\u0641\u0627\u0631\u0634\u200c\u0647\u0627 \u0631\u0648 \u062a\u0627\u06cc\u06cc\u062f/\u0631\u062f \u06a9\u0646\u0646\u060c \u0622\u06cc\u200c\u062f\u06cc\u200c\u0634\u0648\u0646 \u0631\u0648 \u0647\u0645 \u0627\u06cc\u0646\u062c\u0627 \u0627\u0636\u0627\u0641\u0647 \u06a9\u0646\nconst adminChatId = \"6452519019\";\n\nlet kind = \"free_text\";\nlet chatId, username, firstName, text;\nlet slug = null;\nlet decisionAction = null;\nlet decisionOrderId = null;\n\nif (cq) {\n // \u062f\u06a9\u0645\u0647\u200c\u06cc \u062a\u0627\u06cc\u06cc\u062f/\u0631\u062f \u0632\u06cc\u0631 \u0639\u06a9\u0633 \u0631\u0633\u06cc\u062f \u0641\u0634\u0631\u062f\u0647 \u0634\u062f\u0647\n chatId = cq.from?.id;\n username = cq.from?.username || \"\";\n firstName = cq.from?.first_name || \"\";\n text = \"\";\n const m = (cq.data || \"\").match(/^(approve|reject):(ORDER-\\S+)$/);\n if (String(chatId) === adminChatId && m) {\n kind = \"admin_decision\";\n decisionAction = m[1];\n decisionOrderId = m[2];\n } else if (String(chatId) === adminChatId && cq.data === \"admin:report\") {\n kind = \"admin_report\";\n }\n} else {\n chatId = msg.chat?.id;\n username = msg.from?.username || \"\";\n firstName = msg.from?.first_name || \"\";\n text = (msg.text || \"\").trim();\n\n if (msg.contact) {\n kind = \"contact\";\n } else if (String(chatId) === adminChatId && text === \"/start\") {\n // \u0627\u062f\u0645\u06cc\u0646 \u0648\u0627\u0631\u062f \u0645\u0633\u06cc\u0631 \u0639\u0627\u062f\u06cc \u0645\u0634\u062a\u0631\u06cc (\u062f\u0631\u062e\u0648\u0627\u0633\u062a \u0634\u0645\u0627\u0631\u0647 \u0648 ...) \u0646\u0645\u06cc\u200c\u0634\u0647\u060c \u0645\u0646\u0648\u06cc \u062e\u0648\u062f\u0634 \u0631\u0648 \u0645\u06cc\u200c\u0628\u06cc\u0646\u0647\n kind = \"admin_menu\";\n } else if (/^\\/start\\s+\\S+/.test(text)) {\n kind = \"start_product\";\n slug = text.match(/^\\/start\\s+(\\S+)/)[1];\n } else if (text === \"/start\") {\n kind = \"start_product\";\n slug = null;\n } else if (msg.photo && msg.photo.length) {\n kind = \"photo_receipt\";\n } else if (String(chatId) === adminChatId && /^(\u062a\u0627\u06cc\u06cc\u062f|\u0631\u062f)\\s+(ORDER-\\S+)/.test(text)) {\n kind = \"admin_decision\";\n const m2 = text.match(/^(\u062a\u0627\u06cc\u06cc\u062f|\u0631\u062f)\\s+(ORDER-\\S+)/);\n decisionAction = m2[1] === \"\u062a\u0627\u06cc\u06cc\u062f\" ? \"approve\" : \"reject\";\n decisionOrderId = m2[2];\n }\n}\n\nconst photo = msg.photo ? msg.photo[msg.photo.length - 1] : null;\nconst phone = msg.contact ? msg.contact.phone_number : null;\n\nreturn [{\n json: {\n kind, chatId, username, firstName, text, slug,\n decisionAction, decisionOrderId,\n photoFileId: photo ? photo.file_id : null,\n phone,\n },\n}];"
}
},
{
"id": "switch-kind",
"name": "\u0645\u0633\u06cc\u0631 \u0628\u0631 \u0627\u0633\u0627\u0633 \u0646\u0648\u0639 \u067e\u06cc\u0627\u0645",
"type": "n8n-nodes-base.switch",
"typeVersion": 3.2,
"position": [
-1120,
0
],
"parameters": {
"rules": {
"values": [
{
"conditions": {
"combinator": "and",
"conditions": [
{
"leftValue": "={{ $json.kind }}",
"rightValue": "contact",
"operator": {
"type": "string",
"operation": "equals"
}
}
]
},
"outputKey": "contact"
},
{
"conditions": {
"combinator": "and",
"conditions": [
{
"leftValue": "={{ $json.kind }}",
"rightValue": "start_product",
"operator": {
"type": "string",
"operation": "equals"
}
}
]
},
"outputKey": "start_product"
},
{
"conditions": {
"combinator": "and",
"conditions": [
{
"leftValue": "={{ $json.kind }}",
"rightValue": "photo_receipt",
"operator": {
"type": "string",
"operation": "equals"
}
}
]
},
"outputKey": "photo_receipt"
},
{
"conditions": {
"combinator": "and",
"conditions": [
{
"leftValue": "={{ $json.kind }}",
"rightValue": "admin_decision",
"operator": {
"type": "string",
"operation": "equals"
}
}
]
},
"outputKey": "admin_decision"
},
{
"conditions": {
"combinator": "and",
"conditions": [
{
"leftValue": "={{ $json.kind }}",
"rightValue": "free_text",
"operator": {
"type": "string",
"operation": "equals"
}
}
]
},
"outputKey": "free_text"
},
{
"conditions": {
"combinator": "and",
"conditions": [
{
"leftValue": "={{ $json.kind }}",
"rightValue": "admin_menu",
"operator": {
"type": "string",
"operation": "equals"
}
}
]
},
"outputKey": "admin_menu"
},
{
"conditions": {
"combinator": "and",
"conditions": [
{
"leftValue": "={{ $json.kind }}",
"rightValue": "admin_report",
"operator": {
"type": "string",
"operation": "equals"
}
}
]
},
"outputKey": "admin_report"
}
]
},
"options": {}
}
},
{
"id": "shape-save-phone",
"name": "\u0622\u0645\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u0631\u062f\u06cc\u0641 \u0645\u0634\u062a\u0631\u06cc (\u0634\u0645\u0627\u0631\u0647)",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-1000,
-700
],
"parameters": {
"jsCode": "const t = $json;\nreturn [{\n json: {\n telegram_user_id: t.chatId,\n username: t.username,\n phone: t.phone,\n created_at: new Date().toISOString(),\n },\n}];"
}
},
{
"id": "sheets-save-phone",
"name": "\u0630\u062e\u06cc\u0631\u0647 \u0634\u0645\u0627\u0631\u0647 \u062a\u0644\u0641\u0646",
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.5,
"position": [
-880,
-700
],
"parameters": {
"operation": "appendOrUpdate",
"documentId": {
"mode": "list",
"value": "PLACEHOLDER_SPREADSHEET_ID"
},
"sheetName": {
"mode": "name",
"value": "Customers"
},
"columns": {
"mappingMode": "autoMapInputData",
"value": {},
"matchingColumns": [
"telegram_user_id"
]
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"id": "sheets-read-customer-after-phone",
"name": "\u062e\u0648\u0627\u0646\u062f\u0646 \u0648\u0636\u0639\u06cc\u062a \u0645\u0634\u062a\u0631\u06cc",
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.5,
"position": [
-640,
-700
],
"parameters": {
"operation": "read",
"documentId": {
"mode": "list",
"value": "PLACEHOLDER_SPREADSHEET_ID"
},
"sheetName": {
"mode": "name",
"value": "Customers"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
},
"alwaysOutputData": true
},
{
"id": "code-resume-after-phone",
"name": "\u0627\u062f\u0627\u0645\u0647 \u062f\u0627\u062f\u0646 \u0628\u0639\u062f \u0627\u0632 \u0627\u062d\u0631\u0627\u0632 \u0647\u0648\u06cc\u062a",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-400,
-700
],
"parameters": {
"jsCode": "const ctx = $('\u062a\u0634\u062e\u06cc\u0635 \u0646\u0648\u0639 \u067e\u06cc\u0627\u0645').first().json;\nconst rows = $input.all().map((i) => i.json);\nconst row = rows.find((r) => String(r.telegram_user_id) === String(ctx.chatId));\nconst pending = row?.pending_state || \"\";\nconst m = pending.match(/^awaiting_product:(.+)$/);\n\nreturn [{\n json: {\n chatId: ctx.chatId,\n username: ctx.username,\n firstName: ctx.firstName,\n resumeSlug: m ? m[1] : null,\n },\n}];"
}
},
{
"id": "tg-phone-saved",
"name": "\u062a\u0623\u06cc\u06cc\u062f \u062b\u0628\u062a \u0634\u0645\u0627\u0631\u0647",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
-160,
-800
],
"parameters": {
"resource": "message",
"operation": "sendMessage",
"chatId": "={{ $json.chatId }}",
"text": "\u0645\u0645\u0646\u0648\u0646\u060c \u0634\u0645\u0627\u0631\u0647\u200c\u0627\u062a \u062b\u0628\u062a \u0634\u062f \u2705",
"replyMarkup": "replyKeyboardRemove",
"replyKeyboardRemove": {
"selective": false
},
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"id": "if-has-resume-slug",
"name": "\u0645\u062d\u0635\u0648\u0644\u06cc \u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631 \u0628\u0648\u062f\u061f",
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
-160,
-600
],
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "loose"
},
"conditions": [
{
"leftValue": "={{ $json.resumeSlug }}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "notEmpty"
}
}
],
"combinator": "and"
}
}
},
{
"id": "tg-invite-chat",
"name": "\u062f\u0639\u0648\u062a \u0628\u0647 \u06af\u0641\u062a\u06af\u0648",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
80,
-500
],
"parameters": {
"resource": "message",
"operation": "sendMessage",
"chatId": "={{ $json.chatId }}",
"text": "=\u0633\u0644\u0627\u0645 {{ $json.firstName }} \ud83d\udc4b \u062e\u0648\u0634 \u0627\u0648\u0645\u062f\u06cc!\n\u0647\u0631 \u0633\u0648\u0627\u0644\u06cc \u062f\u0631\u0628\u0627\u0631\u0647\u200c\u06cc \u062e\u062f\u0645\u0627\u062a \u0648 \u0645\u062d\u0635\u0648\u0644\u0627\u062a IR-CLU \u062f\u0627\u0631\u06cc \u0647\u0645\u06cc\u0646\u062c\u0627 \u0628\u067e\u0631\u0633\u060c \u062f\u0631 \u062e\u062f\u0645\u062a\u062a\u0645.",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"id": "sheets-read-customers-for-check",
"name": "\u062e\u0648\u0627\u0646\u062f\u0646 \u0645\u0634\u062a\u0631\u06cc\u0627\u0646",
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.5,
"position": [
-880,
-200
],
"parameters": {
"operation": "read",
"documentId": {
"mode": "list",
"value": "PLACEHOLDER_SPREADSHEET_ID"
},
"sheetName": {
"mode": "name",
"value": "Customers"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
},
"alwaysOutputData": true
},
{
"id": "code-check-phone",
"name": "\u0628\u0631\u0631\u0633\u06cc \u0627\u062d\u0631\u0627\u0632 \u0647\u0648\u06cc\u062a",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-640,
-200
],
"parameters": {
"jsCode": "const ctx = $('\u062a\u0634\u062e\u06cc\u0635 \u0646\u0648\u0639 \u067e\u06cc\u0627\u0645').first().json;\nconst rows = $input.all().map((i) => i.json);\nconst row = rows.find((r) => String(r.telegram_user_id) === String(ctx.chatId));\n\nreturn [{ json: { ...ctx, hasPhone: !!(row && row.phone) } }];"
}
},
{
"id": "if-has-phone",
"name": "\u0634\u0645\u0627\u0631\u0647 \u0642\u0628\u0644\u0627\u064b \u062b\u0628\u062a \u0634\u062f\u0647\u061f",
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
-400,
-200
],
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "loose"
},
"conditions": [
{
"leftValue": "={{ $json.hasPhone }}",
"rightValue": true,
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
}
}
],
"combinator": "and"
}
}
},
{
"id": "shape-save-pending-slug",
"name": "\u0622\u0645\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u0631\u062f\u06cc\u0641 \u0645\u0634\u062a\u0631\u06cc (\u0645\u062d\u0635\u0648\u0644 \u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631)",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-280,
-100
],
"parameters": {
"jsCode": "const t = $json;\nreturn [{\n json: {\n telegram_user_id: t.chatId,\n pending_state: t.slug ? ('awaiting_product:' + t.slug) : '',\n },\n}];"
}
},
{
"id": "sheets-save-pending-slug",
"name": "\u0630\u062e\u06cc\u0631\u0647 \u0645\u062d\u0635\u0648\u0644 \u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631",
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.5,
"position": [
-160,
-100
],
"parameters": {
"operation": "appendOrUpdate",
"documentId": {
"mode": "list",
"value": "PLACEHOLDER_SPREADSHEET_ID"
},
"sheetName": {
"mode": "name",
"value": "Customers"
},
"columns": {
"mappingMode": "autoMapInputData",
"value": {},
"matchingColumns": [
"telegram_user_id"
]
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"id": "code-prep-phone-request",
"name": "\u0622\u0645\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u062f\u0631\u062e\u0648\u0627\u0633\u062a \u0634\u0645\u0627\u0631\u0647",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
80,
-100
],
"parameters": {
"jsCode": "const ctx = $('\u0628\u0631\u0631\u0633\u06cc \u0627\u062d\u0631\u0627\u0632 \u0647\u0648\u06cc\u062a').first().json;\nreturn [{ json: { chatId: ctx.chatId, username: ctx.username, firstName: ctx.firstName } }];"
}
},
{
"id": "tg-request-phone",
"name": "\u062f\u0631\u062e\u0648\u0627\u0633\u062a \u0634\u0645\u0627\u0631\u0647 \u062a\u0644\u0641\u0646",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
320,
-100
],
"parameters": {
"resource": "message",
"operation": "sendMessage",
"chatId": "={{ $json.chatId }}",
"text": "\u0628\u0631\u0627\u06cc \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u062e\u062f\u0645\u0627\u062a \u0645\u0627\u060c \u0644\u0637\u0641\u0627\u064b \u0634\u0645\u0627\u0631\u0647 \u062a\u0644\u0641\u0646\u062a \u0631\u0648 \u0628\u0627 \u062f\u06a9\u0645\u0647 \u0632\u06cc\u0631 \u0628\u0641\u0631\u0633\u062a \ud83d\udc47",
"replyMarkup": "replyKeyboard",
"replyKeyboard": {
"rows": [
{
"row": {
"buttons": [
{
"text": "\ud83d\udcf1 \u0627\u0631\u0633\u0627\u0644 \u0634\u0645\u0627\u0631\u0647 \u062a\u0645\u0627\u0633",
"additionalFields": {
"request_contact": true
}
}
]
}
}
]
},
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"id": "if-has-slug",
"name": "\u0645\u062d\u0635\u0648\u0644\u06cc \u062e\u0648\u0627\u0633\u062a\u0647 \u0628\u0648\u062f\u061f",
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
-160,
-260
],
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "loose"
},
"conditions": [
{
"leftValue": "={{ $json.slug }}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "notEmpty"
}
}
],
"combinator": "and"
}
}
},
{
"id": "tg-welcome-no-product",
"name": "\u062e\u0648\u0634\u200c\u0622\u0645\u062f\u06af\u0648\u06cc\u06cc (\u0628\u062f\u0648\u0646 \u0645\u062d\u0635\u0648\u0644)",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
80,
-340
],
"parameters": {
"resource": "message",
"operation": "sendMessage",
"chatId": "={{ $json.chatId }}",
"text": "=\u0633\u0644\u0627\u0645 {{ $json.firstName }} \ud83d\udc4b \u062e\u0648\u0634 \u0627\u0648\u0645\u062f\u06cc\u060c \u0634\u0645\u0627\u0631\u0647\u200c\u062a \u0642\u0628\u0644\u0627\u064b \u062b\u0628\u062a \u0634\u062f\u0647 \u2705\n\u0647\u0631 \u0633\u0648\u0627\u0644\u06cc \u062f\u0631\u0628\u0627\u0631\u0647\u200c\u06cc \u062e\u062f\u0645\u0627\u062a \u0645\u0627 \u062f\u0627\u0631\u06cc \u0628\u067e\u0631\u0633\u060c \u06cc\u0627 \u0627\u0632 \u0635\u0641\u062d\u0647\u200c\u06cc \u0641\u0631\u0648\u0634\u06af\u0627\u0647 \u0633\u0627\u06cc\u062a (irclu.com/store) \u0631\u0648\u06cc \u062f\u06a9\u0645\u0647\u200c\u06cc \u00ab\u062e\u0631\u06cc\u062f \u062f\u0631 \u062a\u0644\u06af\u0631\u0627\u0645\u00bb \u0647\u0645\u0648\u0646 \u0645\u062d\u0635\u0648\u0644 \u0628\u0632\u0646.",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"id": "sheets-read-products",
"name": "\u062e\u0648\u0627\u0646\u062f\u0646 \u0645\u062d\u0635\u0648\u0644\u0627\u062a",
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.5,
"position": [
80,
100
],
"parameters": {
"operation": "read",
"documentId": {
"mode": "list",
"value": "PLACEHOLDER_SPREADSHEET_ID"
},
"sheetName": {
"mode": "name",
"value": "Products"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
},
"alwaysOutputData": true
},
{
"id": "code-find-product",
"name": "\u067e\u06cc\u062f\u0627 \u06a9\u0631\u062f\u0646 \u0645\u062d\u0635\u0648\u0644",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
320,
100
],
"parameters": {
"jsCode": "let ctx;\ntry {\n ctx = $('\u0627\u062f\u0627\u0645\u0647 \u062f\u0627\u062f\u0646 \u0628\u0639\u062f \u0627\u0632 \u0627\u062d\u0631\u0627\u0632 \u0647\u0648\u06cc\u062a').first().json;\n} catch (e) {\n ctx = $('\u0628\u0631\u0631\u0633\u06cc \u0627\u062d\u0631\u0627\u0632 \u0647\u0648\u06cc\u062a').first().json;\n}\n\nconst slug = ctx.slug || ctx.resumeSlug;\nconst chatId = ctx.chatId;\nconst username = ctx.username;\n\nconst rows = $input.all().map((i) => i.json);\nconst product = rows.find((r) => r.slug === slug && String(r.active).toLowerCase() === 'true');\n\nreturn [{ json: { found: !!product, chatId, username, slug, product: product || null } }];"
}
},
{
"id": "if-product-found",
"name": "\u0645\u062d\u0635\u0648\u0644 \u067e\u06cc\u062f\u0627 \u0634\u062f\u061f",
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
560,
100
],
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "loose"
},
"conditions": [
{
"leftValue": "={{ $json.found }}",
"rightValue": true,
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
}
}
],
"combinator": "and"
}
}
},
{
"id": "tg-not-found",
"name": "\u0645\u062d\u0635\u0648\u0644 \u067e\u06cc\u062f\u0627 \u0646\u0634\u062f",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
800,
220
],
"parameters": {
"resource": "message",
"operation": "sendMessage",
"chatId": "={{ $json.chatId }}",
"text": "\u0627\u06cc\u0646 \u0645\u062d\u0635\u0648\u0644 \u062f\u0631 \u062f\u0633\u062a\u0631\u0633 \u0646\u06cc\u0633\u062a. \u0627\u0632 \u0635\u0641\u062d\u0647\u200c\u06cc \u0641\u0631\u0648\u0634\u06af\u0627\u0647 (irclu.com/store) \u062f\u0648\u0628\u0627\u0631\u0647 \u0627\u0645\u062a\u062d\u0627\u0646 \u06a9\u0646.",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"id": "code-create-order",
"name": "\u0633\u0627\u062e\u062a \u0633\u0641\u0627\u0631\u0634 \u062c\u062f\u06cc\u062f",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
800,
-20
],
"parameters": {
"jsCode": "const orderId = `ORDER-${Date.now()}-${Math.floor(Math.random() * 9000 + 1000)}`;\nreturn [{ json: { ...$json, orderId } }];"
}
},
{
"id": "shape-append-order",
"name": "\u0622\u0645\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u0631\u062f\u06cc\u0641 \u0633\u0641\u0627\u0631\u0634",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
920,
-20
],
"parameters": {
"jsCode": "const t = $json;\nreturn [{\n json: {\n order_id: t.orderId,\n telegram_user_id: t.chatId,\n telegram_username: t.username,\n product_slug: t.slug,\n amount: t.product.price,\n requirements_summary: '',\n status: 'awaiting_requirements',\n receipt_file_id: '',\n created_at: new Date().toISOString(),\n reviewed_at: '',\n expires_at: '',\n renewal_notified: 'false',\n },\n}];"
}
},
{
"id": "sheets-append-order",
"name": "\u062b\u0628\u062a \u0633\u0641\u0627\u0631\u0634 (\u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631 \u0646\u06cc\u0627\u0632\u0647\u0627)",
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.5,
"position": [
1040,
-20
],
"parameters": {
"operation": "append",
"documentId": {
"mode": "list",
"value": "PLACEHOLDER_SPREADSHEET_ID"
},
"sheetName": {
"mode": "name",
"value": "Orders"
},
"columns": {
"mappingMode": "autoMapInputData",
"value": {}
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"id": "shape-pending-requirements",
"name": "\u0622\u0645\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u0631\u062f\u06cc\u0641 \u0645\u0634\u062a\u0631\u06cc (\u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631 \u0646\u06cc\u0627\u0632\u0647\u0627)",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1160,
-20
],
"parameters": {
"jsCode": "const t = $('\u0633\u0627\u062e\u062a \u0633\u0641\u0627\u0631\u0634 \u062c\u062f\u06cc\u062f').first().json;\nreturn [{\n json: {\n telegram_user_id: t.chatId,\n pending_state: 'awaiting_requirements:' + t.orderId,\n },\n}];"
}
},
{
"id": "sheets-set-pending-requirements",
"name": "\u062b\u0628\u062a \u0648\u0636\u0639\u06cc\u062a \u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631 \u0646\u06cc\u0627\u0632\u0647\u0627",
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.5,
"position": [
1280,
-20
],
"parameters": {
"operation": "appendOrUpdate",
"documentId": {
"mode": "list",
"value": "PLACEHOLDER_SPREADSHEET_ID"
},
"sheetName": {
"mode": "name",
"value": "Customers"
},
"columns": {
"mappingMode": "autoMapInputData",
"value": {},
"matchingColumns": [
"telegram_user_id"
]
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"id": "tg-ask-requirements",
"name": "\u062f\u0631\u062e\u0648\u0627\u0633\u062a \u062a\u0648\u0636\u06cc\u062d \u0646\u06cc\u0627\u0632\u0647\u0627",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
1520,
-20
],
"parameters": {
"resource": "message",
"operation": "sendMessage",
"chatId": "={{ $('\u0633\u0627\u062e\u062a \u0633\u0641\u0627\u0631\u0634 \u062c\u062f\u06cc\u062f').first().json.chatId }}",
"text": "=\u2705 {{ $('\u0633\u0627\u062e\u062a \u0633\u0641\u0627\u0631\u0634 \u062c\u062f\u06cc\u062f').first().json.product.title }}\n\u0642\u06cc\u0645\u062a: {{ Number($('\u0633\u0627\u062e\u062a \u0633\u0641\u0627\u0631\u0634 \u062c\u062f\u06cc\u062f').first().json.product.price).toLocaleString('fa-IR') }} \u062a\u0648\u0645\u0627\u0646 (\u0645\u0627\u0647\u0627\u0646\u0647)\n\n\u062d\u0627\u0644\u0627 \u0628\u0627 \u0632\u0628\u0627\u0646 \u062e\u0648\u062f\u062a \u0628\u0631\u0627\u0645 \u0628\u0646\u0648\u06cc\u0633 \u062f\u0642\u06cc\u0642\u0627\u064b \u0686\u0647 \u0646\u06cc\u0627\u0632\u06cc \u062f\u0627\u0631\u06cc (\u0646\u0648\u0639 \u06a9\u0633\u0628\u200c\u0648\u06a9\u0627\u0631\u060c \u0686\u0647 \u06a9\u0627\u0631\u06cc \u0628\u0627\u06cc\u062f \u0627\u0646\u062c\u0627\u0645 \u0628\u0634\u0647\u060c \u0647\u0631 \u062c\u0632\u0626\u06cc\u0627\u062a \u0645\u0647\u0645\u06cc). \u0647\u0648\u0634 \u0645\u0635\u0646\u0648\u0639\u06cc \u0645\u0627 \u0647\u0645\u06cc\u0646 \u0627\u0644\u0627\u0646 \u062e\u0644\u0627\u0635\u0647\u200c\u0627\u0634 \u0645\u06cc\u200c\u06a9\u0646\u0647 \u0648 \u0645\u06cc\u200c\u0641\u0631\u0633\u062a\u0647 \u067e\u06cc\u0634 \u062a\u06cc\u0645 \u0645\u0627.",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"id": "sheets-read-customer-freetext",
"name": "\u062e\u0648\u0627\u0646\u062f\u0646 \u0648\u0636\u0639\u06cc\u062a \u0645\u0634\u062a\u0631\u06cc (\u067e\u06cc\u0627\u0645 \u0622\u0632\u0627\u062f)",
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.5,
"position": [
-880,
500
],
"parameters": {
"operation": "read",
"documentId": {
"mode": "list",
"value": "PLACEHOLDER_SPREADSHEET_ID"
},
"sheetName": {
"mode": "name",
"value": "Customers"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
},
"alwaysOutputData": true
},
{
"id": "code-check-awaiting",
"name": "\u0628\u0631\u0631\u0633\u06cc \u0648\u0636\u0639\u06cc\u062a \u0645\u0634\u062a\u0631\u06cc (\u067e\u06cc\u0627\u0645 \u0622\u0632\u0627\u062f)",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-640,
500
],
"parameters": {
"jsCode": "const ctx = $('\u062a\u0634\u062e\u06cc\u0635 \u0646\u0648\u0639 \u067e\u06cc\u0627\u0645').first().json;\nconst rows = $input.all().map((i) => i.json);\nconst row = rows.find((r) => String(r.telegram_user_id) === String(ctx.chatId));\nconst pending = row?.pending_state || \"\";\nconst m = pending.match(/^awaiting_requirements:(.+)$/);\n\nreturn [{\n json: {\n ...ctx,\n hasPhone: !!(row && row.phone),\n awaitingOrderId: m ? m[1] : null,\n chatHistory: row?.chat_history || \"[]\",\n },\n}];"
}
},
{
"id": "if-awaiting-requirements",
"name": "\u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631 \u0646\u06cc\u0627\u0632\u0647\u0627\u0633\u062a\u061f",
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
-400,
500
],
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "loose"
},
"conditions": [
{
"leftValue": "={{ $json.awaitingOrderId }}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "notEmpty"
}
}
],
"combinator": "and"
}
}
},
{
"id": "http-openai-summarize",
"name": "\u062e\u0644\u0627\u0635\u0647\u200c\u0633\u0627\u0632\u06cc \u0646\u06cc\u0627\u0632\u0647\u0627 \u0628\u0627 \u0647\u0648\u0634 \u0645\u0635\u0646\u0648\u0639\u06cc",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
-160,
400
],
"parameters": {
"method": "POST",
"url": "https://api.openai.com/v1/chat/completions",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "content-type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={{ JSON.stringify({\n model: \"gpt-4o-mini\",\n messages: [\n { role: \"system\", content: \"\u06cc\u06a9 \u062a\u062d\u0644\u06cc\u0644\u200c\u06af\u0631 \u0646\u06cc\u0627\u0632\u0645\u0646\u062f\u06cc \u0645\u0634\u062a\u0631\u06cc \u0628\u0631\u0627\u06cc \u0627\u0633\u062a\u0648\u062f\u06cc\u0648\u06cc \u0627\u062a\u0648\u0645\u0627\u0633\u06cc\u0648\u0646 IR-CLU \u0647\u0633\u062a\u06cc. \u067e\u06cc\u0627\u0645 \u0645\u0634\u062a\u0631\u06cc \u0631\u0627 \u062f\u0631 \u0686\u0646\u062f \u062e\u0637 \u062e\u0644\u0627\u0635\u0647\u200c\u06cc \u0641\u0627\u0631\u0633\u06cc\u060c \u0634\u0641\u0627\u0641 \u0648 \u06a9\u0627\u0631\u0628\u0631\u062f\u06cc \u0628\u0631\u0627\u06cc \u062a\u06cc\u0645 \u0641\u0646\u06cc \u0628\u0627\u0632\u0646\u0648\u06cc\u0633\u06cc \u06a9\u0646\u061b \u0646\u0648\u0639 \u06a9\u0633\u0628\u200c\u0648\u06a9\u0627\u0631\u060c \u062e\u0648\u0627\u0633\u062a\u0647 \u0627\u0635\u0644\u06cc\u060c \u0648 \u0647\u0631 \u062c\u0632\u0626\u06cc\u0627\u062a \u0645\u0647\u0645\u06cc \u06a9\u0647 \u0630\u06a9\u0631 \u06a9\u0631\u062f\u0647 \u0631\u0627 \u0646\u06af\u0647 \u062f\u0627\u0631. \u0641\u0642\u0637 \u062e\u0644\u0627\u0635\u0647 \u0631\u0627 \u0628\u0646\u0648\u06cc\u0633\u060c \u0628\u062f\u0648\u0646 \u0645\u0642\u062f\u0645\u0647.\" },\n { role: \"user\", content: $json.text }\n ]\n}) }}"
},
"credentials": {
"httpHeaderAuth": {
"name": "<your credential>"
}
}
},
{
"id": "shape-update-requirements",
"name": "\u0622\u0645\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u062e\u0644\u0627\u0635\u0647 \u0646\u06cc\u0627\u0632\u0647\u0627",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-40,
400
],
"parameters": {
"jsCode": "const ctx = $('\u0628\u0631\u0631\u0633\u06cc \u0648\u0636\u0639\u06cc\u062a \u0645\u0634\u062a\u0631\u06cc (\u067e\u06cc\u0627\u0645 \u0622\u0632\u0627\u062f)').first().json;\nconst summary = $json.choices[0].message.content;\nreturn [{\n json: {\n order_id: ctx.awaitingOrderId,\n requirements_summary: summary,\n status: 'awaiting_payment',\n },\n}];"
}
},
{
"id": "sheets-update-requirements",
"name": "\u062b\u0628\u062a \u062e\u0644\u0627\u0635\u0647 \u0646\u06cc\u0627\u0632\u0647\u0627 \u062f\u0631 \u0633\u0641\u0627\u0631\u0634",
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.5,
"position": [
80,
400
],
"parameters": {
"operation": "update",
"documentId": {
"mode": "list",
"value": "PLACEHOLDER_SPREADSHEET_ID"
},
"sheetName": {
"mode": "name",
"value": "Orders"
},
"columns": {
"mappingMode": "autoMapInputData",
"value": {},
"matchingColumns": [
"order_id"
]
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"id": "shape-clear-pending",
"name": "\u0622\u0645\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u067e\u0627\u06a9 \u06a9\u0631\u062f\u0646 \u0648\u0636\u0639\u06cc\u062a",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
200,
400
],
"parameters": {
"jsCode": "const ctx = $('\u0628\u0631\u0631\u0633\u06cc \u0648\u0636\u0639\u06cc\u062a \u0645\u0634\u062a\u0631\u06cc (\u067e\u06cc\u0627\u0645 \u0622\u0632\u0627\u062f)').first().json;\nreturn [{\n json: {\n telegram_user_id: ctx.chatId,\n pending_state: '',\n },\n}];"
}
},
{
"id": "sheets-clear-pending",
"name": "\u067e\u0627\u06a9 \u06a9\u0631\u062f\u0646 \u0648\u0636\u0639\u06cc\u062a \u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631",
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.5,
"position": [
320,
400
],
"parameters": {
"operation": "appendOrUpdate",
"documentId": {
"mode": "list",
"value": "PLACEHOLDER_SPREADSHEET_ID"
},
"sheetName": {
"mode": "name",
"value": "Customers"
},
"columns": {
"mappingMode": "autoMapInputData",
"value": {},
"matchingColumns": [
"telegram_user_id"
]
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"id": "sheets-read-order-for-payment",
"name": "\u062e\u0648\u0627\u0646\u062f\u0646 \u0633\u0641\u0627\u0631\u0634 \u0628\u0631\u0627\u06cc \u0646\u0645\u0627\u06cc\u0634 \u067e\u0631\u062f\u0627\u062e\u062a",
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.5,
"position": [
560,
400
],
"parameters": {
"operation": "read",
"documentId": {
"mode": "list",
"value": "PLACEHOLDER_SPREADSHEET_ID"
},
"sheetName": {
"mode": "name",
"value": "Orders"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
},
"alwaysOutputData": true
},
{
"id": "code-find-order-for-payment",
"name": "\u067e\u06cc\u062f\u0627 \u06a9\u0631\u062f\u0646 \u0633\u0641\u0627\u0631\u0634 \u0628\u0631\u0627\u06cc \u0646\u0645\u0627\u06cc\u0634 \u067e\u0631\u062f\u0627\u062e\u062a",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
680,
400
],
"parameters": {
"jsCode": "const ctx = $('\u0628\u0631\u0631\u0633\u06cc \u0648\u0636\u0639\u06cc\u062a \u0645\u0634\u062a\u0631\u06cc (\u067e\u06cc\u0627\u0645 \u0622\u0632\u0627\u062f)').first().json;\nconst rows = $input.all().map((i) => i.json);\nconst order = rows.find((r) => r.order_id === ctx.awaitingOrderId);\n\nreturn [{ json: { chatId: ctx.chatId, order: order || null } }];"
}
},
{
"id": "tg-show-payment-info",
"name": "\u0646\u0645\u0627\u06cc\u0634 \u0627\u0637\u0644\u0627\u0639\u0627\u062a \u067e\u0631\u062f\u0627\u062e\u062a",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
800,
400
],
"parameters": {
"resource": "message",
"operation": "sendMessage",
"chatId": "={{ $json.chatId }}",
"text": "=\u0645\u0645\u0646\u0648\u0646\u060c \u0646\u06cc\u0627\u0632\u0647\u0627\u062a \u062b\u0628\u062a \u0634\u062f \u2705\n\n\u0628\u0631\u0627\u06cc \u062a\u06a9\u0645\u06cc\u0644 \u0633\u0641\u0627\u0631\u0634\u060c \u0645\u0628\u0644\u063a \u0631\u0648 \u06a9\u0627\u0631\u062a\u200c\u0628\u0647\u200c\u06a9\u0627\u0631\u062a \u06a9\u0646:\n\n\ud83d\udcb3 \u0634\u0645\u0627\u0631\u0647 \u06a9\u0627\u0631\u062a: PLACEHOLDER_CARD_NUMBER\n\u0628\u0647 \u0646\u0627\u0645: PLACEHOLDER_CARD_HOLDER\n\u0645\u0628\u0644\u063a: {{ Number($json.order.amount).toLocaleString('fa-IR') }} \u062a\u0648\u0645\u0627\u0646\n\n\u0628\u0639\u062f \u0627\u0632 \u0648\u0627\u0631\u06cc\u0632\u060c \u0647\u0645\u06cc\u0646\u200c\u062c\u0627 \u0639\u06a9\u0633 \u0631\u0633\u06cc\u062f/\u0641\u06cc\u0634 \u0648\u0627\u0631\u06cc\u0632\u06cc \u0631\u0648 \u0628\u0641\u0631\u0633\u062a \u062a\u0627 \u062a\u06cc\u0645 \u0645\u0627 \u0628\u0631\u0631\u0633\u06cc \u0648 \u062a\u0623\u06cc\u06cc\u062f \u06a9\u0646\u0647.",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"id": "if-has-phone-freetext",
"name": "\u0634\u0645\u0627\u0631\u0647 \u062b\u0628\u062a \u0634\u062f\u0647\u061f (\u067e\u06cc\u0627\u0645 \u0622\u0632\u0627\u062f)",
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
-160,
700
],
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "loose"
},
"conditions": [
{
"leftValue": "={{ $json.hasPhone }}",
"rightValue": true,
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
}
}
],
"combinator": "and"
}
}
},
{
"id": "code-build-ai-chat",
"name": "\u0633\u0627\u062e\u062a \u067e\u06cc\u0627\u0645 \u06af\u0641\u062a\u06af\u0648 \u0628\u0627 \u0647\u0648\u0634 \u0645\u0635\u0646\u0648\u0639\u06cc",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
80,
800
],
"parameters": {
"jsCode": "// ============================================================\n// \u0641\u0642\u0637 \u0647\u0645\u06cc\u0646 \u0628\u062e\u0634 (SALES_KNOWLEDGE) \u0631\u0648 \u0648\u06cc\u0631\u0627\u06cc\u0634 \u06a9\u0646 \u062a\u0627 \u0645\u062d\u062a\u0648\u0627\u06cc \u0641\u0631\u0648\u0634 \u0648\n// \u0645\u0639\u0631\u0641\u06cc\u200c\u0627\u06cc \u06a9\u0647 \u0647\u0648\u0634 \u0645\u0635\u0646\u0648\u0639\u06cc \u0645\u0648\u0642\u0639 \u0686\u062a \u0628\u0627 \u0645\u0634\u062a\u0631\u06cc\u200c\u0647\u0627\u06cc \u062c\u062f\u06cc\u062f \u0627\u0632\u0634 \u0627\u0633\u062a\u0641\u0627\u062f\u0647\n// \u0645\u06cc\u200c\u06a9\u0646\u0647 \u0639\u0648\u0636 \u0628\u0634\u0647. \u0628\u0642\u06cc\u0647\u200c\u06cc \u0627\u06cc\u0646 \u06a9\u062f \u0631\u0648 \u062f\u0633\u062a \u0646\u0632\u0646.\n// ============================================================\nconst SALES_KNOWLEDGE = `\n\u062a\u0648 \u062f\u0633\u062a\u06cc\u0627\u0631 \u0641\u0631\u0648\u0634 \u0627\u0633\u062a\u0648\u062f\u06cc\u0648\u06cc \u0627\u062a\u0648\u0645\u0627\u0633\u06cc\u0648\u0646 IR-CLU \u0647\u0633\u062a\u06cc \u0648 \u062f\u0627\u0631\u06cc \u062a\u0648\u06cc \u062a\u0644\u06af\u0631\u0627\u0645 \u0628\u0627 \u06cc\u06a9 \u0645\u0634\u062a\u0631\u06cc \u0628\u0627\u0644\u0642\u0648\u0647 \u0686\u062a \u0645\u06cc\u200c\u06a9\u0646\u06cc.\n\n\u062f\u0631\u0628\u0627\u0631\u0647\u200c\u06cc IR-CLU:\n- IR-CLU \u0627\u067e\u0644\u06cc\u06a9\u06cc\u0634\u0646\u200c\u0647\u0627 \u0648 \u0631\u0628\u0627\u062a\u200c\u0647\u0627\u06cc \u0622\u0645\u0627\u062f\u0647 \u0628\u0631\u0627\u06cc \u0627\u062a\u0648\u0645\u0627\u0633\u06cc\u0648\u0646 \u06a9\u0633\u0628\u200c\u0648\u06a9\u0627\u0631 \u0645\u06cc\u200c\u0633\u0627\u0632\u062f \u0648 \u0628\u0627 \u0627\u0634\u062a\u0631\u0627\u06a9 \u0645\u0627\u0647\u0627\u0646\u0647 \u0627\u0632 \u0637\u0631\u06cc\u0642 \u0647\u0645\u06cc\u0646 \u0631\u0628\u0627\u062a \u062a\u0644\u06af\u0631\u0627\u0645 \u0645\u06cc\u200c\u0641\u0631\u0648\u0634\u062f.\n- \u0645\u062d\u0635\u0648\u0644 \u0627\u0635\u0644\u06cc: \u0633\u0646\u0627\u0631\u06cc\u0648 (Senaryo) \u2014 \u06cc\u06a9 \u0627\u067e\u0644\u06cc\u06a9\u06cc\u0634\u0646 \u062f\u0633\u06a9\u062a\u0627\u067e \u0648\u06cc\u0646\u062f\u0648\u0632 \u06a9\u0647 \u06cc\u06a9 \u0645\u0648\u0636\u0648\u0639 \u0645\u06cc\u200c\u06af\u06cc\u0631\u062f\u060c \u062f\u0631 \u06cc\u0648\u062a\u06cc\u0648\u0628 \u0648 \u0627\u06cc\u0646\u0633\u062a\u0627\u06af\u0631\u0627\u0645 \u062f\u0646\u0628\u0627\u0644 \u0648\u06cc\u062f\u06cc\u0648\u0647\u0627\u06cc \u0648\u0627\u0642\u0639\u0627\u064b \u0648\u0627\u06cc\u0631\u0627\u0644\u200c\u0634\u062f\u0647\u200c\u06cc \u0627\u06cc\u0631\u0627\u0646\u06cc\u0650 \u0645\u0631\u062a\u0628\u0637 \u0645\u06cc\u200c\u06af\u0631\u062f\u062f\u060c \u0628\u0627 \u0647\u0648\u0634 \u0645\u0635\u0646\u0648\u0639\u06cc \u062a\u062d\u0644\u06cc\u0644 \u0645\u06cc\u200c\u06a9\u0646\u062f \u062f\u0642\u06cc\u0642\u0627\u064b \u0686\u0631\u0627 \u0648\u0627\u06cc\u0631\u0627\u0644 \u0634\u062f\u0647\u200c\u0627\u0646\u062f\u060c \u0648 \u0686\u0646\u062f \u0627\u06cc\u062f\u0647\u200c\u06cc \u06a9\u0627\u0645\u0644\u0627\u064b \u062c\u062f\u06cc\u062f \u0648 \u0622\u0645\u0627\u062f\u0647\u200c\u06cc \u0641\u06cc\u0644\u0645\u200c\u0628\u0631\u062f\u0627\u0631\u06cc (\u0633\u0646\u0627\u0631\u06cc\u0648\u06cc \u06a9\u0627\u0645\u0644\u060c \u0634\u0627\u062a\u200c\u0644\u06cc\u0633\u062a\u060c \u06a9\u067e\u0634\u0646\u060c \u0647\u0634\u062a\u06af) \u062a\u0648\u0644\u06cc\u062f \u0645\u06cc\u200c\u06a9\u0646\u062f\u061b \u0639\u0645\u0644\u06a9\u0631\u062f \u0648\u0627\u0642\u0639\u06cc \u067e\u0633\u062a \u0645\u0646\u062a\u0634\u0631\u0634\u062f\u0647 \u0631\u0627 \u0647\u0645 \u0628\u0639\u062f\u0627\u064b \u0645\u06cc\u200c\u0633\u0646\u062c\u062f \u0648 \u0645\u06cc\u200c\u06af\u0648\u06cc\u062f \u06a9\u062f\u0627\u0645 \u0627\u0644\u06af\u0648 \u0648\u0627\u0642\u0639\u0627\u064b \u062c\u0648\u0627\u0628 \u062f\u0627\u062f.\n- \u0647\u0631 \u0645\u062d\u0635\u0648\u0644 \u067e\u0631\u062f\u0627\u062e\u062a \u06a9\u0627\u0631\u062a\u200c\u0628\u0647\u200c\u06a9\u0627\u0631\u062a \u062f\u0627\u0631\u062f\u061b \u0628\u0639\u062f \u0627\u0632 \u062a\u0627\u06cc\u06cc\u062f \u062a\u06cc\u0645\u060c \u0644\u0627\u06cc\u0633\u0646\u0633/\u062f\u0633\u062a\u0631\u0633\u06cc \u0641\u0648\u0631\u06cc \u0635\u0627\u062f\u0631 \u0645\u06cc\u200c\u0634\u0648\u062f.\n\n\u0648\u0638\u06cc\u0641\u0647\u200c\u06cc \u062a\u0648:\n- \u0628\u0627 \u0644\u062d\u0646 \u062f\u0648\u0633\u062a\u0627\u0646\u0647\u060c \u0641\u0627\u0631\u0633\u06cc \u0648 \u062d\u0631\u0641\u0647\u200c\u0627\u06cc \u0635\u062d\u0628\u062a \u06a9\u0646.\n- \u0646\u06cc\u0627\u0632 \u0648\u0627\u0642\u0639\u06cc \u0645\u0634\u062a\u0631\u06cc \u0631\u0648 \u0628\u0641\u0647\u0645 \u0648 \u0646\u0634\u0648\u0646 \u0628\u062f\u0647 IR-CLU \u0686\u0637\u0648\u0631 \u0627\u0648\u0646 \u0645\u0634\u06a9\u0644 \u0631\u0648 \u062d\u0644 \u0645\u06cc\u200c\u06a9\u0646\u0647.\n- \u0647\u06cc\u0686\u200c\u0648\u0642\u062a \u0642\u06cc\u0645\u062a \u062f\u0642\u06cc\u0642 \u0642\u0637\u0639\u06cc \u0627\u0639\u0644\u0627\u0645 \u0646\u06a9\u0646 \u0645\u06af\u0631 \u0645\u0637\u0645\u0626\u0646 \u0628\u0627\u0634\u06cc\u061b \u0628\u0631\u0627\u06cc \u0642\u06cc\u0645\u062a \u0648 \u0634\u0631\u0648\u0639 \u062e\u0631\u06cc\u062f \u0645\u0634\u062a\u0631\u06cc \u0631\u0648 \u0628\u0647 \u0635\u0641\u062d\u0647\u200c\u06cc \u0641\u0631\u0648\u0634\u06af\u0627\u0647 \u0633\u0627\u06cc\u062a (irclu.com/store) \u0647\u062f\u0627\u06cc\u062a \u06a9\u0646 \u062a\u0627 \u0631\u0648\u06cc \u00ab\u062e\u0631\u06cc\u062f \u062f\u0631 \u062a\u0644\u06af\u0631\u0627\u0645\u00bb \u0647\u0645\u0648\u0646 \u0645\u062d\u0635\u0648\u0644 \u0628\u0632\u0646\u0647.\n- \u0627\u06af\u0647 \u0645\u0634\u062a\u0631\u06cc \u062f\u0631\u0628\u0627\u0631\u0647\u200c\u06cc \u0648\u0636\u0639\u06cc\u062a \u0633\u0641\u0627\u0631\u0634\u060c \u0644\u0627\u06cc\u0633\u0646\u0633\u060c \u06cc\u0627 \u067e\u0631\u062f\u0627\u062e\u062a\u0634 \u067e\u0631\u0633\u06cc\u062f\u060c \u0647\u06cc\u0686\u200c\u0648\u0642\u062a \u062c\u0632\u0626\u06cc\u0627\u062a \u0641\u0631\u0636\u06cc \u0646\u0633\u0627\u0632 (\u0645\u062b\u0644 \u0627\u06cc\u0645\u06cc\u0644\u060c \u062d\u0633\u0627\u0628 \u06a9\u0627\u0631\u0628\u0631\u06cc \u0633\u0627\u06cc\u062a\u060c \u0644\u06cc\u0646\u06a9 \u0648\u0631\u0648\u062f\u060c \u06cc\u0627 \u0647\u0631 \u0686\u06cc\u0632 \u062f\u06cc\u06af\u0647\u200c\u0627\u06cc \u06a9\u0647 \u0645\u0637\u0645\u0626\u0646 \u0646\u06cc\u0633\u062a\u06cc \u0648\u062c\u0648\u062f \u062f\u0627\u0631\u0647) \u2014 \u0641\u0642\u0637 \u0628\u06af\u0648 \u06a9\u0647 \u0647\u0645\u06cc\u0646\u200c\u062c\u0627 \u062a\u0648\u06cc \u0647\u0645\u06cc\u0646 \u0686\u062a\u060c \u0628\u0639\u062f \u0627\u0632 \u0628\u0631\u0631\u0633\u06cc \u0631\u0633\u06cc\u062f\u060c \u0644\u0627\u06cc\u0633\u0646\u0633/\u067e\u0627\u0633\u062e \u0628\u0631\u0627\u0634 \u0627\u0631\u0633\u0627\u0644 \u0645\u06cc\u200c\u0634\u0647.\n- \u067e\u0627\u0633\u062e\u200c\u0647\u0627 \u06a9\u0648\u062a\u0627\u0647 \u0648 \u0645\u0641\u06cc\u062f \u0628\u0627\u0634\u0646 (\u062d\u062f\u0627\u06a9\u062b\u0631 \u06f4 \u062a\u0627 \u06f5 \u062c\u0645\u0644\u0647)\u060c \u0627\u0632 \u062a\u06a9\u0631\u0627\u0631 \u0645\u0635\u0646\u0648\u0639\u06cc \u0648 \u0634\u0639\u0627\u0631 \u062e\u0627\u0644\u06cc \u062e\u0648\u062f\u062f\u0627\u0631\u06cc \u06a9\u0646.\n`.trim();\n\nconst MAX_HISTORY = 6; // \u062d\u062f\u0627\u06a9\u062b\u0631 \u06f3 \u062a\u0628\u0627\u062f\u0644 \u0631\u0641\u062a\u200c\u0648\u0628\u0631\u06af\u0634\u062a (\u06f6 \u067e\u06cc\u0627\u0645) \u0628\u0647 \u06cc\u0627\u062f \u0633\u067e\u0631\u062f\u0647 \u0645\u06cc\u200c\u0634\u0647\n\nconst t = $json;\nlet history = [];\ntry {\n history = JSON.parse(t.chatHistory || \"[]\");\n} catch (e) {\n history = [];\n}\nif (!Array.isArray(history)) history = [];\nhistory = history.slice(-MAX_HISTORY);\n\nconst messages = [\n { role: \"system\", content: SALES_KNOWLEDGE },\n ...history,\n { role: \"user\", content: t.text },\n];\n\nreturn [{ json: { chatId: t.chatId, text: t.text, historyBeforeReply: history, messages } }];"
}
},
{
"id": "http-openai-chat",
"name": "\u0686\u062a \u0641\u0631\u0648\u0634 \u0628\u0627 \u0647\u0648\u0634 \u0645\u0635\u0646\u0648\u0639\u06cc",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
320,
800
],
"parameters": {
"method": "POST",
"url": "https://api.openai.com/v1/chat/completions",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "content-type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={{ JSON.stringify({ model: \"gpt-4o-mini\", messages: $json.messages }) }}"
},
"credentials": {
"httpHeaderAuth": {
"name": "<your credential>"
}
}
},
{
"id": "code-finalize-chat-reply",
"name": "\u0622\u0645\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u067e\u0627\u0633\u062e \u0648 \u062a\u0627\u0631\u06cc\u062e\u0686\u0647 \u06af\u0641\u062a\u06af\u0648",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
560,
800
],
"parameters": {
"jsCode": "const ctx = $('\u0633\u0627\u062e\u062a \u067e\u06cc\u0627\u0645 \u06af\u0641\u062a\u06af\u0648 \u0628\u0627 \u0647\u0648\u0634 \u0645\u0635\u0646\u0648\u0639\u06cc').first().json;\nconst replyText = $json.choices[0].message.content;\n\nconst newHistory = [\n ...ctx.historyBeforeReply,\n { role: 'user', content: ctx.text },\n { role: 'assistant', content: replyText },\n].slice(-6);\n\nreturn [{\n json: {\n chatId: ctx.chatId,\n replyText,\n chat_history: JSON.stringify(newHistory),\n },\n}];"
}
},
{
"id": "tg-send-ai-reply",
"name": "\u0627\u0631\u0633\u0627\u0644 \u067e\u0627\u0633\u062e \u0647\u0648\u0634 \u0645\u0635\u0646\u0648\u0639\u06cc \u0628\u0647 \u0645\u0634\u062a\u0631\u06cc",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
800,
720
],
"parameters": {
"resource": "message",
"operation": "sendMessage",
"chatId": "={{ $json.chatId }}",
"text": "={{ $json.replyText }}",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"id": "shape-chat-history",
"name": "\u0622\u0645\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u0631\u062f\u06cc\u0641 \u062a\u0627\u0631\u06cc\u062e\u0686\u0647 \u06af\u0641\u062a\u06af\u0648",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
680,
900
],
"parameters": {
"jsCode": "const t = $json;\nreturn [{\n json: {\n telegram_user_id: t.chatId,\n chat_history: t.chat_history,\n },\n}];"
}
},
{
"id": "sheets-save-chat-history",
"name": "\u0630\u062e\u06cc\u0631\u0647 \u062a\u0627\u0631\u06cc\u062e\u0686\u0647 \u06af\u0641\u062a\u06af\u0648",
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.5,
"position": [
800,
900
],
"parameters": {
"operation": "appendOrUpdate",
"documentId": {
"mode": "list",
"value": "PLACEHOLDER_SPREADSHEET_ID"
},
"sheetName": {
"mode": "name",
"value": "Customers"
},
"columns": {
"mappingMode": "autoMapInputData",
"value": {},
"matchingColumns": [
"telegram_user_id"
]
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"id": "sheets-read-orders-for-receipt",
"name": "\u062e\u0648\u0627\u0646\u062f\u0646 \u0633\u0641\u0627\u0631\u0634\u200c\u0647\u0627 (\u0631\u0633\u06cc\u062f)",
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.5,
"position": [
-880,
1100
],
"parameters": {
"operation": "read",
"documentId": {
"mode": "list",
"value": "PLACEHOLDER_SPREADSHEET_ID"
},
"sheetName": {
"mode": "name",
"value": "Orders"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
},
"alwaysOutputData": true
},
{
"id": "code-find-pending-order",
"name": "\u067e\u06cc\u062f\u0627 \u06a9\u0631\u062f\u0646 \u0633\u0641\u0627\u0631\u0634 \u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631 \u067e\u0631\u062f\u0627\u062e\u062a",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-640,
1100
],
"parameters": {
"jsCode": "const ctx = $('\u062a\u0634\u062e\u06cc\u0635 \u0646\u0648\u0639 \u067e\u06cc\u0627\u0645').first().json;\nconst rows = $input.all().map((i) => i.json);\nconst order = rows.find((r) => String(r.telegram_user_id) === String(ctx.chatId) && r.status === 'awaiting_payment');\n\nreturn [{ json: { ...ctx, order: order || null } }];"
}
},
{
"id": "if-pending-order-found",
"name": "\u0633\u0641\u0627\u0631\u0634\u06cc \u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631 \u067e\u0631\u062f\u0627\u062e\u062a \u0647\u0633\u062a\u061f",
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
-400,
1100
],
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "loose"
},
"conditions": [
{
"leftValue": "={{ $json.order }}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "notEmpty"
}
}
],
"combinator": "and"
}
}
},
{
"id": "tg-no-pending-order",
"name": "\u0633\u0641\u0627\u0631\u0634\u06cc \u067e\u06cc\u062f\u0627 \u0646\u0634\u062f",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
-160,
1220
],
"parameters": {
"resource": "message",
"operation": "sendMessage",
"chatId": "={{ $json.chatId }}",
"text": "\u0633\u0641\u0627\u0631\u0634 \u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631 \u067e\u0631\u062f\u0627\u062e\u062a\u06cc \u0627\u0632 \u062a\u0648 \u067e\u06cc\u062f\u0627 \u0646\u06a9\u0631\u062f\u0645. \u0627\u0632 \u0635\u0641\u062d\u0647\u200c\u06cc \u0641\u0631\u0648\u0634\u06af\u0627\u0647 \u062f\u0648\u0628\u0627\u0631\u0647 \u0634\u0631\u0648\u0639 \u06a9\u0646.",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"id": "shape-mark-receipt",
"name": "\u0622\u0645\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u0628\u0647\u200c\u0631\u0648\u0632\u0631\u0633\u0627\u0646\u06cc \u0631\u0633\u06cc\u062f",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-280,
1020
],
"parameters": {
"jsCode": "const t = $json;\nreturn [{\n json: {\n order_id: t.order.order_id,\n status: 'pending_review',\n receipt_file_id: $('\u062a\u0634\u062e\u06cc\u0635 \u0646\u0648\u0639 \u067e\u06cc\u0627\u0645').first().json.photoFileId,\n },\n}];"
}
},
{
"id": "sheets-mark-receipt-received",
"name": "\u062b\u0628\u062a \u0631\u0633\u06cc\u062f \u067e\u0631\u062f\u0627\u062e\u062a",
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.5,
"position": [
-160,
1020
],
"parameters": {
"operation": "update",
"documentId": {
"mode": "list",
"value": "PLACEHOLDER_SPREADSHEET_ID"
},
"sheetName": {
"mode": "name",
"value": "Orders"
},
"columns": {
"mappingMode": "autoMapInputData",
"value": {},
"matchingColumns": [
"order_id"
]
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"id": "tg-ack-receipt",
"name": "\u062a\u0623\u06cc\u06cc\u062f \u062f\u0631\u06cc\u0627\u0641\u062a \u0631\u0633\u06cc\u062f \u0628\u0647 \u0645\u0634\u062a\u0631\u06cc",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
80,
1020
],
"parameters": {
"resource": "message",
"operation": "sendMessage",
"chatId": "={{ $('\u067e\u06cc\u062f\u
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.
googleSheetsOAuth2ApihttpHeaderAuthtelegramApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
IR-CLU — ربات فروش (احراز هویت + هوش مصنوعی + پرداخت کارتبهکارت). Uses telegramTrigger, googleSheets, telegram, httpRequest. Event-driven trigger; 50 nodes.
Source: https://github.com/manbom/IR-CLU/blob/e30da84e9e888ade86507be696a99a54552a9b6a/automation/n8n-store-bot-workflow.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.
IR-CLU — ربات فروش (احراز هویت + هوش مصنوعی + پرداخت کارتبهکارت). Uses telegramTrigger, googleSheets, telegram, httpRequest. Event-driven trigger; 83 nodes.
IR-CLU — ربات فروش (احراز هویت + هوش مصنوعی + پرداخت کارتبهکارت). Uses telegramTrigger, googleSheets, telegram, httpRequest. Event-driven trigger; 76 nodes.
Try on any outfit virtually - right inside Telegram. A user sends a person photo, then a garment photo (captioned ), and the bot replies with an AI-generated try-on result image using a dedicated Virt
TGBot. Uses telegram, googleSheets, telegramTrigger, httpRequest. Event-driven trigger; 30 nodes.
This n8n workflow enables Telegram users to interact with multiple AI models dynamically using #model_id commands. It also supports a /models command to list all available models. Each user has a dail