{
  "name": "OCR Receipts to Notion",
  "nodes": [
    {
      "id": "e5f6a7b8-5555-4000-8000-000000000001",
      "name": "Webhook (Receipt Upload)",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [-480, 300],
      "parameters": { "path": "receipt-upload" },
      "webhookId": "wh-receipt-001"
    },
    {
      "id": "e5f6a7b8-5555-4000-8000-000000000002",
      "name": "Upload to Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [-280, 300],
      "parameters": { "operation": "upload", "name": "={{'Receipt - ' + new Date().toISOString().split('T')[0] + '.jpg'}}" },
      "credentials": { "googleDriveOAuth2Api": { "id": null, "name": "Google Drive OAuth2" } }
    },
    {
      "id": "e5f6a7b8-5555-4000-8000-000000000003",
      "name": "Anthropic Claude Vision",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "typeVersion": 1,
      "position": [-80, 300],
      "parameters": {
        "options": { "model": "claude-3-haiku-20240307", "maxTokens": 2000 },
        "messages": { "values": [{ "role": "user", "message": "Extract from this receipt: merchantName, date (YYYY-MM-DD), total, subtotal, tax, items (array of {name, price}), category, paymentMethod. Return JSON." }] }
      },
      "credentials": { "anthropicApi": { "id": null, "name": "Anthropic API" } }
    },
    {
      "id": "e5f6a7b8-5555-4000-8000-000000000004",
      "name": "Parse Receipt",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [120, 300],
      "parameters": {
        "jsCode": "const raw = $input.first().json;\nconst text = raw.output || raw.text || '{}';\nlet r;\ntry { r = JSON.parse(text); } catch (e) { r = { merchantName: 'Unknown', total: 0, category: 'other' }; }\nreturn [{ json: { merchantName: r.merchantName, date: r.date || new Date().toISOString().split('T')[0], total: r.total || 0, category: r.category || 'other' } }];"
      }
    },
    {
      "id": "e5f6a7b8-5555-4000-8000-000000000005",
      "name": "OpenAI Embeddings",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "typeVersion": 1,
      "position": [320, 420],
      "parameters": { "model": "text-embedding-3-small" },
      "credentials": { "openAiApi": { "id": null, "name": "OpenAI API" } }
    },
    {
      "id": "e5f6a7b8-5555-4000-8000-000000000006",
      "name": "Supabase Vector",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "typeVersion": 1,
      "position": [520, 420],
      "parameters": { "tableName": "receipts", "queryName": "match_receipts" },
      "credentials": { "supabaseApi": { "id": null, "name": "Supabase API" } }
    },
    {
      "id": "e5f6a7b8-5555-4000-8000-000000000007",
      "name": "Notion (Create Page)",
      "type": "n8n-nodes-base.notion",
      "typeVersion": 1,
      "position": [320, 140],
      "parameters": { "operation": "create", "resource": "page", "title": "={{'Receipt: ' + $node['Parse Receipt'].json.merchantName}}" },
      "credentials": { "notionApi": { "id": null, "name": "Notion API" } }
    },
    {
      "id": "e5f6a7b8-5555-4000-8000-000000000008",
      "name": "Webhook Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 2,
      "position": [720, 300],
      "parameters": { "respondWith": "json", "responseBody": "={{ { success: true, merchant: $node['Parse Receipt'].json.merchantName } }}" }
    }
  ],
  "connections": {
    "Webhook (Receipt Upload)": { "main": [[{ "node": "Upload to Google Drive", "type": "main", "index": 0 }]] },
    "Upload to Google Drive": { "main": [[{ "node": "Anthropic Claude Vision", "type": "main", "index": 0 }]] },
    "Anthropic Claude Vision": { "main": [[{ "node": "Parse Receipt", "type": "main", "index": 0 }]] },
    "Parse Receipt": { "main": [[{ "node": "Notion (Create Page)", "type": "main", "index": 0 }]] },
    "OpenAI Embeddings": { "ai_embedding": [[{ "node": "Supabase Vector", "type": "ai_embedding", "index": 0 }]] },
    "Notion (Create Page)": { "main": [[{ "node": "Webhook Response", "type": "main", "index": 0 }]] }
  },
  "settings": { "executionOrder": "v1" },
  "staticData": null,
  "pinData": {},
  "triggerCount": 1,
  "meta": { "templateCredsSetupCompleted": true }
}
