{
  "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\u0627 \u06a9\u0631\u062f\u0646 \u0633\u0641\u0627\u0631\u0634 \u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631 \u067e\u0631\u062f\u0627\u062e\u062a').first().json.chatId }}",
        "text": "\u0631\u0633\u06cc\u062f\u062a \u0631\u0633\u06cc\u062f \u2705 \u062a\u06cc\u0645 \u0645\u0627 \u0638\u0631\u0641 \u0686\u0646\u062f \u0633\u0627\u0639\u062a \u0628\u0631\u0631\u0633\u06cc \u0645\u06cc\u200c\u06a9\u0646\u0647 \u0648 \u0628\u0647\u062a \u0627\u0637\u0644\u0627\u0639 \u0645\u06cc\u200c\u062f\u0647.",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "tg-forward-receipt-admin",
      "name": "\u0627\u0631\u0633\u0627\u0644 \u0631\u0633\u06cc\u062f \u0628\u0647 \u0627\u062f\u0645\u06cc\u0646",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        320,
        1020
      ],
      "parameters": {
        "resource": "message",
        "operation": "sendPhoto",
        "chatId": "6452519019",
        "file": "={{ $('\u062a\u0634\u062e\u06cc\u0635 \u0646\u0648\u0639 \u067e\u06cc\u0627\u0645').first().json.photoFileId }}",
        "caption": "=\ud83d\udcb3 \u0631\u0633\u06cc\u062f \u067e\u0631\u062f\u0627\u062e\u062a \u062c\u062f\u06cc\u062f\n\u0633\u0641\u0627\u0631\u0634: {{ $('\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').first().json.order.order_id }}\n\u0645\u062d\u0635\u0648\u0644: {{ $('\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').first().json.order.product_slug }}\n\u0645\u0634\u062a\u0631\u06cc: @{{ $('\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').first().json.order.telegram_username }}\n\u0645\u0628\u0644\u063a: {{ Number($('\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').first().json.order.amount).toLocaleString('fa-IR') }} \u062a\u0648\u0645\u0627\u0646\n\u0646\u06cc\u0627\u0632\u0647\u0627: {{ $('\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').first().json.order.requirements_summary }}\n\n(\u06cc\u0627 \u0627\u06af\u0647 \u062f\u06a9\u0645\u0647\u200c\u0647\u0627 \u06a9\u0627\u0631 \u0646\u06a9\u0631\u062f\u060c \u0628\u0646\u0648\u06cc\u0633: \u062a\u0627\u06cc\u06cc\u062f {{ $('\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').first().json.order.order_id }})",
        "replyMarkup": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "\u2705 \u062a\u0627\u06cc\u06cc\u062f \u0648 \u0627\u0631\u0633\u0627\u0644 \u0644\u0627\u06cc\u0633\u0646\u0633",
                    "additionalFields": {
                      "callback_data": "={{ 'approve:' + $('\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').first().json.order.order_id }}"
                    }
                  },
                  {
                    "text": "\u274c \u0631\u062f \u06a9\u0631\u062f\u0646",
                    "additionalFields": {
                      "callback_data": "={{ 'reject:' + $('\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').first().json.order.order_id }}"
                    }
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "sheets-read-orders-for-decision",
      "name": "\u062e\u0648\u0627\u0646\u062f\u0646 \u0633\u0641\u0627\u0631\u0634\u200c\u0647\u0627 (\u062a\u0635\u0645\u06cc\u0645 \u0627\u062f\u0645\u06cc\u0646)",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        -880,
        1500
      ],
      "parameters": {
        "operation": "read",
        "documentId": {
          "mode": "list",
          "value": "PLACEHOLDER_SPREADSHEET_ID"
        },
        "sheetName": {
          "mode": "name",
          "value": "Orders"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "alwaysOutputData": true
    },
    {
      "id": "code-match-decision-order",
      "name": "\u062a\u0637\u0628\u06cc\u0642 \u0633\u0641\u0627\u0631\u0634 \u0628\u0627 \u062a\u0635\u0645\u06cc\u0645",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -640,
        1500
      ],
      "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) => r.order_id === ctx.decisionOrderId);\n\nreturn [{ json: { ...ctx, order: order || null } }];"
      }
    },
    {
      "id": "if-already-processed",
      "name": "\u0642\u0628\u0644\u0627\u064b \u067e\u0631\u062f\u0627\u0632\u0634 \u0634\u062f\u0647\u061f",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -560,
        1500
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "leftValue": "={{ $json.order.status }}",
              "rightValue": "pending_review",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              }
            }
          ],
          "combinator": "and"
        }
      }
    },
    {
      "id": "tg-already-processed",
      "name": "\u0627\u0637\u0644\u0627\u0639 \u0633\u0641\u0627\u0631\u0634 \u0642\u0628\u0644\u0627\u064b \u067e\u0631\u062f\u0627\u0632\u0634\u200c\u0634\u062f\u0647",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -480,
        1580
      ],
      "parameters": {
        "resource": "message",
        "operation": "sendMessage",
        "chatId": "={{ $json.chatId }}",
        "text": "=\u0627\u06cc\u0646 \u0633\u0641\u0627\u0631\u0634 ({{ $json.order.order_id }}) \u0642\u0628\u0644\u0627\u064b \u067e\u0631\u062f\u0627\u0632\u0634 \u0634\u062f\u0647 \u2014 \u0648\u0636\u0639\u06cc\u062a \u0641\u0639\u0644\u06cc: {{ $json.order.status }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "if-decision-approve",
      "name": "\u062a\u0623\u06cc\u06cc\u062f \u06cc\u0627 \u0631\u062f\u061f",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -400,
        1500
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "leftValue": "={{ $json.decisionAction }}",
              "rightValue": "approve",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        }
      }
    },
    {
      "id": "if-already-delivered",
      "name": "\u0633\u0641\u0627\u0631\u0634 \u0642\u0628\u0644\u0627\u064b \u062a\u062d\u0648\u06cc\u0644 \u0634\u062f\u0647\u061f",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -280,
        1500
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "leftValue": "={{ $json.order.status }}",
              "rightValue": "delivered",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        }
      }
    },
    {
      "id": "tg-already-delivered",
      "name": "\u0627\u0637\u0644\u0627\u0639 \u062a\u062d\u0648\u06cc\u0644 \u062a\u06a9\u0631\u0627\u0631\u06cc \u0628\u0647 \u0627\u062f\u0645\u06cc\u0646",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -160,
        1560
      ],
      "parameters": {
        "resource": "message",
        "operation": "sendMessage",
        "chatId": "6452519019",
        "text": "=\u26a0\ufe0f \u0633\u0641\u0627\u0631\u0634 {{ $json.order.order_id }} \u0642\u0628\u0644\u0627\u064b \u062a\u062d\u0648\u06cc\u0644 \u062f\u0627\u062f\u0647 \u0634\u062f\u0647 \u0628\u0648\u062f \u2014 \u0628\u0631\u0627\u06cc \u062c\u0644\u0648\u06af\u06cc\u0631\u06cc \u0627\u0632 \u0635\u062f\u0648\u0631 \u0644\u0627\u06cc\u0633\u0646\u0633 \u062a\u06a9\u0631\u0627\u0631\u06cc\u060c \u0627\u06cc\u0646 \u062a\u0627\u06cc\u06cc\u062f\u0650 \u062f\u0648\u0628\u0627\u0631\u0647 \u0646\u0627\u062f\u06cc\u062f\u0647 \u06af\u0631\u0641\u062a\u0647 \u0634\u062f.\n\u0627\u06af\u0647 \u0648\u0627\u0642\u0639\u0627\u064b \u0644\u0627\u0632\u0645\u0647 \u0644\u0627\u06cc\u0633\u0646\u0633 \u062f\u0648\u0628\u0627\u0631\u0647 \u0635\u0627\u062f\u0631 \u0628\u0634\u0647\u060c \u0628\u0627\u06cc\u062f \u062f\u0633\u062a\u06cc \u0627\u0632 \u0634\u06cc\u062a Licenses \u0627\u0636\u0627\u0641\u0647\u200c\u0634 \u06a9\u0646\u06cc.",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "shape-mark-rejected",
      "name": "\u0622\u0645\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u0631\u062f \u0633\u0641\u0627\u0631\u0634",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -280,
        1620
      ],
      "parameters": {
        "jsCode": "const t = $json;\nreturn [{\n  json: {\n    order_id: t.order.order_id,\n    status: 'rejected',\n    reviewed_at: new Date().toISOString(),\n  },\n}];"
      }
    },
    {
      "id": "sheets-mark-rejected",
      "name": "\u062b\u0628\u062a \u0631\u062f \u0633\u0641\u0627\u0631\u0634",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        -160,
        1620
      ],
      "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-notify-rejected",
      "name": "\u0627\u0637\u0644\u0627\u0639 \u0631\u062f \u0628\u0647 \u0645\u0634\u062a\u0631\u06cc",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        80,
        1620
      ],
      "parameters": {
        "resource": "message",
        "operation": "sendMessage",
        "chatId": "={{ $('\u062a\u0637\u0628\u06cc\u0642 \u0633\u0641\u0627\u0631\u0634 \u0628\u0627 \u062a\u0635\u0645\u06cc\u0645').first().json.order.telegram_user_id }}",
        "text": "\u0631\u0633\u06cc\u062f \u067e\u0631\u062f\u0627\u062e\u062a\u062a \u062a\u0623\u06cc\u06cc\u062f \u0646\u0634\u062f. \u0644\u0637\u0641\u0627\u064b \u0628\u0627 \u067e\u0634\u062a\u06cc\u0628\u0627\u0646\u06cc (@bardiaaSam) \u062f\u0631 \u062a\u0645\u0627\u0633 \u0628\u0627\u0634.",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "shape-mark-approved",
      "name": "\u0622\u0645\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u062a\u0623\u06cc\u06cc\u062f \u0633\u0641\u0627\u0631\u0634",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -280,
        1400
      ],
      "parameters": {
        "jsCode": "const t = $json;\nreturn [{\n  json: {\n    order_id: t.order.order_id,\n    status: 'delivered',\n    reviewed_at: new Date().toISOString(),\n    expires_at: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString(),\n  },\n}];"
      }
    },
    {
      "id": "sheets-mark-approved",
      "name": "\u062b\u0628\u062a \u062a\u0623\u06cc\u06cc\u062f \u0633\u0641\u0627\u0631\u0634",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        -160,
        1400
      ],
      "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": "sheets-read-product-for-delivery",
      "name": "\u062e\u0648\u0627\u0646\u062f\u0646 \u0645\u062d\u0635\u0648\u0644 \u0628\u0631\u0627\u06cc \u062a\u062d\u0648\u06cc\u0644",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        80,
        1400
      ],
      "parameters": {
        "operation": "read",
        "documentId": {
          "mode": "list",
          "value": "PLACEHOLDER_SPREADSHEET_ID"
        },
        "sheetName": {
          "mode": "name",
          "value": "Products"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "alwaysOutputData": true
    },
    {
      "id": "code-match-product-delivery",
      "name": "\u062a\u0637\u0628\u06cc\u0642 \u0645\u062d\u0635\u0648\u0644 \u062a\u062d\u0648\u06cc\u0644\u06cc",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        320,
        1400
      ],
      "parameters": {
        "jsCode": "const order = $('\u062a\u0637\u0628\u06cc\u0642 \u0633\u0641\u0627\u0631\u0634 \u0628\u0627 \u062a\u0635\u0645\u06cc\u0645').first().json.order;\nconst rows = $input.all().map((i) => i.json);\nconst product = rows.find((r) => r.slug === order.product_slug);\nconst licenseKey = `IRCLU-${order.order_id.replace('ORDER-', '')}-${Math.random().toString(36).slice(2, 8).toUpperCase()}`;\nconst expiresAt = new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString();\n\nreturn [{ json: { order: { ...order, expires_at: expiresAt }, product, licenseKey } }];"
      }
    },
    {
      "id": "shape-append-license",
      "name": "\u0622\u0645\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u0631\u062f\u06cc\u0641 \u0644\u0627\u06cc\u0633\u0646\u0633",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        380,
        1400
      ],
      "parameters": {
        "jsCode": "const t = $json;\nreturn [{\n  json: {\n    license_key: t.licenseKey,\n    order_id: t.order.order_id,\n    product_slug: t.product.slug,\n    telegram_user_id: t.order.telegram_user_id,\n    customer: t.order.telegram_username,\n    machine_id: '',\n    issued_at: new Date().toISOString(),\n    expires_at: t.order.expires_at,\n    active: 'true',\n  },\n}];"
      }
    },
    {
      "id": "sheets-append-license",
      "name": "\u062b\u0628\u062a \u0644\u0627\u06cc\u0633\u0646\u0633 \u062c\u062f\u06cc\u062f",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        440,
        1400
      ],
      "parameters": {
        "operation": "append",
        "documentId": {
          "mode": "list",
          "value": "PLACEHOLDER_SPREADSHEET_ID"
        },
        "sheetName": {
          "mode": "name",
          "value": "Licenses"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {}
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "if-product-type-app",
      "name": "\u0646\u0648\u0639 \u0645\u062d\u0635\u0648\u0644 = \u0627\u067e\u0644\u06cc\u06a9\u06cc\u0634\u0646\u061f",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        560,
        1400
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "leftValue": "={{ $('\u062a\u0637\u0628\u06cc\u0642 \u0645\u062d\u0635\u0648\u0644 \u062a\u062d\u0648\u06cc\u0644\u06cc').first().json.product.type }}",
              "rightValue": "app",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        }
      }
    },
    {
      "id": "tg-deliver-app",
      "name": "\u062a\u062d\u0648\u06cc\u0644 \u0644\u06cc\u0646\u06a9 \u062f\u0627\u0646\u0644\u0648\u062f",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        800,
        1320
      ],
      "parameters": {
        "resource": "message",
        "operation": "sendMessage",
        "chatId": "={{ $('\u062a\u0637\u0628\u06cc\u0642 \u0645\u062d\u0635\u0648\u0644 \u062a\u062d\u0648\u06cc\u0644\u06cc').first().json.order.telegram_user_id }}",
        "text": "=\ud83c\udf89 \u067e\u0631\u062f\u0627\u062e\u062a \u062a\u0623\u06cc\u06cc\u062f \u0634\u062f!\n\n\u0644\u06cc\u0646\u06a9 \u062f\u0627\u0646\u0644\u0648\u062f {{ $('\u062a\u0637\u0628\u06cc\u0642 \u0645\u062d\u0635\u0648\u0644 \u062a\u062d\u0648\u06cc\u0644\u06cc').first().json.product.title }}:\n{{ $('\u062a\u0637\u0628\u06cc\u0642 \u0645\u062d\u0635\u0648\u0644 \u062a\u062d\u0648\u06cc\u0644\u06cc').first().json.product.file_url }}\n\n\ud83d\udd11 \u06a9\u062f \u0644\u0627\u06cc\u0633\u0646\u0633 \u0634\u0645\u0627 (\u0645\u0648\u0642\u0639 \u0627\u0648\u0644\u06cc\u0646 \u0627\u062c\u0631\u0627 \u0648\u0627\u0631\u062f \u06a9\u0646\u06cc\u062f):\n{{ $('\u062a\u0637\u0628\u06cc\u0642 \u0645\u062d\u0635\u0648\u0644 \u062a\u062d\u0648\u06cc\u0644\u06cc').first().json.licenseKey }}\n\n\u0627\u0634\u062a\u0631\u0627\u06a9 \u0634\u0645\u0627 \u0628\u0647 \u0645\u062f\u062a \u06cc\u06a9 \u0645\u0627\u0647 \u0641\u0639\u0627\u0644 \u0627\u0633\u062a \u0648 \u0647\u0631 \u0631\u0648\u0632 \u0628\u0647\u200c\u0635\u0648\u0631\u062a \u062e\u0648\u062f\u06a9\u0627\u0631 \u062a\u0648\u0633\u0637 \u0627\u067e\u0644\u06cc\u06a9\u06cc\u0634\u0646 \u0628\u0631\u0631\u0633\u06cc \u0645\u06cc\u200c\u0634\u0648\u062f.",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "tg-deliver-bot-customer",
      "name": "\u0627\u0637\u0644\u0627\u0639 \u0631\u0627\u0647\u200c\u0627\u0646\u062f\u0627\u0632\u06cc \u0631\u0628\u0627\u062a \u0628\u0647 \u0645\u0634\u062a\u0631\u06cc",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        800,
        1500
      ],
      "parameters": {
        "resource": "message",
        "operation": "sendMessage",
        "chatId": "={{ $('\u062a\u0637\u0628\u06cc\u0642 \u0645\u062d\u0635\u0648\u0644 \u062a\u062d\u0648\u06cc\u0644\u06cc').first().json.order.telegram_user_id }}",
        "text": "=\ud83c\udf89 \u067e\u0631\u062f\u0627\u062e\u062a \u062a\u0623\u06cc\u06cc\u062f \u0634\u062f!\n\n\u0686\u0648\u0646 {{ $('\u062a\u0637\u0628\u06cc\u0642 \u0645\u062d\u0635\u0648\u0644 \u062a\u062d\u0648\u06cc\u0644\u06cc').first().json.product.title }} \u0628\u0631\u0627\u06cc \u0647\u0631 \u0645\u0634\u062a\u0631\u06cc \u062c\u062f\u0627\u06af\u0627\u0646\u0647 \u0631\u0627\u0647\u200c\u0627\u0646\u062f\u0627\u0632\u06cc \u0645\u06cc\u200c\u0634\u0648\u062f\u060c \u062a\u06cc\u0645 \u0645\u0627 \u0638\u0631\u0641 \u062d\u062f\u0627\u06a9\u062b\u0631 \u06f2\u06f4 \u0633\u0627\u0639\u062a \u0627\u0632 \u0647\u0645\u06cc\u0646 \u0686\u062a \u0628\u0627 \u0634\u0645\u0627 \u062a\u0645\u0627\u0633 \u0645\u06cc\u200c\u06af\u06cc\u0631\u062f.",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "tg-notify-admin-setup",
      "name": "\u0627\u0637\u0644\u0627\u0639 \u0646\u06cc\u0627\u0632 \u0628\u0647 \u0631\u0627\u0647\u200c\u0627\u0646\u062f\u0627\u0632\u06cc \u062f\u0633\u062a\u06cc",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1040,
        1500
      ],
      "parameters": {
        "resource": "message",
        "operation": "sendMessage",
        "chatId": "6452519019",
        "text": "=\u2705 \u0633\u0641\u0627\u0631\u0634 {{ $('\u062a\u0637\u0628\u06cc\u0642 \u0645\u062d\u0635\u0648\u0644 \u062a\u062d\u0648\u06cc\u0644\u06cc').first().json.order.order_id }} \u062a\u0623\u06cc\u06cc\u062f \u0634\u062f \u2014 \u0646\u06cc\u0627\u0632 \u0628\u0647 \u0631\u0627\u0647\u200c\u0627\u0646\u062f\u0627\u0632\u06cc \u062f\u0633\u062a\u06cc \u0631\u0628\u0627\u062a \u062f\u0627\u0631\u062f.\n\u0646\u06cc\u0627\u0632\u0647\u0627\u06cc \u0645\u0634\u062a\u0631\u06cc: {{ $('\u062a\u0637\u0628\u06cc\u0642 \u0645\u062d\u0635\u0648\u0644 \u062a\u062d\u0648\u06cc\u0644\u06cc').first().json.order.requirements_summary }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "sheets-read-orders-admin-menu",
      "name": "\u062e\u0648\u0627\u0646\u062f\u0646 \u0633\u0641\u0627\u0631\u0634\u200c\u0647\u0627 (\u0645\u0646\u0648\u06cc \u0627\u062f\u0645\u06cc\u0646)",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        -880,
        1900
      ],
      "parameters": {
        "operation": "read",
        "documentId": {
          "mode": "list",
          "value": "PLACEHOLDER_SPREADSHEET_ID"
        },
        "sheetName": {
          "mode": "name",
          "value": "Orders"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "alwaysOutputData": true
    },
    {
      "id": "code-admin-stats",
      "name": "\u0633\u0627\u062e\u062a \u0622\u0645\u0627\u0631 \u0633\u0631\u06cc\u0639 \u0627\u062f\u0645\u06cc\u0646",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -640,
        1900
      ],
      "parameters": {
        "jsCode": "const rows = $input.all().map((i) => i.json);\nconst now = Date.now();\nconst threeDaysMs = 3 * 24 * 60 * 60 * 1000;\n\nconst pendingReview = rows.filter((o) => o.status === 'pending_review').length;\nconst awaitingPayment = rows.filter((o) => o.status === 'awaiting_payment').length;\nconst deliveredThisMonth = rows.filter((o) => {\n  if (o.status !== 'delivered' || !o.reviewed_at) return false;\n  const d = new Date(o.reviewed_at);\n  const n = new Date();\n  return d.getFullYear() === n.getFullYear() && d.getMonth() === n.getMonth();\n}).length;\nconst expiringSoon = rows.filter((o) => {\n  if (o.status !== 'delivered' || !o.expires_at) return false;\n  const diff = new Date(o.expires_at).getTime() - now;\n  return diff > 0 && diff <= threeDaysMs;\n}).length;\n\nreturn [{\n  json: {\n    chatId: $('\u062a\u0634\u062e\u06cc\u0635 \u0646\u0648\u0639 \u067e\u06cc\u0627\u0645').first().json.chatId,\n    pendingReview, awaitingPayment, deliveredThisMonth, expiringSoon,\n  },\n}];"
      }
    },
    {
      "id": "tg-admin-menu",
      "name": "\u0645\u0646\u0648\u06cc \u0627\u062f\u0645\u06cc\u0646",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -400,
        1900
      ],
      "parameters": {
        "resource": "message",
        "operation": "sendMessage",
        "chatId": "={{ $json.chatId }}",
        "text": "=\ud83d\udc4b \u0633\u0644\u0627\u0645 \u0645\u062f\u06cc\u0631!\n\n\ud83d\udccb \u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631 \u062a\u0627\u06cc\u06cc\u062f \u0631\u0633\u06cc\u062f: {{ $json.pendingReview }}\n\ud83d\udcb3 \u0645\u0646\u062a\u0638\u0631 \u067e\u0631\u062f\u0627\u062e\u062a \u0645\u0634\u062a\u0631\u06cc: {{ $json.awaitingPayment }}\n\u2705 \u062a\u062d\u0648\u06cc\u0644\u200c\u0634\u062f\u0647 \u0627\u06cc\u0646 \u0645\u0627\u0647: {{ $json.deliveredThisMonth }}\n\u23f0 \u0631\u0648\u200c\u0628\u0647\u200c\u0627\u0646\u0642\u0636\u0627 (\u06f3 \u0631\u0648\u0632 \u0622\u06cc\u0646\u062f\u0647): {{ $json.expiringSoon }}\n\n\u0628\u0631\u0627\u06cc \u062f\u06cc\u062f\u0646 \u0644\u06cc\u0633\u062a \u06a9\u0627\u0645\u0644 \u0645\u0634\u062a\u0631\u06cc\u200c\u0647\u0627\u060c \u0686\u062a\u200c\u0647\u0627\u0634\u0648\u0646 \u0648 \u0633\u0641\u0627\u0631\u0634\u200c\u0647\u0627\u0634\u0648\u0646\u060c \u062f\u06a9\u0645\u0647\u200c\u06cc \u0632\u06cc\u0631 \u0631\u0648 \u0628\u0632\u0646 \u062a\u0627 \u06cc\u0647 \u0641\u0627\u06cc\u0644 \u06af\u0632\u0627\u0631\u0634 \u0628\u0631\u0627\u062a \u0628\u0641\u0631\u0633\u062a\u0645 \ud83d\udc47",
        "replyMarkup": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "\ud83d\udcca \u062f\u0631\u06cc\u0627\u0641\u062a \u06af\u0632\u0627\u0631\u0634 (\u0641\u0627\u06cc\u0644 HTML)",
                    "additionalFields": {
                      "callback_data": "admin:report"
                    }
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "sheets-read-customers-report",
      "name": "\u062e\u0648\u0627\u0646\u062f\u0646 \u0645\u0634\u062a\u0631\u06cc\u0627\u0646 (\u06af\u0632\u0627\u0631\u0634)",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        -880,
        2300
      ],
      "parameters": {
        "operation": "read",
        "documentId": {
          "mode": "list",
          "value": "PLACEHOLDER_SPREADSHEET_ID"
        },
        "sheetName": {
          "mode": "name",
          "value": "Customers"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "alwaysOutputData": true
    },
    {
      "id": "sheets-read-orders-report",
      "name": "\u062e\u0648\u0627\u0646\u062f\u0646 \u0633\u0641\u0627\u0631\u0634\u200c\u0647\u0627 (\u06af\u0632\u0627\u0631\u0634)",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        -640,
        2300
      ],
      "parameters": {
        "operation": "read",
        "documentId": {
          "mode": "list",
          "value": "PLACEHOLDER_SPREADSHEET_ID"
        },
        "sheetName": {
          "mode": "name",
          "value": "Orders"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "alwaysOutputData": true
    },
    {
      "id": "sheets-read-licenses-report",
      "name": "\u062e\u0648\u0627\u0646\u062f\u0646 \u0644\u0627\u06cc\u0633\u0646\u0633\u200c\u0647\u0627 (\u06af\u0632\u0627\u0631\u0634)",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        -400,
        2300
      ],
      "parameters": {
        "operation": "read",
        "documentId": {
          "mode": "list",
          "value": "PLACEHOLDER_SPREADSHEET_ID"
        },
        "sheetName": {
          "mode": "name",
          "value": "Licenses"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "alwaysOutputData": true
    },
    {
      "id": "code-build-report-html",
      "name": "\u0633\u0627\u062e\u062a \u0641\u0627\u06cc\u0644 \u06af\u0632\u0627\u0631\u0634 HTML",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -160,
        2300
      ],
      "parameters": {
        "jsCode": "// \u0627\u06af\u0647 \u06cc\u0647 \u0631\u062f\u06cc\u0641 (\u0633\u0641\u0627\u0631\u0634/\u0644\u0627\u06cc\u0633\u0646\u0633/\u0645\u0634\u062a\u0631\u06cc) \u0628\u0647 \u0647\u0631 \u062f\u0644\u06cc\u0644\u06cc (\u0645\u062b\u0644\u0627\u064b \u0686\u0646\u062f\u0628\u0627\u0631 \u0632\u062f\u0646 \u062f\u06a9\u0645\u0647\u200c\u06cc \u062a\u0627\u06cc\u06cc\u062f \u0631\u0648\u06cc \u06cc\u06a9 \u0633\u0641\u0627\u0631\u0634)\n// \u062a\u0648\u06cc \u0634\u06cc\u062a \u062a\u06a9\u0631\u0627\u0631\u06cc \u062b\u0628\u062a \u0634\u062f\u0647 \u0628\u0627\u0634\u0647\u060c \u0627\u06cc\u0646\u062c\u0627 \u0628\u0627 \u06a9\u0644\u06cc\u062f \u06cc\u06a9\u062a\u0627\u0634 \u06cc\u06a9\u200c\u0628\u0627\u0631 \u0646\u06af\u0647 \u062f\u0627\u0634\u062a\u0647 \u0645\u06cc\u200c\u0634\u0647 \u062a\u0627 \u06af\u0632\u0627\u0631\u0634 \u062a\u06a9\u0631\u0627\u0631\u06cc \u0646\u0634\u0647 \u2014\n// \u0627\u06cc\u0646 \u0641\u0642\u0637 \u0646\u0645\u0627\u06cc\u0634 \u0631\u0648 \u062a\u0645\u06cc\u0632 \u0645\u06cc\u200c\u06a9\u0646\u0647\u061b \u062e\u0648\u062f\u0650 \u0634\u06cc\u062a \u0627\u0635\u0644\u0627\u062d \u0646\u0645\u06cc\u200c\u0634\u0647.\nfunction dedupeBy(rows, keyFn) {\n  const seen = new Set();\n  const out = [];\n  for (const row of rows) {\n    const key = keyFn(row);\n    if (key && seen.has(key)) continue;\n    if (key) seen.add(key);\n    out.push(row);\n  }\n  return out;\n}\n\nconst customersRaw = dedupeBy(\n  $('\u062e\u0648\u0627\u0646\u062f\u0646 \u0645\u0634\u062a\u0631\u06cc\u0627\u0646 (\u06af\u0632\u0627\u0631\u0634)').all().map((i) => i.json),\n  (c) => c.telegram_user_id\n);\nconst orders = dedupeBy(\n  $('\u062e\u0648\u0627\u0646\u062f\u0646 \u0633\u0641\u0627\u0631\u0634\u200c\u0647\u0627 (\u06af\u0632\u0627\u0631\u0634)').all().map((i) => i.json),\n  (o) => o.order_id\n);\nconst licenses = dedupeBy(\n  $('\u062e\u0648\u0627\u0646\u062f\u0646 \u0644\u0627\u06cc\u0633\u0646\u0633\u200c\u0647\u0627 (\u06af\u0632\u0627\u0631\u0634)').all().map((i) => i.json),\n  (l) => l.license_key\n);\n\nconst customers = customersRaw\n  .map((c) => {\n    let chatHistory = [];\n    try {\n      chatHistory = JSON.parse(c.chat_history || '[]');\n    } catch (e) {\n      chatHistory = [];\n    }\n    if (!Array.isArray(chatHistory)) chatHistory = [];\n    return {\n      chatId: c.telegram_user_id,\n      username: c.username || '',\n      phone: c.phone || '',\n      pendingState: c.pending_state || '',\n      createdAt: c.created_at || '',\n      chatHistory,\n      orders: orders.filter((o) => String(o.telegram_user_id) === String(c.telegram_user_id)),\n      licenses: licenses.filter((l) => String(l.telegram_user_id) === String(c.telegram_user_id)),\n    };\n  })\n  .filter((c) => c.chatId)\n  .sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());\n\nconst now = Date.now();\nconst threeDaysMs = 3 * 24 * 60 * 60 * 1000;\nconst stats = {\n  pendingReview: orders.filter((o) => o.status === 'pending_review').length,\n  awaitingPayment: orders.filter((o) => o.status === 'awaiting_payment').length,\n  deliveredThisMonth: orders.filter((o) => {\n    if (o.status !== 'delivered' || !o.reviewed_at) return false;\n    const d = new Date(o.reviewed_at);\n    const n = new Date();\n    return d.getFullYear() === n.getFullYear() && d.getMonth() === n.getMonth();\n  }).length,\n  expiringSoon: orders.filter((o) => {\n    if (o.status !== 'delivered' || !o.expires_at) return false;\n    const diff = new Date(o.expires_at).getTime() - now;\n    return diff > 0 && diff <= threeDaysMs;\n  }).length,\n};\n\nconst STATUS_LABELS = {\n  awaiting_requirements: '\u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631 \u062a\u0648\u0636\u06cc\u062d \u0646\u06cc\u0627\u0632',\n  awaiting_payment: '\u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631 \u067e\u0631\u062f\u0627\u062e\u062a',\n  pending_review: '\u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631 \u062a\u0627\u06cc\u06cc\u062f',\n  delivered: '\u062a\u062d\u0648\u06cc\u0644\u200c\u0634\u062f\u0647',\n  rejected: '\u0631\u062f \u0634\u062f\u0647',\n};\n\nfunction esc(s) {\n  return String(s == null ? '' : s)\n    .replace(/&/g, '&amp;')\n    .replace(/</g, '&lt;')\n    .replace(/>/g, '&gt;')\n    .replace(/\"/g, '&quot;');\n}\n\nfunction money(n) {\n  return Number(n || 0).toLocaleString('fa-IR');\n}\n\nfunction customerBlock(c) {\n  const statusKey = (c.pendingState || '').split(':')[0];\n  const statusLabel = STATUS_LABELS[statusKey] || c.pendingState || '';\n  const statusChip = statusLabel\n    ? `<span class=\"chip\">${esc(statusLabel)}</span>`\n    : '';\n\n  const chatHtml = c.chatHistory.length\n    ? c.chatHistory\n        .map(\n          (m) =>\n            `<div class=\"msg ${m.role === 'user' ? 'msg-user' : 'msg-bot'}\">${esc(m.content)}</div>`\n        )\n        .join('')\n    : '<p class=\"muted\">\u0647\u0646\u0648\u0632 \u06af\u0641\u062a\u06af\u0648\u06cc \u0622\u0632\u0627\u062f\u06cc \u0628\u0627 AI \u0646\u062f\u0627\u0634\u062a\u0647.</p>';\n\n  const ordersHtml = c.orders.length\n    ? `<div class=\"rows\">${c.orders\n        .map(\n          (o) => `<div class=\"row\">\n            <span class=\"mono\">${esc(o.order_id)}</span>\n            <span>${esc(o.product_slug)}</span>\n            <span>${money(o.amount)} \u062a\u0648\u0645\u0627\u0646</span>\n            <span class=\"chip\">${esc(STATUS_LABELS[o.status] || o.status)}</span>\n          </div>`\n        )\n        .join('')}</div>`\n    : '';\n\n  const licensesHtml = c.licenses.length\n    ? `<div class=\"rows\">${c.licenses\n        .map(\n          (l) => `<div class=\"row\">\n            <span class=\"mono cyan\">${esc(l.license_key)}</span>\n            <span class=\"muted\">${l.expires_at ? new Date(l.expires_at).toLocaleDateString('fa-IR') : '\u2014'}</span>\n          </div>`\n        )\n        .join('')}</div>`\n    : '';\n\n  return `<details class=\"customer\">\n    <summary>\n      <span class=\"who\">\n        <b>${c.username ? '@' + esc(c.username) : '\u0628\u062f\u0648\u0646 \u06cc\u0648\u0632\u0631\u0646\u06cc\u0645'}</b>\n        <span class=\"mono muted\">${esc(c.phone) || '\u2014'}</span>\n      </span>\n      <span class=\"meta\">${statusChip}<span class=\"muted\">${c.orders.length} \u0633\u0641\u0627\u0631\u0634</span></span>\n    </summary>\n    <div class=\"customer-body\">\n      <h4>\u06af\u0641\u062a\u06af\u0648\u06cc \u0647\u0648\u0634 \u0645\u0635\u0646\u0648\u0639\u06cc \u0641\u0631\u0648\u0634</h4>\n      ${chatHtml}\n      ${c.orders.length ? '<h4>\u0633\u0641\u0627\u0631\u0634\u200c\u0647\u0627</h4>' + ordersHtml : ''}\n      ${c.licenses.length ? '<h4>\u0644\u0627\u06cc\u0633\u0646\u0633\u200c\u0647\u0627</h4>' + licensesHtml : ''}\n    </div>\n  </details>`;\n}\n\nconst generatedAt = new Date().toLocaleString('fa-IR', { dateStyle: 'full', timeStyle: 'short' });\n\nconst html = `<!doctype html>\n<html lang=\"fa\" dir=\"rtl\">\n<head>\n<meta charset=\"utf-8\" />\n<title>\u06af\u0632\u0627\u0631\u0634 \u0645\u0634\u062a\u0631\u06cc\u200c\u0647\u0627 \u2014 IR-CLU</title>\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n<style>\n  :root {\n    --ink:#07080d; --surface:#10131c; --surface2:#161b28; --border:rgba(230,234,245,.1);\n    --text:#e8eaf2; --muted:#8b93a8; --cyan:#34d9e8; --violet:#9b7bf8; --ember:#fb7a3c;\n  }\n  * { box-sizing: border-box; }\n  body { margin:0; background:var(--ink); color:var(--text); font-family:\"Vazirmatn\",\"Segoe UI\",Tahoma,sans-serif; line-height:1.8; }\n  .wrap { max-width:860px; margin:0 auto; padding:40px 20px 80px; }\n  h1 { font-size:26px; margin:0; }\n  .gen { font-family:monospace; font-size:12px; color:var(--muted); margin-top:10px; }\n  .stats { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:12px; margin:28px 0; }\n  .stat { background:var(--surface); border:1px solid var(--border); border-radius:14px; padding:16px 18px; }\n  .stat b { font-size:22px; display:block; }\n  .stat span { font-size:12px; color:var(--muted); }\n  .customer { background:var(--surface); border:1px solid var(--border); border-radius:14px; margin-bottom:10px; overflow:hidden; }\n  .customer summary { cursor:pointer; list-style:none; padding:16px 18px; display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; }\n  .customer summary::-webkit-details-marker { display:none; }\n  .who { display:flex; flex-direction:column; gap:4px; }\n  .meta { display:flex; align-items:center; gap:10px; font-size:12px; }\n  .chip { border:1px solid rgba(52,217,232,.4); color:var(--cyan); border-radius:999px; padding:2px 10px; font-size:11px; }\n  .customer-body { border-top:1px solid var(--border); padding:16px 18px; }\n  .customer-body h4 { font-size:12px; text-transform:uppercase; letter-spacing:.05em; color:var(--muted); margin:16px 0 8px; }\n  .customer-body h4:first-child { margin-top:0; }\n  .msg { max-width:85%; border-radius:14px; padding:9px 14px; margin:6px 0; font-size:14px; }\n  .msg-user { background:var(--surface2); }\n  .msg-bot { background:linear-gradient(90deg,var(--cyan),var(--violet)); color:var(--ink); margin-inline-start:auto; }\n  .rows { display:flex; flex-direction:column; gap:6px; }\n  .row { display:flex; flex-wrap:wrap; gap:10px; align-items:center; justify-content:space-between; border:1px solid var(--border); border-radius:10px; padding:8px 12px; font-size:13px; }\n  .mono { font-family:monospace; direction:ltr; unicode-bidi:isolate; }\n  .cyan { color:var(--cyan); }\n  .muted { color:var(--muted); }\n</style>\n</head>\n<body>\n<div class=\"wrap\">\n  <h1>\u06af\u0632\u0627\u0631\u0634 \u0645\u0634\u062a\u0631\u06cc\u200c\u0647\u0627 \u0648 \u06af\u0641\u062a\u06af\u0648\u0647\u0627\u0634\u0648\u0646 \u0628\u0627 \u0631\u0628\u0627\u062a \u0641\u0631\u0648\u0634</h1>\n  <div class=\"gen\">\u062a\u0648\u0644\u06cc\u062f \u0634\u062f\u0647 \u062f\u0631: ${esc(generatedAt)}</div>\n\n  <div class=\"stats\">\n    <div class=\"stat\"><b>${stats.pendingReview}</b><span>\u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631 \u062a\u0627\u06cc\u06cc\u062f \u0631\u0633\u06cc\u062f</span></div>\n    <div class=\"stat\"><b>${stats.awaitingPayment}</b><span>\u0645\u0646\u062a\u0638\u0631 \u067e\u0631\u062f\u0627\u062e\u062a \u0645\u0634\u062a\u0631\u06cc</span></div>\n    <div class=\"stat\"><b>${stats.deliveredThisMonth}</b><span>\u062a\u062d\u0648\u06cc\u0644\u200c\u0634\u062f\u0647 \u0627\u06cc\u0646 \u0645\u0627\u0647</span></div>\n    <div class=\"stat\"><b>${stats.expiringSoon}</b><span>\u0631\u0648\u200c\u0628\u0647\u200c\u0627\u0646\u0642\u0636\u0627 (\u06f3 \u0631\u0648\u0632 \u0622\u06cc\u0646\u062f\u0647)</span></div>\n  </div>\n\n  ${customers.length ? customers.map(customerBlock).join('') : '<p class=\"muted\">\u0647\u0646\u0648\u0632 \u0647\u06cc\u0686 \u0645\u0634\u062a\u0631\u06cc\u200c\u0627\u06cc \u062b\u0628\u062a \u0646\u0634\u062f\u0647.</p>'}\n</div>\n</body>\n</html>`;\n\nconst buffer = Buffer.from(html, 'utf8');\n\nreturn [{\n  json: { generatedAt },\n  binary: {\n    data: {\n      data: buffer.toString('base64'),\n      mimeType: 'text/html',\n      fileName: `irclu-report-${Date.now()}.html`,\n    },\n  },\n}];"
      }
    },
    {
      "id": "tg-send-report-document",
      "name": "\u0627\u0631\u0633\u0627\u0644 \u0641\u0627\u06cc\u0644 \u06af\u0632\u0627\u0631\u0634",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        80,
        2300
      ],
      "parameters": {
        "resource": "message",
        "operation": "sendDocument",
        "chatId": "={{ $('\u062a\u0634\u062e\u06cc\u0635 \u0646\u0648\u0639 \u067e\u06cc\u0627\u0645').first().json.chatId }}",
        "binaryData": true,
        "file": "data",
        "additionalFields": {
          "caption": "=\ud83d\udcca \u06af\u0632\u0627\u0631\u0634 \u0644\u062d\u0638\u0647\u200c\u0627\u06cc \u0645\u0634\u062a\u0631\u06cc\u200c\u0647\u0627 \u2014 {{ $json.generatedAt }}\\n\u0627\u06cc\u0646 \u0641\u0627\u06cc\u0644 \u0631\u0648 \u062f\u0627\u0646\u0644\u0648\u062f \u0648 \u0628\u0627 \u0645\u0631\u0648\u0631\u06af\u0631 \u0628\u0627\u0632 \u06a9\u0646\u061b \u06a9\u0627\u0645\u0644\u0627\u064b \u0645\u0633\u062a\u0642\u0644 \u0648 \u0622\u0641\u0644\u0627\u06cc\u0646\u0647.",
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "\u067e\u06cc\u0627\u0645 \u062c\u062f\u06cc\u062f \u062f\u0631 \u0631\u0628\u0627\u062a \u0641\u0631\u0648\u0634": {
      "main": [
        [
          {
            "node": "\u062a\u0634\u062e\u06cc\u0635 \u0646\u0648\u0639 \u067e\u06cc\u0627\u0645",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u062a\u0634\u062e\u06cc\u0635 \u0646\u0648\u0639 \u067e\u06cc\u0627\u0645": {
      "main": [
        [
          {
            "node": "\u0645\u0633\u06cc\u0631 \u0628\u0631 \u0627\u0633\u0627\u0633 \u0646\u0648\u0639 \u067e\u06cc\u0627\u0645",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0645\u0633\u06cc\u0631 \u0628\u0631 \u0627\u0633\u0627\u0633 \u0646\u0648\u0639 \u067e\u06cc\u0627\u0645": {
      "main": [
        [
          {
            "node": "\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": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\u062e\u0648\u0627\u0646\u062f\u0646 \u0645\u0634\u062a\u0631\u06cc\u0627\u0646",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\u062e\u0648\u0627\u0646\u062f\u0646 \u0633\u0641\u0627\u0631\u0634\u200c\u0647\u0627 (\u0631\u0633\u06cc\u062f)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\u062e\u0648\u0627\u0646\u062f\u0646 \u0633\u0641\u0627\u0631\u0634\u200c\u0647\u0627 (\u062a\u0635\u0645\u06cc\u0645 \u0627\u062f\u0645\u06cc\u0646)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\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": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\u062e\u0648\u0627\u0646\u062f\u0646 \u0633\u0641\u0627\u0631\u0634\u200c\u0647\u0627 (\u0645\u0646\u0648\u06cc \u0627\u062f\u0645\u06cc\u0646)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\u062e\u0648\u0627\u0646\u062f\u0646 \u0645\u0634\u062a\u0631\u06cc\u0627\u0646 (\u06af\u0632\u0627\u0631\u0634)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0622\u0645\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u0631\u062f\u06cc\u0641 \u0645\u0634\u062a\u0631\u06cc (\u0634\u0645\u0627\u0631\u0647)": {
      "main": [
        [
          {
            "node": "\u0630\u062e\u06cc\u0631\u0647 \u0634\u0645\u0627\u0631\u0647 \u062a\u0644\u0641\u0646",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0630\u062e\u06cc\u0631\u0647 \u0634\u0645\u0627\u0631\u0647 \u062a\u0644\u0641\u0646": {
      "main": [
        [
          {
            "node": "\u062e\u0648\u0627\u0646\u062f\u0646 \u0648\u0636\u0639\u06cc\u062a \u0645\u0634\u062a\u0631\u06cc",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u062e\u0648\u0627\u0646\u062f\u0646 \u0648\u0636\u0639\u06cc\u062a \u0645\u0634\u062a\u0631\u06cc": {
      "main": [
        [
          {
            "node": "\u0627\u062f\u0627\u0645\u0647 \u062f\u0627\u062f\u0646 \u0628\u0639\u062f \u0627\u0632 \u0627\u062d\u0631\u0627\u0632 \u0647\u0648\u06cc\u062a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0627\u062f\u0627\u0645\u0647 \u062f\u0627\u062f\u0646 \u0628\u0639\u062f \u0627\u0632 \u0627\u062d\u0631\u0627\u0632 \u0647\u0648\u06cc\u062a": {
      "main": [
        [
          {
            "node": "\u062a\u0623\u06cc\u06cc\u062f \u062b\u0628\u062a \u0634\u0645\u0627\u0631\u0647",
            "type": "main",
            "index": 0
          },
          {
            "node": "\u0645\u062d\u0635\u0648\u0644\u06cc \u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631 \u0628\u0648\u062f\u061f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0645\u062d\u0635\u0648\u0644\u06cc \u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631 \u0628\u0648\u062f\u061f": {
      "main": [
        [
          {
            "node": "\u062e\u0648\u0627\u0646\u062f\u0646 \u0645\u062d\u0635\u0648\u0644\u0627\u062a",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\u062f\u0639\u0648\u062a \u0628\u0647 \u06af\u0641\u062a\u06af\u0648",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u062e\u0648\u0627\u0646\u062f\u0646 \u0645\u0634\u062a\u0631\u06cc\u0627\u0646": {
      "main": [
        [
          {
            "node": "\u0628\u0631\u0631\u0633\u06cc \u0627\u062d\u0631\u0627\u0632 \u0647\u0648\u06cc\u062a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0628\u0631\u0631\u0633\u06cc \u0627\u062d\u0631\u0627\u0632 \u0647\u0648\u06cc\u062a": {
      "main": [
        [
          {
            "node": "\u0634\u0645\u0627\u0631\u0647 \u0642\u0628\u0644\u0627\u064b \u062b\u0628\u062a \u0634\u062f\u0647\u061f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0634\u0645\u0627\u0631\u0647 \u0642\u0628\u0644\u0627\u064b \u062b\u0628\u062a \u0634\u062f\u0647\u061f": {
      "main": [
        [
          {
            "node": "\u0645\u062d\u0635\u0648\u0644\u06cc \u062e\u0648\u0627\u0633\u062a\u0647 \u0628\u0648\u062f\u061f",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\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": "main",
            "index": 0
          }
        ]
      ]
    },
    "\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)": {
      "main": [
        [
          {
            "node": "\u0630\u062e\u06cc\u0631\u0647 \u0645\u062d\u0635\u0648\u0644 \u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0630\u062e\u06cc\u0631\u0647 \u0645\u062d\u0635\u0648\u0644 \u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631": {
      "main": [
        [
          {
            "node": "\u0622\u0645\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u062f\u0631\u062e\u0648\u0627\u0633\u062a \u0634\u0645\u0627\u0631\u0647",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0622\u0645\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u062f\u0631\u062e\u0648\u0627\u0633\u062a \u0634\u0645\u0627\u0631\u0647": {
      "main": [
        [
          {
            "node": "\u062f\u0631\u062e\u0648\u0627\u0633\u062a \u0634\u0645\u0627\u0631\u0647 \u062a\u0644\u0641\u0646",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0645\u062d\u0635\u0648\u0644\u06cc \u062e\u0648\u0627\u0633\u062a\u0647 \u0628\u0648\u062f\u061f": {
      "main": [
        [
          {
            "node": "\u062e\u0648\u0627\u0646\u062f\u0646 \u0645\u062d\u0635\u0648\u0644\u0627\u062a",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\u062e\u0648\u0634\u200c\u0622\u0645\u062f\u06af\u0648\u06cc\u06cc (\u0628\u062f\u0648\u0646 \u0645\u062d\u0635\u0648\u0644)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u062e\u0648\u0627\u0646\u062f\u0646 \u0645\u062d\u0635\u0648\u0644\u0627\u062a": {
      "main": [
        [
          {
            "node": "\u067e\u06cc\u062f\u0627 \u06a9\u0631\u062f\u0646 \u0645\u062d\u0635\u0648\u0644",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u067e\u06cc\u062f\u0627 \u06a9\u0631\u062f\u0646 \u0645\u062d\u0635\u0648\u0644": {
      "main": [
        [
          {
            "node": "\u0645\u062d\u0635\u0648\u0644 \u067e\u06cc\u062f\u0627 \u0634\u062f\u061f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0645\u062d\u0635\u0648\u0644 \u067e\u06cc\u062f\u0627 \u0634\u062f\u061f": {
      "main": [
        [
          {
            "node": "\u0633\u0627\u062e\u062a \u0633\u0641\u0627\u0631\u0634 \u062c\u062f\u06cc\u062f",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\u0645\u062d\u0635\u0648\u0644 \u067e\u06cc\u062f\u0627 \u0646\u0634\u062f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0633\u0627\u062e\u062a \u0633\u0641\u0627\u0631\u0634 \u062c\u062f\u06cc\u062f": {
      "main": [
        [
          {
            "node": "\u0622\u0645\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u0631\u062f\u06cc\u0641 \u0633\u0641\u0627\u0631\u0634",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0622\u0645\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u0631\u062f\u06cc\u0641 \u0633\u0641\u0627\u0631\u0634": {
      "main": [
        [
          {
            "node": "\u062b\u0628\u062a \u0633\u0641\u0627\u0631\u0634 (\u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631 \u0646\u06cc\u0627\u0632\u0647\u0627)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u062b\u0628\u062a \u0633\u0641\u0627\u0631\u0634 (\u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631 \u0646\u06cc\u0627\u0632\u0647\u0627)": {
      "main": [
        [
          {
            "node": "\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": "main",
            "index": 0
          }
        ]
      ]
    },
    "\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)": {
      "main": [
        [
          {
            "node": "\u062b\u0628\u062a \u0648\u0636\u0639\u06cc\u062a \u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631 \u0646\u06cc\u0627\u0632\u0647\u0627",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u062b\u0628\u062a \u0648\u0636\u0639\u06cc\u062a \u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631 \u0646\u06cc\u0627\u0632\u0647\u0627": {
      "main": [
        [
          {
            "node": "\u062f\u0631\u062e\u0648\u0627\u0633\u062a \u062a\u0648\u0636\u06cc\u062d \u0646\u06cc\u0627\u0632\u0647\u0627",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u062e\u0648\u0627\u0646\u062f\u0646 \u0648\u0636\u0639\u06cc\u062a \u0645\u0634\u062a\u0631\u06cc (\u067e\u06cc\u0627\u0645 \u0622\u0632\u0627\u062f)": {
      "main": [
        [
          {
            "node": "\u0628\u0631\u0631\u0633\u06cc \u0648\u0636\u0639\u06cc\u062a \u0645\u0634\u062a\u0631\u06cc (\u067e\u06cc\u0627\u0645 \u0622\u0632\u0627\u062f)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0628\u0631\u0631\u0633\u06cc \u0648\u0636\u0639\u06cc\u062a \u0645\u0634\u062a\u0631\u06cc (\u067e\u06cc\u0627\u0645 \u0622\u0632\u0627\u062f)": {
      "main": [
        [
          {
            "node": "\u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631 \u0646\u06cc\u0627\u0632\u0647\u0627\u0633\u062a\u061f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631 \u0646\u06cc\u0627\u0632\u0647\u0627\u0633\u062a\u061f": {
      "main": [
        [
          {
            "node": "\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": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\u0634\u0645\u0627\u0631\u0647 \u062b\u0628\u062a \u0634\u062f\u0647\u061f (\u067e\u06cc\u0627\u0645 \u0622\u0632\u0627\u062f)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\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": {
      "main": [
        [
          {
            "node": "\u0622\u0645\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u062e\u0644\u0627\u0635\u0647 \u0646\u06cc\u0627\u0632\u0647\u0627",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0622\u0645\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u062e\u0644\u0627\u0635\u0647 \u0646\u06cc\u0627\u0632\u0647\u0627": {
      "main": [
        [
          {
            "node": "\u062b\u0628\u062a \u062e\u0644\u0627\u0635\u0647 \u0646\u06cc\u0627\u0632\u0647\u0627 \u062f\u0631 \u0633\u0641\u0627\u0631\u0634",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u062b\u0628\u062a \u062e\u0644\u0627\u0635\u0647 \u0646\u06cc\u0627\u0632\u0647\u0627 \u062f\u0631 \u0633\u0641\u0627\u0631\u0634": {
      "main": [
        [
          {
            "node": "\u0622\u0645\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u067e\u0627\u06a9 \u06a9\u0631\u062f\u0646 \u0648\u0636\u0639\u06cc\u062a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0622\u0645\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u067e\u0627\u06a9 \u06a9\u0631\u062f\u0646 \u0648\u0636\u0639\u06cc\u062a": {
      "main": [
        [
          {
            "node": "\u067e\u0627\u06a9 \u06a9\u0631\u062f\u0646 \u0648\u0636\u0639\u06cc\u062a \u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u067e\u0627\u06a9 \u06a9\u0631\u062f\u0646 \u0648\u0636\u0639\u06cc\u062a \u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631": {
      "main": [
        [
          {
            "node": "\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": "main",
            "index": 0
          }
        ]
      ]
    },
    "\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": {
      "main": [
        [
          {
            "node": "\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": "main",
            "index": 0
          }
        ]
      ]
    },
    "\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": {
      "main": [
        [
          {
            "node": "\u0646\u0645\u0627\u06cc\u0634 \u0627\u0637\u0644\u0627\u0639\u0627\u062a \u067e\u0631\u062f\u0627\u062e\u062a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0634\u0645\u0627\u0631\u0647 \u062b\u0628\u062a \u0634\u062f\u0647\u061f (\u067e\u06cc\u0627\u0645 \u0622\u0632\u0627\u062f)": {
      "main": [
        [
          {
            "node": "\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": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\u062f\u0631\u062e\u0648\u0627\u0633\u062a \u0634\u0645\u0627\u0631\u0647 \u062a\u0644\u0641\u0646",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0633\u0627\u062e\u062a \u067e\u06cc\u0627\u0645 \u06af\u0641\u062a\u06af\u0648 \u0628\u0627 \u0647\u0648\u0634 \u0645\u0635\u0646\u0648\u0639\u06cc": {
      "main": [
        [
          {
            "node": "\u0686\u062a \u0641\u0631\u0648\u0634 \u0628\u0627 \u0647\u0648\u0634 \u0645\u0635\u0646\u0648\u0639\u06cc",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0686\u062a \u0641\u0631\u0648\u0634 \u0628\u0627 \u0647\u0648\u0634 \u0645\u0635\u0646\u0648\u0639\u06cc": {
      "main": [
        [
          {
            "node": "\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": "main",
            "index": 0
          }
        ]
      ]
    },
    "\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": {
      "main": [
        [
          {
            "node": "\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": "main",
            "index": 0
          },
          {
            "node": "\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": "main",
            "index": 0
          }
        ]
      ]
    },
    "\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": {
      "main": [
        [
          {
            "node": "\u0630\u062e\u06cc\u0631\u0647 \u062a\u0627\u0631\u06cc\u062e\u0686\u0647 \u06af\u0641\u062a\u06af\u0648",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u062e\u0648\u0627\u0646\u062f\u0646 \u0633\u0641\u0627\u0631\u0634\u200c\u0647\u0627 (\u0631\u0633\u06cc\u062f)": {
      "main": [
        [
          {
            "node": "\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": "main",
            "index": 0
          }
        ]
      ]
    },
    "\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": {
      "main": [
        [
          {
            "node": "\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": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0633\u0641\u0627\u0631\u0634\u06cc \u062f\u0631 \u0627\u0646\u062a\u0638\u0627\u0631 \u067e\u0631\u062f\u0627\u062e\u062a \u0647\u0633\u062a\u061f": {
      "main": [
        [
          {
            "node": "\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": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\u0633\u0641\u0627\u0631\u0634\u06cc \u067e\u06cc\u062f\u0627 \u0646\u0634\u062f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\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": {
      "main": [
        [
          {
            "node": "\u062b\u0628\u062a \u0631\u0633\u06cc\u062f \u067e\u0631\u062f\u0627\u062e\u062a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u062b\u0628\u062a \u0631\u0633\u06cc\u062f \u067e\u0631\u062f\u0627\u062e\u062a": {
      "main": [
        [
          {
            "node": "\u062a\u0623\u06cc\u06cc\u062f \u062f\u0631\u06cc\u0627\u0641\u062a \u0631\u0633\u06cc\u062f \u0628\u0647 \u0645\u0634\u062a\u0631\u06cc",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u062a\u0623\u06cc\u06cc\u062f \u062f\u0631\u06cc\u0627\u0641\u062a \u0631\u0633\u06cc\u062f \u0628\u0647 \u0645\u0634\u062a\u0631\u06cc": {
      "main": [
        [
          {
            "node": "\u0627\u0631\u0633\u0627\u0644 \u0631\u0633\u06cc\u062f \u0628\u0647 \u0627\u062f\u0645\u06cc\u0646",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u062e\u0648\u0627\u0646\u062f\u0646 \u0633\u0641\u0627\u0631\u0634\u200c\u0647\u0627 (\u062a\u0635\u0645\u06cc\u0645 \u0627\u062f\u0645\u06cc\u0646)": {
      "main": [
        [
          {
            "node": "\u062a\u0637\u0628\u06cc\u0642 \u0633\u0641\u0627\u0631\u0634 \u0628\u0627 \u062a\u0635\u0645\u06cc\u0645",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u062a\u0637\u0628\u06cc\u0642 \u0633\u0641\u0627\u0631\u0634 \u0628\u0627 \u062a\u0635\u0645\u06cc\u0645": {
      "main": [
        [
          {
            "node": "\u0642\u0628\u0644\u0627\u064b \u067e\u0631\u062f\u0627\u0632\u0634 \u0634\u062f\u0647\u061f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0642\u0628\u0644\u0627\u064b \u067e\u0631\u062f\u0627\u0632\u0634 \u0634\u062f\u0647\u061f": {
      "main": [
        [
          {
            "node": "\u0627\u0637\u0644\u0627\u0639 \u0633\u0641\u0627\u0631\u0634 \u0642\u0628\u0644\u0627\u064b \u067e\u0631\u062f\u0627\u0632\u0634\u200c\u0634\u062f\u0647",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\u062a\u0623\u06cc\u06cc\u062f \u06cc\u0627 \u0631\u062f\u061f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u062a\u0623\u06cc\u06cc\u062f \u06cc\u0627 \u0631\u062f\u061f": {
      "main": [
        [
          {
            "node": "\u0633\u0641\u0627\u0631\u0634 \u0642\u0628\u0644\u0627\u064b \u062a\u062d\u0648\u06cc\u0644 \u0634\u062f\u0647\u061f",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\u0622\u0645\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u0631\u062f \u0633\u0641\u0627\u0631\u0634",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0633\u0641\u0627\u0631\u0634 \u0642\u0628\u0644\u0627\u064b \u062a\u062d\u0648\u06cc\u0644 \u0634\u062f\u0647\u061f": {
      "main": [
        [
          {
            "node": "\u0627\u0637\u0644\u0627\u0639 \u062a\u062d\u0648\u06cc\u0644 \u062a\u06a9\u0631\u0627\u0631\u06cc \u0628\u0647 \u0627\u062f\u0645\u06cc\u0646",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\u0622\u0645\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u062a\u0623\u06cc\u06cc\u062f \u0633\u0641\u0627\u0631\u0634",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0622\u0645\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u0631\u062f \u0633\u0641\u0627\u0631\u0634": {
      "main": [
        [
          {
            "node": "\u062b\u0628\u062a \u0631\u062f \u0633\u0641\u0627\u0631\u0634",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0622\u0645\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u062a\u0623\u06cc\u06cc\u062f \u0633\u0641\u0627\u0631\u0634": {
      "main": [
        [
          {
            "node": "\u062b\u0628\u062a \u062a\u0623\u06cc\u06cc\u062f \u0633\u0641\u0627\u0631\u0634",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u062b\u0628\u062a \u0631\u062f \u0633\u0641\u0627\u0631\u0634": {
      "main": [
        [
          {
            "node": "\u0627\u0637\u0644\u0627\u0639 \u0631\u062f \u0628\u0647 \u0645\u0634\u062a\u0631\u06cc",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u062b\u0628\u062a \u062a\u0623\u06cc\u06cc\u062f \u0633\u0641\u0627\u0631\u0634": {
      "main": [
        [
          {
            "node": "\u062e\u0648\u0627\u0646\u062f\u0646 \u0645\u062d\u0635\u0648\u0644 \u0628\u0631\u0627\u06cc \u062a\u062d\u0648\u06cc\u0644",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u062e\u0648\u0627\u0646\u062f\u0646 \u0645\u062d\u0635\u0648\u0644 \u0628\u0631\u0627\u06cc \u062a\u062d\u0648\u06cc\u0644": {
      "main": [
        [
          {
            "node": "\u062a\u0637\u0628\u06cc\u0642 \u0645\u062d\u0635\u0648\u0644 \u062a\u062d\u0648\u06cc\u0644\u06cc",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u062a\u0637\u0628\u06cc\u0642 \u0645\u062d\u0635\u0648\u0644 \u062a\u062d\u0648\u06cc\u0644\u06cc": {
      "main": [
        [
          {
            "node": "\u0622\u0645\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u0631\u062f\u06cc\u0641 \u0644\u0627\u06cc\u0633\u0646\u0633",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0622\u0645\u0627\u062f\u0647\u200c\u0633\u0627\u0632\u06cc \u0631\u062f\u06cc\u0641 \u0644\u0627\u06cc\u0633\u0646\u0633": {
      "main": [
        [
          {
            "node": "\u062b\u0628\u062a \u0644\u0627\u06cc\u0633\u0646\u0633 \u062c\u062f\u06cc\u062f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u062b\u0628\u062a \u0644\u0627\u06cc\u0633\u0646\u0633 \u062c\u062f\u06cc\u062f": {
      "main": [
        [
          {
            "node": "\u0646\u0648\u0639 \u0645\u062d\u0635\u0648\u0644 = \u0627\u067e\u0644\u06cc\u06a9\u06cc\u0634\u0646\u061f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0646\u0648\u0639 \u0645\u062d\u0635\u0648\u0644 = \u0627\u067e\u0644\u06cc\u06a9\u06cc\u0634\u0646\u061f": {
      "main": [
        [
          {
            "node": "\u062a\u062d\u0648\u06cc\u0644 \u0644\u06cc\u0646\u06a9 \u062f\u0627\u0646\u0644\u0648\u062f",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\u0627\u0637\u0644\u0627\u0639 \u0631\u0627\u0647\u200c\u0627\u0646\u062f\u0627\u0632\u06cc \u0631\u0628\u0627\u062a \u0628\u0647 \u0645\u0634\u062a\u0631\u06cc",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0627\u0637\u0644\u0627\u0639 \u0631\u0627\u0647\u200c\u0627\u0646\u062f\u0627\u0632\u06cc \u0631\u0628\u0627\u062a \u0628\u0647 \u0645\u0634\u062a\u0631\u06cc": {
      "main": [
        [
          {
            "node": "\u0627\u0637\u0644\u0627\u0639 \u0646\u06cc\u0627\u0632 \u0628\u0647 \u0631\u0627\u0647\u200c\u0627\u0646\u062f\u0627\u0632\u06cc \u062f\u0633\u062a\u06cc",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u062e\u0648\u0627\u0646\u062f\u0646 \u0633\u0641\u0627\u0631\u0634\u200c\u0647\u0627 (\u0645\u0646\u0648\u06cc \u0627\u062f\u0645\u06cc\u0646)": {
      "main": [
        [
          {
            "node": "\u0633\u0627\u062e\u062a \u0622\u0645\u0627\u0631 \u0633\u0631\u06cc\u0639 \u0627\u062f\u0645\u06cc\u0646",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0633\u0627\u062e\u062a \u0622\u0645\u0627\u0631 \u0633\u0631\u06cc\u0639 \u0627\u062f\u0645\u06cc\u0646": {
      "main": [
        [
          {
            "node": "\u0645\u0646\u0648\u06cc \u0627\u062f\u0645\u06cc\u0646",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u062e\u0648\u0627\u0646\u062f\u0646 \u0645\u0634\u062a\u0631\u06cc\u0627\u0646 (\u06af\u0632\u0627\u0631\u0634)": {
      "main": [
        [
          {
            "node": "\u062e\u0648\u0627\u0646\u062f\u0646 \u0633\u0641\u0627\u0631\u0634\u200c\u0647\u0627 (\u06af\u0632\u0627\u0631\u0634)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u062e\u0648\u0627\u0646\u062f\u0646 \u0633\u0641\u0627\u0631\u0634\u200c\u0647\u0627 (\u06af\u0632\u0627\u0631\u0634)": {
      "main": [
        [
          {
            "node": "\u062e\u0648\u0627\u0646\u062f\u0646 \u0644\u0627\u06cc\u0633\u0646\u0633\u200c\u0647\u0627 (\u06af\u0632\u0627\u0631\u0634)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u062e\u0648\u0627\u0646\u062f\u0646 \u0644\u0627\u06cc\u0633\u0646\u0633\u200c\u0647\u0627 (\u06af\u0632\u0627\u0631\u0634)": {
      "main": [
        [
          {
            "node": "\u0633\u0627\u062e\u062a \u0641\u0627\u06cc\u0644 \u06af\u0632\u0627\u0631\u0634 HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u0633\u0627\u062e\u062a \u0641\u0627\u06cc\u0644 \u06af\u0632\u0627\u0631\u0634 HTML": {
      "main": [
        [
          {
            "node": "\u0627\u0631\u0633\u0627\u0644 \u0641\u0627\u06cc\u0644 \u06af\u0632\u0627\u0631\u0634",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  }
}