{
  "name": "Receipts to spending sheet with AI",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyHour"
            }
          ]
        },
        "simple": false,
        "filters": {
          "q": "label:receipts"
        },
        "options": {}
      },
      "id": "b2fb980c-c50a-5cdb-90c0-de541ab16657",
      "name": "Email labeled receipts",
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1.2,
      "position": [
        200,
        300
      ]
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4.1-mini",
          "mode": "list",
          "cachedResultName": "GPT-4.1-MINI"
        },
        "messages": {
          "values": [
            {
              "content": "=Read this receipt email and return JSON only, in this shape: {\"date\": \"YYYY-MM-DD\", \"vendor\": \"\", \"amount\": 0, \"currency\": \"\"}. Use null for anything not in the email.\n\nSubject: {{ $json.subject }}\n\n{{ ($json.text || '').slice(0, 4000) }}"
            }
          ]
        },
        "options": {},
        "jsonOutput": true
      },
      "id": "9b197b1f-2947-5725-83f0-18857b1d8ef7",
      "name": "Extract the details",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        420,
        300
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "r1",
              "name": "date",
              "value": "={{ $json.message.content.date }}",
              "type": "string"
            },
            {
              "id": "r2",
              "name": "vendor",
              "value": "={{ $json.message.content.vendor }}",
              "type": "string"
            },
            {
              "id": "r3",
              "name": "amount",
              "value": "={{ $json.message.content.amount }}",
              "type": "number"
            },
            {
              "id": "r4",
              "name": "currency",
              "value": "={{ $json.message.content.currency }}",
              "type": "string"
            },
            {
              "id": "r5",
              "name": "email_subject",
              "value": "={{ $('Email labeled receipts').item.json.subject }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "4b4635df-f02c-5327-a5fa-8b68aeaa46fa",
      "name": "Pick the fields",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        640,
        300
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {},
          "matchingColumns": [],
          "schema": []
        },
        "options": {}
      },
      "id": "0aaaab06-32a5-5520-9707-90998cb3c5c3",
      "name": "Add row to sheet",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        860,
        300
      ]
    },
    {
      "parameters": {
        "content": "## Draft, not yet tested\nThis workflow was written by Automation Recipes and has NOT been run end to end yet.\n\nAfter importing: open each node, connect your own accounts (credentials), and fill in anything left blank (sheet URL, Slack channel, label names). Then run it once by hand with test data before turning it on.",
        "height": 260,
        "width": 420
      },
      "id": "dfdd35cb-8ba8-520d-8b4d-3c6f07faefd0",
      "name": "Read me",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        20
      ]
    }
  ],
  "connections": {
    "Email labeled receipts": {
      "main": [
        [
          {
            "node": "Extract the details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract the details": {
      "main": [
        [
          {
            "node": "Pick the fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pick the fields": {
      "main": [
        [
          {
            "node": "Add row to sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": []
}