{
  "name": "06 Morning digest of open quotes and invoices",
  "nodes": [
    {
      "id": "915c9761-251d-4151-9c2b-203ded64088a",
      "name": "Weekdays 7:30",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        300
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "30 7 * * 1-5"
            }
          ]
        }
      }
    },
    {
      "id": "ca868745-8444-4813-860b-bdb9a351e56e",
      "name": "Open quotes",
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1,
      "position": [
        240,
        300
      ],
      "parameters": {
        "resource": "row",
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultName": "quotes"
        },
        "matchType": "allConditions",
        "filters": {
          "conditions": [
            {
              "keyName": "status",
              "condition": "eq",
              "keyValue": "sent"
            }
          ]
        },
        "returnAll": true
      },
      "alwaysOutputData": true
    },
    {
      "id": "d1322ddd-4b39-401c-9005-14003608cbfa",
      "name": "Open invoices",
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1,
      "position": [
        480,
        300
      ],
      "parameters": {
        "resource": "row",
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultName": "invoices"
        },
        "matchType": "allConditions",
        "filters": {
          "conditions": [
            {
              "keyName": "status",
              "condition": "eq",
              "keyValue": "open"
            }
          ]
        },
        "returnAll": true
      },
      "alwaysOutputData": true,
      "executeOnce": true
    },
    {
      "id": "2687b73b-0e9a-403f-83f1-81d331b96b04",
      "name": "Build digest",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        720,
        300
      ],
      "parameters": {
        "jsCode": "const usd = n => '$' + Number(n).toLocaleString('en-US', {minimumFractionDigits: 2});\nconst days = d => Math.floor((Date.now() - new Date(d).getTime()) / 864e5);\nconst q = $('Open quotes').all().map(i => i.json).filter(o => o.client);\nconst inv = $('Open invoices').all().map(i => i.json).filter(f => f.invoice_number);\nconst late = inv.filter(f => days(f.due_date) >= 1);\nconst r = [];\nr.push(`Open quotes: ${q.length} (total ${usd(q.reduce((s, o) => s + o.amount, 0))})`);\nfor (const o of q) r.push(`- ${o.client}: ${o.description}, ${usd(o.amount)}, sent ${days(o.sent_at)} days ago`);\nr.push('', `Overdue invoices: ${late.length} (total ${usd(late.reduce((s, f) => s + f.amount, 0))})`);\nfor (const f of late) r.push(`- ${f.invoice_number} ${f.client}: ${usd(f.amount)}, ${days(f.due_date)} days overdue`);\nreturn [{ json: { text: r.join('\\n'), empty: q.length + late.length === 0 } }];"
      },
      "notes": "No AI needed: counting and formatting is code",
      "notesInFlow": true
    },
    {
      "id": "e944bafb-acbb-444a-8847-368d915c87c7",
      "name": "Anything to report?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        960,
        300
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "l",
              "leftValue": "={{ $json.empty }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "b2fc254f-e9ef-480c-9679-59f41f6d5dea",
      "name": "Email digest",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2.1,
      "position": [
        1200,
        300
      ],
      "parameters": {
        "fromEmail": "info@example.com",
        "toEmail": "you@example.com",
        "subject": "=Morning digest {{ $now.setLocale('en-US').toFormat('cccc, MMMM d') }}",
        "emailFormat": "text",
        "text": "={{ $json.text }}",
        "options": {
          "appendAttribution": false
        }
      }
    },
    {
      "id": "56204d7c-e438-47e0-b48e-b201c75b8fb7",
      "name": "Test manually",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        560
      ],
      "parameters": {}
    },
    {
      "id": "3645914d-79fe-4154-9de0-c70ddb84e065",
      "name": "Read me",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -40,
        -160
      ],
      "parameters": {
        "content": "## Morning digest, no AI\nTested on November 11, 2026, with n8n 2.47.3.\n\n**Fill in:** an SMTP account, your own address, and the *quotes* and *invoices* tables (see templates 01 and 02).\n\nQuiet morning, no email.",
        "height": 220,
        "width": 520,
        "color": 7
      }
    }
  ],
  "connections": {
    "Weekdays 7:30": {
      "main": [
        [
          {
            "node": "Open quotes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Open quotes": {
      "main": [
        [
          {
            "node": "Open invoices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Open invoices": {
      "main": [
        [
          {
            "node": "Build digest",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build digest": {
      "main": [
        [
          {
            "node": "Anything to report?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Anything to report?": {
      "main": [
        [
          {
            "node": "Email digest",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Test manually": {
      "main": [
        [
          {
            "node": "Open quotes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  }
}