{
  "name": "عکس فاکتور ← ردیف در Google Sheets",
  "nodes": [
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {
          "download": true,
          "imageSize": "large"
        }
      },
      "id": "d4c344c6-5692-41d1-9dc1-205fcf0886fe",
      "name": "عکس فاکتور در تلگرام",
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.1,
      "position": [
        0,
        0
      ],
      "webhookId": "74e1ef93-dd6c-4618-80ab-6a5284f0ad5d",
      "credentials": {
        "telegramApi": {
          "id": "telegram",
          "name": "Telegram Bot"
        }
      }
    },
    {
      "parameters": {
        "operation": "binaryToPropery",
        "destinationKey": "img",
        "options": {}
      },
      "id": "39b7f7ac-39f6-4e24-98ce-eff4ce5e1118",
      "name": "تبدیل عکس به base64",
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [
        220,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://nabegheapi.ir/v1/chat/completions",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ model: 'nabeghe/vision', response_format: { type: 'json_object' }, messages: [ { role: 'system', content: \"از روی تصویر فاکتور یا رسید فقط یک JSON با این کلیدها برگردان: date (تاریخ)، vendor (فروشنده)، total (مبلغ کل به عدد)، currency، items (فهرست کوتاه اقلام به‌صورت متن). اگر چیزی خوانا نیست، رشته‌ی خالی بگذار.\" }, { role: 'user', content: [ { type: 'text', text: 'این فاکتور را استخراج کن' }, { type: 'image_url', image_url: { url: 'data:image/jpeg;base64,' + $json.img } } ] } ] }) }}",
        "options": {
          "timeout": 120000
        }
      },
      "id": "118b8dfc-20d6-46bc-9368-324e17f4f587",
      "name": "استخراج اطلاعات (Nabeghe API)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        440,
        0
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "nabeghe-api",
          "name": "Nabeghe API"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const j = JSON.parse($json.choices[0].message.content || '{}');\nreturn [{ json: { date: j.date || '', vendor: j.vendor || '', total: j.total || '', currency: j.currency || '', items: Array.isArray(j.items) ? j.items.join('، ') : (j.items || '') } }];"
      },
      "id": "672ed8b6-47ac-4c39-8425-7f30774b2e98",
      "name": "مرتب‌کردن",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        660,
        0
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "YOUR_SHEET_ID",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {}
        },
        "options": {}
      },
      "id": "b753ed88-2cbe-4045-9ce6-d334f07d1eb1",
      "name": "ثبت در Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        880,
        0
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "google",
          "name": "Google Sheets"
        }
      }
    }
  ],
  "connections": {
    "عکس فاکتور در تلگرام": {
      "main": [
        [
          {
            "node": "تبدیل عکس به base64",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "تبدیل عکس به base64": {
      "main": [
        [
          {
            "node": "استخراج اطلاعات (Nabeghe API)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "استخراج اطلاعات (Nabeghe API)": {
      "main": [
        [
          {
            "node": "مرتب‌کردن",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "مرتب‌کردن": {
      "main": [
        [
          {
            "node": "ثبت در Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false,
    "source": "nabeghemarket.ir/automation"
  },
  "pinData": {},
  "tags": []
}