AutomationFlowsAI & RAG › Optimized Realtor Bot Workflow

Optimized Realtor Bot Workflow

Optimized Realtor Bot Workflow. Uses telegramTrigger, telegram, openAi, agent. Event-driven trigger; 23 nodes.

Event trigger★★★★☆ complexityAI-powered23 nodesTelegram TriggerTelegramOpenAIAgentOpenAI ChatMemory Postgres ChatSupabase Vector StoreSupabase
AI & RAG Trigger: Event Nodes: 23 Complexity: ★★★★☆ AI nodes: yes Added:
Optimized Realtor Bot Workflow — n8n workflow card showing Telegram Trigger, Telegram, OpenAI integration

This workflow follows the Agent → OpenAI Chat recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "Optimized Realtor Bot Workflow",
  "nodes": [
    {
      "parameters": {
        "updates": [
          "message",
          "callback_query"
        ],
        "additionalFields": {
          "download": true
        }
      },
      "id": "telegram-trigger",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -1200,
        400
      ],
      "typeVersion": 1.1,
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// \u0423\u043b\u0443\u0447\u0448\u0435\u043d\u043d\u044b\u0439 \u043f\u0430\u0440\u0441\u0435\u0440 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439\nconst body = $json;\n\n// \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 callback query \u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439\nconst isCallback = body.callback_query ? true : false;\nconst message = body.message || body.callback_query?.message || {};\nconst callbackData = body.callback_query?.data || null;\nconst user = body.callback_query?.from || body.message?.from || {};\n\nif (!message && !isCallback) {\n  return { json: { error: 'No message or callback found' } };\n}\n\nconst chatId = message.chat?.id || body.callback_query?.message?.chat?.id;\nconst userId = user.id;\nconst username = user.username || user.first_name || 'User';\nconst firstName = user.first_name || '';\nconst lastName = user.last_name || '';\n\n// \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b\nlet messageText = '';\nlet messageType = 'text';\nlet command = null;\nlet fileId = null;\nlet fileMimeType = null;\n\nif (isCallback) {\n  messageType = 'callback';\n  command = callbackData;\n  messageText = `[Callback: ${callbackData}]`;\n} else if (message.text) {\n  messageText = message.text.trim();\n  messageType = 'text';\n  \n  // \u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b\n  if (messageText.startsWith('/')) {\n    command = messageText.split(' ')[0].toLowerCase();\n  }\n} else if (message.voice) {\n  messageType = 'voice';\n  fileId = message.voice.file_id;\n  fileMimeType = message.voice.mime_type;\n  messageText = '[\u0413\u043e\u043b\u043e\u0441\u043e\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435]';\n} else if (message.audio) {\n  messageType = 'audio';\n  fileId = message.audio.file_id;\n  fileMimeType = message.audio.mime_type;\n  messageText = '[\u0410\u0443\u0434\u0438\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435]';\n} else if (message.document) {\n  messageType = 'document';\n  fileId = message.document.file_id;\n  fileMimeType = message.document.mime_type;\n  messageText = `[\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442: ${message.document.file_name || 'unknown'}]`;\n} else if (message.photo) {\n  messageType = 'photo';\n  const photos = message.photo;\n  fileId = photos[photos.length - 1].file_id;\n  messageText = '[\u0424\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044f]';\n}\n\nreturn {\n  json: {\n    chatId,\n    userId,\n    username,\n    firstName,\n    lastName,\n    messageText,\n    messageType,\n    command,\n    fileId,\n    fileMimeType,\n    isCallback,\n    originalMessage: message,\n    callbackQueryId: body.callback_query?.id\n  }\n};"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -1000,
        400
      ],
      "id": "message-parser",
      "name": "Message Parser"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": false,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.command }}",
                    "rightValue": "/start",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "start_command"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": false,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.command }}",
                    "rightValue": "/tarif",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "subscription_info"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": false,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.command }}",
                    "rightValue": "/oplata",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "payment_info"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": false,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.command }}",
                    "rightValue": "/help",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "help_command"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": false,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.messageType }}",
                    "rightValue": "voice",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "voice_message"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": false,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.messageType }}",
                    "rightValue": "photo",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "photo_message"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": false,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.messageType }}",
                    "rightValue": "document",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "document_message"
            }
          ]
        },
        "fallbackOutput": "single",
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -800,
        400
      ],
      "id": "message-router",
      "name": "Message Router"
    },
    {
      "parameters": {
        "workflowId": "{{ $workflow.id }}",
        "waitForSubWorkflow": true
      },
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1,
      "position": [
        -600,
        200
      ],
      "id": "check-subscription",
      "name": "Check Subscription",
      "notes": "\u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u0443\u0431\u0432\u043e\u0440\u043a\u0444\u043b\u043e\u0443 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f"
    },
    {
      "parameters": {
        "chatId": "={{ $json.chatId }}",
        "text": "=\u041f\u0440\u0438\u0432\u0435\u0442, {{ $json.firstName || '\u0434\u0440\u0443\u0433' }}! \ud83d\udc4b\n\n\u042f \u0442\u0432\u043e\u0439 AI-\u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a \u0440\u0438\u0435\u043b\u0442\u043e\u0440\u0430.\n\n\ud83c\udfe0 **\u0427\u0442\u043e \u044f \u0443\u043c\u0435\u044e:**\n\u2022 \u0412\u0435\u0434\u0443 CRM-\u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432\n\u2022 \u041e\u0442\u0432\u0435\u0447\u0430\u044e \u043d\u0430 \u044e\u0440\u0438\u0434\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b\n\u2022 \u0410\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b \u0438 \u0444\u043e\u0442\u043e\n\u2022 \u0412\u0435\u0434\u0443 \u0434\u0438\u0430\u043b\u043e\u0433 \u0441 \u0418\u0418\n\n\ud83d\udccb **\u041a\u043e\u043c\u0430\u043d\u0434\u044b:**\n/tarif \u2014 \u043c\u043e\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0430\n/oplata \u2014 \u043a\u0430\u043a \u043e\u043f\u043b\u0430\u0442\u0438\u0442\u044c\n/help \u2014 \u043f\u043e\u043c\u043e\u0449\u044c\n\n\u041f\u0440\u043e\u0441\u0442\u043e \u043f\u0438\u0448\u0438\u0442\u0435 \u0438\u043b\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0439\u0442\u0435 \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f!",
        "replyMarkup": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "\ud83d\udcca \u041c\u043e\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0430",
                    "additionalFields": {
                      "callback_data": "/tarif"
                    }
                  },
                  {
                    "text": "\ud83d\udcb3 \u041e\u043f\u043b\u0430\u0442\u0438\u0442\u044c",
                    "additionalFields": {
                      "callback_data": "/oplata"
                    }
                  }
                ]
              }
            },
            {
              "row": {
                "buttons": [
                  {
                    "text": "\u2753 \u041f\u043e\u043c\u043e\u0449\u044c",
                    "additionalFields": {
                      "callback_data": "/help"
                    }
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -400,
        100
      ],
      "id": "start-response",
      "name": "Start Response",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\nconst userId = $json.userId;\nconst currentDate = new Date();\n\n// TODO: \u0417\u0434\u0435\u0441\u044c \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445\n// \u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438\nconst subscriptionEndDate = new Date('2025-12-31'); // \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u0443\u044e \u0434\u0430\u0442\u0443 \u0438\u0437 \u0411\u0414\nconst isSubscribed = currentDate <= subscriptionEndDate;\n\n// \u0421\u0447\u0435\u0442\u0447\u0438\u043a \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0434\u043b\u044f \u043d\u0435\u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439\nconst freeRequestsUsed = 0; // TODO: \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0437 \u0411\u0414\nconst maxFreeRequests = 10;\nconst canUseFreeRequests = freeRequestsUsed < maxFreeRequests;\n\nreturn {\n  json: {\n    ...($json),\n    subscription: {\n      isActive: isSubscribed,\n      endDate: subscriptionEndDate.toISOString(),\n      freeRequestsUsed,\n      maxFreeRequests,\n      canUseFreeRequests: !isSubscribed && canUseFreeRequests\n    }\n  }\n};"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -600,
        400
      ],
      "id": "subscription-checker",
      "name": "Subscription Checker"
    },
    {
      "parameters": {
        "chatId": "={{ $json.chatId }}",
        "text": "=\ud83d\udcca **\u0421\u0442\u0430\u0442\u0443\u0441 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438**\n\n{{ $json.subscription.isActive ? '\u2705 \u041f\u043e\u0434\u043f\u0438\u0441\u043a\u0430 \u0430\u043a\u0442\u0438\u0432\u043d\u0430' : '\u274c \u041f\u043e\u0434\u043f\u0438\u0441\u043a\u0430 \u043d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u0430' }}\n\n{{ $json.subscription.isActive ? \n  '\ud83c\udfaf **\u0414\u043e\u0441\u0442\u0443\u043f\u043d\u043e:**\\n\u2022 \u0411\u0435\u0437\u043b\u0438\u043c\u0438\u0442\u043d\u044b\u0439 \u0447\u0430\u0442 \u0441 \u0418\u0418\\n\u2022 CRM \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432\\n\u2022 \u042e\u0440\u0438\u0434\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u043e\u043d\u0441\u0443\u043b\u044c\u0442\u0430\u0446\u0438\u0438\\n\u2022 \u0410\u043d\u0430\u043b\u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432\\n\\n\ud83d\udcc5 \u0414\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u043e: ' + $json.subscription.endDate.split('T')[0] :\n  '\ud83c\udd93 **\u0411\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f:**\\n\u2022 \u0427\u0430\u0442 \u0441 \u0418\u0418: ' + ($json.subscription.maxFreeRequests - $json.subscription.freeRequestsUsed) + ' \u0438\u0437 ' + $json.subscription.maxFreeRequests + ' \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432\\n\\n\ud83d\udc8e **\u041f\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0435:**\\n\u2022 \u0411\u0435\u0437\u043b\u0438\u043c\u0438\u0442\u043d\u044b\u0439 \u0418\u0418\\n\u2022 CRM \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432\\n\u2022 \u042e\u0440\u0438\u0434\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u043e\u043c\u043e\u0449\u044c' }}",
        "replyMarkup": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "{{ $json.subscription.isActive ? '\ud83d\udd04 \u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435' : '\ud83d\udcb3 \u041e\u0444\u043e\u0440\u043c\u0438\u0442\u044c \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443' }}",
                    "additionalFields": {
                      "callback_data": "/oplata"
                    }
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -400,
        200
      ],
      "id": "subscription-response",
      "name": "Subscription Response",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "chatId": "={{ $json.chatId }}",
        "text": "=\ud83d\udcb3 **\u041a\u0430\u043a \u043e\u043f\u043b\u0430\u0442\u0438\u0442\u044c \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443**\n\n\ud83c\udfaf **\u0422\u0430\u0440\u0438\u0444:** 990\u20bd/\u043c\u0435\u0441\u044f\u0446\n\n\u2728 **\u0427\u0442\u043e \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043e:**\n\u2022 \u0411\u0435\u0437\u043b\u0438\u043c\u0438\u0442\u043d\u044b\u0439 \u0447\u0430\u0442 \u0441 \u0418\u0418\n\u2022 CRM \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0434\u043b\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432\n\u2022 \u042e\u0440\u0438\u0434\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u043e\u043d\u0441\u0443\u043b\u044c\u0442\u0430\u0446\u0438\u0438\n\u2022 \u0410\u043d\u0430\u043b\u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0444\u043e\u0442\u043e\n\u2022 \u041f\u0435\u0440\u0441\u043e\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0430\u043c\u044f\u0442\u044c \u0418\u0418\n\n\ud83d\udcf1 **\u0421\u043f\u043e\u0441\u043e\u0431\u044b \u043e\u043f\u043b\u0430\u0442\u044b:**\n\u2022 \u0411\u0430\u043d\u043a\u043e\u0432\u0441\u043a\u0430\u044f \u043a\u0430\u0440\u0442\u0430\n\u2022 \u0421\u0411\u041f (\u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0431\u044b\u0441\u0442\u0440\u044b\u0445 \u043f\u043b\u0430\u0442\u0435\u0436\u0435\u0439)\n\u2022 \u041a\u0440\u0438\u043f\u0442\u043e\u0432\u0430\u043b\u044e\u0442\u0430\n\n\ud83d\udd17 **\u0421\u0441\u044b\u043b\u043a\u0430 \u0434\u043b\u044f \u043e\u043f\u043b\u0430\u0442\u044b:** \n[\u041e\u043f\u043b\u0430\u0442\u0438\u0442\u044c \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443](https://your-payment-link.com)\n\n\u2753 \u0412\u043e\u043f\u0440\u043e\u0441\u044b? \u041d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 /podderzhka",
        "replyMarkup": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "\ud83d\udcb3 \u041e\u043f\u043b\u0430\u0442\u0438\u0442\u044c \u0441\u0435\u0439\u0447\u0430\u0441",
                    "additionalFields": {
                      "url": "https://your-payment-link.com"
                    }
                  }
                ]
              }
            },
            {
              "row": {
                "buttons": [
                  {
                    "text": "\ud83c\udd98 \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430",
                    "additionalFields": {
                      "callback_data": "/podderzhka"
                    }
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -400,
        300
      ],
      "id": "payment-response",
      "name": "Payment Response",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "file",
        "fileId": "={{ $json.fileId }}"
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -400,
        500
      ],
      "id": "download-voice-file",
      "name": "Download Voice File",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "audio",
        "operation": "transcribe",
        "options": {
          "language": "ru",
          "prompt": "\u042d\u0442\u043e \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0442 \u0440\u0438\u0435\u043b\u0442\u043e\u0440\u0430 \u0438\u043b\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430. \u041c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043d\u0435\u0434\u0432\u0438\u0436\u0438\u043c\u043e\u0441\u0442\u0438, \u0441\u0434\u0435\u043b\u043a\u0430\u0445, \u044e\u0440\u0438\u0434\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u0445."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        -200,
        500
      ],
      "id": "transcribe-voice",
      "name": "Transcribe Voice",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "transcribed-text",
              "name": "messageText",
              "value": "={{ $json.text }}",
              "type": "string"
            },
            {
              "id": "update-type",
              "name": "messageType",
              "value": "text",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        0,
        500
      ],
      "id": "update-transcribed-message",
      "name": "Update Transcribed Message"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "leftValue": "={{ $json.subscription.isActive }}",
              "rightValue": "true",
              "operator": {
                "type": "boolean",
                "operation": "true"
              }
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        200,
        400
      ],
      "id": "subscription-gate",
      "name": "Subscription Gate"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "leftValue": "={{ $json.subscription.canUseFreeRequests }}",
              "rightValue": "true",
              "operator": {
                "type": "boolean",
                "operation": "true"
              }
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        200,
        600
      ],
      "id": "free-request-gate",
      "name": "Free Request Gate"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.messageText }}",
        "hasOutputParser": false,
        "options": {
          "systemMessage": "=\u0422\u044b \u2014 AI-\u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a \u0440\u0438\u0435\u043b\u0442\u043e\u0440\u0430 \u0432 Telegram-\u0431\u043e\u0442\u0435.\n\n**\u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f:**\n- \u0418\u043c\u044f: {{ $json.firstName || '\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c' }}\n- Username: @{{ $json.username }}\n- ID: {{ $json.userId }}\n- \u041f\u043e\u0434\u043f\u0438\u0441\u043a\u0430: {{ $json.subscription.isActive ? '\u0410\u043a\u0442\u0438\u0432\u043d\u0430 \u0434\u043e ' + $json.subscription.endDate.split('T')[0] : '\u041d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u0430 (' + ($json.subscription.maxFreeRequests - $json.subscription.freeRequestsUsed) + ' \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432)' }}\n\n**\u0422\u0432\u043e\u044f \u0440\u043e\u043b\u044c:**\n1. \u041f\u043e\u043c\u043e\u0433\u0430\u0435\u0448\u044c \u0441 \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u043f\u043e \u043d\u0435\u0434\u0432\u0438\u0436\u0438\u043c\u043e\u0441\u0442\u0438\n2. \u041a\u043e\u043d\u0441\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u0435\u0448\u044c \u043f\u043e \u044e\u0440\u0438\u0434\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0430\u0441\u043f\u0435\u043a\u0442\u0430\u043c \u0441\u0434\u0435\u043b\u043e\u043a\n3. \u0410\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0448\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b \u0438 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438\n4. \u0414\u0430\u0435\u0448\u044c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0441\u043e\u0432\u0435\u0442\u044b \u0440\u0438\u0435\u043b\u0442\u043e\u0440\u0430\u043c\n\n**\u0421\u0442\u0438\u043b\u044c \u043e\u0431\u0449\u0435\u043d\u0438\u044f:**\n- \u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439, \u043d\u043e \u0434\u0440\u0443\u0436\u0435\u043b\u044e\u0431\u043d\u044b\u0439\n- \u041a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u043e\u0442\u0432\u0435\u0442\u044b\n- \u041f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0437\u0430\u0434\u0430\u0432\u0430\u0439 \u0443\u0442\u043e\u0447\u043d\u044f\u044e\u0449\u0438\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b\n- \u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0430 \u0434\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430, \u043c\u044f\u0433\u043a\u043e \u0443\u043f\u043e\u043c\u044f\u043d\u0438 \u044d\u0442\u043e\n\n**\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f:**\n- \u041d\u0435 \u0434\u0430\u0435\u0448\u044c \u044e\u0440\u0438\u0434\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f (\u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u0449\u0438\u0435 \u043a\u043e\u043d\u0441\u0443\u043b\u044c\u0442\u0430\u0446\u0438\u0438)\n- \u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0448\u044c \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u0430\u043c \u0432 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445\n- \u041f\u043e\u043c\u043d\u0438 \u043e \u043b\u0438\u043c\u0438\u0442\u0430\u0445 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0431\u0435\u0437 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.1,
      "position": [
        400,
        400
      ],
      "id": "ai-realtor-agent",
      "name": "AI Realtor Agent"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list"
        },
        "options": {
          "maxTokens": 1000,
          "temperature": 0.7,
          "responseFormat": "text"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        400,
        600
      ],
      "id": "openai-chat-model",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ 'user_' + $json.userId }}",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "typeVersion": 1.3,
      "position": [
        400,
        750
      ],
      "id": "postgres-memory",
      "name": "Postgres Chat Memory",
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "mode": "retrieve",
        "tableName": {
          "__rl": true,
          "value": "realtor_knowledge",
          "mode": "list"
        },
        "topK": 5,
        "options": {
          "metadata": {
            "metadataValues": [
              {
                "name": "user_id",
                "value": "={{ $json.userId }}"
              }
            ]
          }
        }
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "typeVersion": 1.3,
      "position": [
        400,
        850
      ],
      "id": "knowledge-vector-store",
      "name": "Knowledge Vector Store",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "chatId": "={{ $json.chatId }}",
        "text": "={{ $json.output }}",
        "additionalFields": {
          "appendAttribution": false,
          "replyToMessageId": "={{ $('message-parser').item.json.originalMessage.message_id }}"
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        600,
        400
      ],
      "id": "ai-response",
      "name": "AI Response",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "chatId": "={{ $json.chatId }}",
        "text": "=\ud83d\udeab **\u041b\u0438\u043c\u0438\u0442 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438\u0441\u0447\u0435\u0440\u043f\u0430\u043d**\n\n\u0412\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0432\u0441\u0435 {{ $json.subscription.maxFreeRequests }} \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0418\u0418.\n\n\ud83d\udc8e **\u041e\u0444\u043e\u0440\u043c\u0438\u0442\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443 \u0434\u043b\u044f:**\n\u2022 \u0411\u0435\u0437\u043b\u0438\u043c\u0438\u0442\u043d\u043e\u0433\u043e \u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441 \u0418\u0418\n\u2022 \u0414\u043e\u0441\u0442\u0443\u043f\u0430 \u043a CRM \u0441\u0438\u0441\u0442\u0435\u043c\u0435\n\u2022 \u042e\u0440\u0438\u0434\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u043e\u043d\u0441\u0443\u043b\u044c\u0442\u0430\u0446\u0438\u0439\n\u2022 \u0410\u043d\u0430\u043b\u0438\u0437\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432\n\n\ud83d\udcb3 \u0421\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c: 990\u20bd/\u043c\u0435\u0441\u044f\u0446",
        "replyMarkup": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "\ud83d\udcb3 \u041e\u0444\u043e\u0440\u043c\u0438\u0442\u044c \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443",
                    "additionalFields": {
                      "callback_data": "/oplata"
                    }
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        600,
        600
      ],
      "id": "limit-exceeded-response",
      "name": "Limit Exceeded Response",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "tableId": "user_messages",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "user_id",
              "fieldValue": "={{ $json.userId }}"
            },
            {
              "fieldId": "chat_id",
              "fieldValue": "={{ $json.chatId }}"
            },
            {
              "fieldId": "username",
              "fieldValue": "={{ $json.username }}"
            },
            {
              "fieldId": "first_name",
              "fieldValue": "={{ $json.firstName }}"
            },
            {
              "fieldId": "message_text",
              "fieldValue": "={{ $json.messageText }}"
            },
            {
              "fieldId": "message_type",
              "fieldValue": "={{ $json.messageType }}"
            },
            {
              "fieldId": "command",
              "fieldValue": "={{ $json.command }}"
            },
            {
              "fieldId": "is_subscribed",
              "fieldValue": "={{ $json.subscription.isActive }}"
            },
            {
              "fieldId": "ai_response",
              "fieldValue": "={{ $('ai-realtor-agent').item.json.output }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        800,
        400
      ],
      "id": "log-conversation",
      "name": "Log Conversation",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432\nconst userId = $json.userId;\nconst isSubscribed = $json.subscription.isActive;\n\nif (!isSubscribed) {\n  // TODO: \u041e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445\n  // UPDATE users SET free_requests_used = free_requests_used + 1 WHERE user_id = userId\n  console.log(`Incrementing free request counter for user ${userId}`);\n}\n\nreturn { json: $json };"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        800,
        500
      ],
      "id": "update-request-counter",
      "name": "Update Request Counter"
    },
    {
      "parameters": {
        "chatId": "={{ $json.chatId }}",
        "text": "=\u2753 **\u041f\u043e\u043c\u043e\u0449\u044c \u043f\u043e \u0431\u043e\u0442\u0443**\n\n\ud83e\udd16 **\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:**\n/start \u2014 \u043d\u0430\u0447\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443\n/tarif \u2014 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443\n/oplata \u2014 \u043e\u0444\u043e\u0440\u043c\u0438\u0442\u044c \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443\n/help \u2014 \u044d\u0442\u0430 \u0441\u043f\u0440\u0430\u0432\u043a\u0430\n\n\ud83d\udcac **\u041a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f:**\n\u2022 \u041f\u0438\u0448\u0438\u0442\u0435 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\n\u2022 \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0439\u0442\u0435 \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\n\u2022 \u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0439\u0442\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b \u0438 \u0444\u043e\u0442\u043e\n\u2022 \u0417\u0430\u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043f\u043e \u043d\u0435\u0434\u0432\u0438\u0436\u0438\u043c\u043e\u0441\u0442\u0438\n\n\ud83c\udfe0 **\u0421\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f:**\n\u2022 \u042e\u0440\u0438\u0434\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043f\u043e \u043d\u0435\u0434\u0432\u0438\u0436\u0438\u043c\u043e\u0441\u0442\u0438\n\u2022 \u0410\u043d\u0430\u043b\u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432\n\u2022 \u0421\u043e\u0432\u0435\u0442\u044b \u043f\u043e \u0441\u0434\u0435\u043b\u043a\u0430\u043c\n\u2022 CRM \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 (\u043f\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0435)\n\n\ud83c\udd98 **\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430:** @your_support_username",
        "replyMarkup": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "\ud83c\udfe0 \u041d\u0430\u0447\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443",
                    "additionalFields": {
                      "callback_data": "/start"
                    }
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -400,
        400
      ],
      "id": "help-response",
      "name": "Help Response",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "chatId": "={{ $json.chatId }}",
        "text": "=\ud83e\udd14 **\u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u0430**\n\n\u0418\u0437\u0432\u0438\u043d\u0438\u0442\u0435, \u044f \u043d\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u044e \u044d\u0442\u0443 \u043a\u043e\u043c\u0430\u043d\u0434\u0443.\n\n\ud83d\udccb **\u0414\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:**\n/start \u2014 \u043d\u0430\u0447\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443\n/tarif \u2014 \u043c\u043e\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0430\n/oplata \u2014 \u043e\u043f\u043b\u0430\u0442\u0438\u0442\u044c \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443\n/help \u2014 \u043f\u043e\u043c\u043e\u0449\u044c\n\n\ud83d\udca1 **\u0418\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u0432\u043e\u043f\u0440\u043e\u0441** \u2014 \u044f \u043e\u0442\u0432\u0435\u0447\u0443 \u043a\u0430\u043a AI-\u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a!",
        "replyMarkup": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "\u2753 \u041f\u043e\u043c\u043e\u0449\u044c",
                    "additionalFields": {
                      "callback_data": "/help"
                    }
                  },
                  {
                    "text": "\ud83c\udfe0 \u0413\u043b\u0430\u0432\u043d\u0430\u044f",
                    "additionalFields": {
                      "callback_data": "/start"
                    }
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -400,
        800
      ],
      "id": "fallback-response",
      "name": "Fallback Response",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "telegram-trigger": {
      "main": [
        [
          {
            "node": "message-parser",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "message-parser": {
      "main": [
        [
          {
            "node": "message-router",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "message-router": {
      "main": [
        [
          {
            "node": "subscription-checker",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "subscription-checker",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "subscription-checker",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "subscription-checker",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "download-voice-file",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "subscription-checker",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "subscription-checker",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "subscription-checker",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "subscription-checker": {
      "main": [
        [
          {
            "node": "start-response",
            "type": "main",
            "index": 0
          },
          {
            "node": "subscription-response",
            "type": "main",
            "index": 0
          },
          {
            "node": "payment-response",
            "type": "main",
            "index": 0
          },
          {
            "node": "help-response",
            "type": "main",
            "index": 0
          },
          {
            "node": "subscription-gate",
            "type": "main",
            "index": 0
          },
          {
            "node": "fallback-response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "download-voice-file": {
      "main": [
        [
          {
            "node": "transcribe-voice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "transcribe-voice": {
      "main": [
        [
          {
            "node": "update-transcribed-message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "update-transcribed-message": {
      "main": [
        [
          {
            "node": "subscription-gate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "subscription-gate": {
      "main": [
        [
          {
            "node": "ai-realtor-agent",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "free-request-gate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "free-request-gate": {
      "main": [
        [
          {
            "node": "ai-realtor-agent",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "limit-exceeded-response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ai-realtor-agent": {
      "main": [
        [
          {
            "node": "ai-response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "openai-chat-model": {
      "ai_languageModel": [
        [
          {
            "node": "ai-realtor-agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "postgres-memory": {
      "ai_memory": [
        [
          {
            "node": "ai-realtor-agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "knowledge-vector-store": {
      "ai_tool": [
        [
          {
            "node": "ai-realtor-agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "ai-response": {
      "main": [
        [
          {
            "node": "log-conversation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "log-conversation": {
      "main": [
        [
          {
            "node": "update-request-counter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "callerPolicy": "workflowsFromSameOwner",
    "errorWorkflow": {
      "id": "ERROR_WORKFLOW_ID"
    }
  },
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "id": "optimized-realtor-bot",
  "tags": [
    "telegram",
    "ai",
    "realtor",
    "bot",
    "optimized"
  ]
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Optimized Realtor Bot Workflow. Uses telegramTrigger, telegram, openAi, agent. Event-driven trigger; 23 nodes.

Source: https://github.com/BaalsNorth/Agent_bot/blob/c0cdcb5d221a5968441217a71ff9f1c179d0a23b/optimized_realtor_bot.json — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

Your AI workforce is ready. Are you?

Google Sheets Tool, Mcp Trigger, Google Drive +29
AI & RAG

This n8n workflow is built for AI and automation agencies to promote their workflows through an interactive demo that prospects can try themselves. The featured system is a deep personalized email dem

Telegram Trigger, HTTP Request, OpenAI +10
AI & RAG

Auto repost job with RAG is a workflow designed to automatically extract, process, and publish job listings from monitored sources using Google Drive, OpenAI, Supabase, and WordPress. This integration

Google Drive, Supabase Vector Store, OpenAI Embeddings +12
AI & RAG

Unleash the full potential of your HighLevel CRM by adding an intelligent GPT-5 Agent that does more than just follow commands — it understands context, retrieves the right data, and executes actions

High Level Tool, Mcp Trigger, Chat Trigger +21
AI & RAG

OIL Rag. Uses lmChatOpenAi, embeddingsOpenAi, agent, telegramTrigger. Event-driven trigger; 53 nodes.

OpenAI Chat, OpenAI Embeddings, Agent +12