{
  "name": "Real Estate Bot",
  "nodes": [
    {
      "parameters": {
        "updates": [
          "message"
        ]
      },
      "id": "1",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1,
      "position": [
        240,
        300
      ],
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {},
      "id": "2",
      "name": "Route by Message Type",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 1,
      "position": [
        460,
        300
      ]
    },
    {
      "parameters": {
        "resource": "file",
        "operation": "download",
        "fileId": "={{$json.message.voice.file_id}}"
      },
      "id": "3",
      "name": "Download Voice",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1,
      "position": [
        680,
        200
      ],
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "transcribe",
        "options": {}
      },
      "id": "4",
      "name": "Whisper Transcribe",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1,
      "position": [
        900,
        200
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "message",
        "model": "gpt-4o",
        "messages": {
          "values": [
            {
              "content": "={{$json.text}}"
            }
          ]
        },
        "options": {
          "systemMessage": "Extract object data from voice transcription into JSON with fields: objectType, shortTitle, description, purpose, price{value,currency}, owner{name,phone}, notes. Return only valid JSON."
        }
      },
      "id": "5",
      "name": "Parse Object Data",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1,
      "position": [
        1120,
        200
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "return JSON.parse($input.item.json.choices[0].message.content);"
      },
      "id": "6",
      "name": "Parse JSON Response",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1340,
        200
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "SPREADSHEET_ID",
          "mode": "id"
        },
        "sheetName": "Objects",
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "timestamp": "={{$now.toISO()}}",
            "objectType": "={{$json.objectType}}",
            "title": "={{$json.shortTitle}}",
            "description": "={{$json.description}}",
            "purpose": "={{$json.purpose}}",
            "price": "={{$json.price.value}}",
            "currency": "={{$json.price.currency}}",
            "owner_name": "={{$json.owner.name}}",
            "owner_phone": "={{$json.owner.phone}}",
            "notes": "={{$json.notes}}",
            "latitude": "={{$('Get Location').item.json.message.location.latitude}}",
            "longitude": "={{$('Get Location').item.json.message.location.longitude}}"
          }
        },
        "options": {}
      },
      "id": "7",
      "name": "Save to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [
        1560,
        200
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "latitude": "={{$json.message.location.latitude}}",
        "longitude": "={{$json.message.location.longitude}}"
      },
      "id": "8",
      "name": "Get Location",
      "type": "n8n-nodes-base.setNode",
      "typeVersion": 1,
      "position": [
        680,
        300
      ]
    },
    {
      "parameters": {
        "operation": "upload",
        "binaryData": true,
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "root"
        },
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "FOLDER_ID"
        },
        "options": {}
      },
      "id": "9",
      "name": "Upload to Drive",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        900,
        400
      ],
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "file",
        "operation": "download",
        "fileId": "={{$json.message.photo[0].file_id}}"
      },
      "id": "10",
      "name": "Download Photo",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1,
      "position": [
        680,
        400
      ],
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "chatId": "={{$json.message.chat.id}}",
        "text": "\u041e\u0431\u044a\u0435\u043a\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d! \n\u0422\u0438\u043f: {{$('Parse JSON Response').item.json.objectType}}\n\u0426\u0435\u043d\u0430: {{$('Parse JSON Response').item.json.price.value}} {{$('Parse JSON Response').item.json.price.currency}}"
      },
      "id": "11",
      "name": "Send Confirmation",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1,
      "position": [
        1780,
        200
      ],
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Route by Message Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by Message Type": {
      "main": [
        [
          {
            "node": "Download Voice",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Location",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download Photo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Voice": {
      "main": [
        [
          {
            "node": "Whisper Transcribe",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Whisper Transcribe": {
      "main": [
        [
          {
            "node": "Parse Object Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Object Data": {
      "main": [
        [
          {
            "node": "Parse JSON Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse JSON Response": {
      "main": [
        [
          {
            "node": "Save to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save to Google Sheets": {
      "main": [
        [
          {
            "node": "Send Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Photo": {
      "main": [
        [
          {
            "node": "Upload to Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {},
  "staticData": null
}