{
  "updatedAt": "2026-03-25T03:06:36.172Z",
  "createdAt": "2026-03-25T02:31:24.236Z",
  "id": "Qno1QlN4jMFvzwja",
  "name": "Weekly Business Report",
  "description": null,
  "active": true,
  "isArchived": false,
  "nodes": [
    {
      "id": "cron-1",
      "name": "Monday 8am CT",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        200,
        300
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 8,
              "triggerAtDay": 1
            }
          ]
        }
      }
    },
    {
      "id": "http-1",
      "name": "Get Twenty Companies",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        420,
        100
      ],
      "parameters": {
        "method": "GET",
        "url": "https://YOUR_TWENTY_URL",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_JWT_TOKEN"
            }
          ]
        }
      }
    },
    {
      "id": "http-2",
      "name": "Get Twenty Opportunities",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        420,
        300
      ],
      "parameters": {
        "method": "GET",
        "url": "https://YOUR_TWENTY_URL",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_JWT_TOKEN"
            }
          ]
        }
      }
    },
    {
      "id": "http-3",
      "name": "Get InvoiceNinja Metrics",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        420,
        500
      ],
      "parameters": {
        "method": "GET",
        "url": "https://YOUR_SERVICE_URL",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Api-Token",
              "value": "ESptGETLrVRBcXQ61FrsKcLbJffsUwozIX9UzfqRspaKoQv6Af1z7AsSVCQsRNej"
            },
            {
              "name": "X-Requested-With",
              "value": "XMLHttpRequest"
            }
          ]
        }
      }
    },
    {
      "id": "http-4",
      "name": "Get Listmonk Stats",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        420,
        700
      ],
      "parameters": {
        "method": "GET",
        "url": "https://YOUR_LISTMONK_URL",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "={{ 'Basic ' + Buffer.from('WhtnxtAPI:RDdNiY7XIXdfb8rgQDnorlyqKIOSgIIG').toString('base64') }}"
            }
          ]
        }
      }
    },
    {
      "id": "code-1",
      "name": "Compile Report",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        700,
        300
      ],
      "parameters": {
        "jsCode": "// Compile weekly business report from all data sources\nconst companies = $('Get Twenty Companies').first().json?.data?.companies || [];\nconst opportunities = $('Get Twenty Opportunities').first().json?.data?.opportunities || [];\nconst invoiceData = $('Get InvoiceNinja Metrics').first().json?.data || [];\nconst listmonkData = $('Get Listmonk Stats').first().json?.data?.results || [];\n\n// CRM Metrics\nconst totalCompanies = companies.length;\nconst activeDeals = opportunities.filter(o => o.stage && o.stage !== 'WON' && o.stage !== 'LOST').length;\nconst wonDeals = opportunities.filter(o => o.stage === 'WON').length;\n\n// Invoice Metrics\nconst outstandingInvoices = invoiceData.filter(i => ['2','3'].includes(i.status_id));\nconst totalOutstanding = outstandingInvoices.reduce((sum, i) => sum + (i.balance || 0), 0);\nconst overdueInvoices = outstandingInvoices.filter(i => i.due_date && new Date(i.due_date) < new Date());\n\n// Listmonk Metrics\nconst listStats = listmonkData.map(l => ({ name: l.name, subscribers: l.subscriber_count || 0 }));\n\nconst now = new Date();\nconst weekOf = now.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' });\n\nconst report = `# Whtnxt Weekly Report - Week of ${weekOf}\\n\\n## CRM\\n- Total Companies: ${totalCompanies}\\n- Active Deals: ${activeDeals}\\n- Won Deals: ${wonDeals}\\n\\n## Billing\\n- Outstanding Invoices: ${outstandingInvoices.length}\\n- Total Outstanding: $${totalOutstanding.toFixed(2)}\\n- Overdue: ${overdueInvoices.length}\\n\\n## Email Lists\\n${listStats.map(l => `- ${l.name}: ${l.subscribers} subscribers`).join('\\n')}\\n`;\n\nconst htmlReport = report.replace(/# (.*)/g, '<h1>$1</h1>').replace(/## (.*)/g, '<h2>$1</h2>').replace(/- (.*)/g, '<li>$1</li>').replace(/\\n/g, '');\n\nreturn [{ json: { markdown: report, html: htmlReport, weekOf } }];"
      }
    },
    {
      "id": "http-5",
      "name": "Publish to Outline",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        920,
        200
      ],
      "parameters": {
        "method": "POST",
        "url": "https://YOUR_OUTLINE_URL",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer ol_YOUR_API_KEY"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ title: 'Weekly Report - ' + $json.weekOf, text: $json.markdown, collectionId: 'f9f25fea-d55e-41ff-9bfe-5c9d8c202f06', publish: true }) }}"
      }
    },
    {
      "id": "gmail-1",
      "name": "Email Report",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        920,
        400
      ],
      "parameters": {
        "sendTo": "your-email@example.com",
        "subject": "={{ 'Whtnxt Weekly Report - ' + $('Compile Report').first().json.weekOf }}",
        "message": "={{ $('Compile Report').first().json.html }}",
        "options": {}
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "YOUR_CREDENTIAL_ID",
          "name": "YOUR_CREDENTIAL_NAME"
        }
      }
    }
  ],
  "connections": {
    "Monday 8am CT": {
      "main": [
        [
          {
            "node": "Get Twenty Companies",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get Twenty Opportunities",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get InvoiceNinja Metrics",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get Listmonk Stats",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Twenty Companies": {
      "main": [
        [
          {
            "node": "Compile Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Twenty Opportunities": {
      "main": [
        [
          {
            "node": "Compile Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get InvoiceNinja Metrics": {
      "main": [
        [
          {
            "node": "Compile Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Listmonk Stats": {
      "main": [
        [
          {
            "node": "Compile Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Compile Report": {
      "main": [
        [
          {
            "node": "Publish to Outline",
            "type": "main",
            "index": 0
          },
          {
            "node": "Email Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "timezone": "America/Chicago",
    "callerPolicy": "workflowsFromSameOwner",
    "availableInMCP": false
  },
  "staticData": {
    "node:Monday 8am CT": {
      "recurrenceRules": []
    }
  },
  "pinData": null,
  "versionId": "e98d0148-5483-490a-8131-443ea16b10b8",
  "activeVersionId": "e98d0148-5483-490a-8131-443ea16b10b8",
  "versionCounter": 13,
  "triggerCount": 1,
  "shared": [
    {
      "updatedAt": "2026-03-25T02:31:24.236Z",
      "createdAt": "2026-03-25T02:31:24.236Z",
      "role": "workflow:owner",
      "workflowId": "Qno1QlN4jMFvzwja",
      "projectId": "6RTJ3ead58ncl4Hy",
      "project": {
        "updatedAt": "2025-01-23T18:31:39.020Z",
        "createdAt": "2025-01-23T05:37:52.794Z",
        "id": "6RTJ3ead58ncl4Hy",
        "name": "Edward Chalupa <your-email@example.com>",
        "type": "personal",
        "icon": null,
        "description": null,
        "creatorId": "e67b6366-69ec-43f2-91cb-2e5098f53def"
      }
    }
  ],
  "tags": [],
  "activeVersion": {
    "updatedAt": "2026-03-25T03:06:29.118Z",
    "createdAt": "2026-03-25T03:06:29.118Z",
    "versionId": "e98d0148-5483-490a-8131-443ea16b10b8",
    "workflowId": "Qno1QlN4jMFvzwja",
    "nodes": [
      {
        "id": "cron-1",
        "name": "Monday 8am CT",
        "type": "n8n-nodes-base.scheduleTrigger",
        "typeVersion": 1.2,
        "position": [
          200,
          300
        ],
        "parameters": {
          "rule": {
            "interval": [
              {
                "triggerAtHour": 8,
                "triggerAtDay": 1
              }
            ]
          }
        }
      },
      {
        "id": "http-1",
        "name": "Get Twenty Companies",
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4.2,
        "position": [
          420,
          100
        ],
        "parameters": {
          "method": "GET",
          "url": "https://YOUR_TWENTY_URL",
          "sendHeaders": true,
          "headerParameters": {
            "parameters": [
              {
                "name": "Authorization",
                "value": "Bearer YOUR_JWT_TOKEN"
              }
            ]
          }
        }
      },
      {
        "id": "http-2",
        "name": "Get Twenty Opportunities",
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4.2,
        "position": [
          420,
          300
        ],
        "parameters": {
          "method": "GET",
          "url": "https://YOUR_TWENTY_URL",
          "sendHeaders": true,
          "headerParameters": {
            "parameters": [
              {
                "name": "Authorization",
                "value": "Bearer YOUR_JWT_TOKEN"
              }
            ]
          }
        }
      },
      {
        "id": "http-3",
        "name": "Get InvoiceNinja Metrics",
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4.2,
        "position": [
          420,
          500
        ],
        "parameters": {
          "method": "GET",
          "url": "https://YOUR_SERVICE_URL",
          "sendHeaders": true,
          "headerParameters": {
            "parameters": [
              {
                "name": "X-Api-Token",
                "value": "ESptGETLrVRBcXQ61FrsKcLbJffsUwozIX9UzfqRspaKoQv6Af1z7AsSVCQsRNej"
              },
              {
                "name": "X-Requested-With",
                "value": "XMLHttpRequest"
              }
            ]
          }
        }
      },
      {
        "id": "http-4",
        "name": "Get Listmonk Stats",
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4.2,
        "position": [
          420,
          700
        ],
        "parameters": {
          "method": "GET",
          "url": "https://YOUR_LISTMONK_URL",
          "sendHeaders": true,
          "headerParameters": {
            "parameters": [
              {
                "name": "Authorization",
                "value": "={{ 'Basic ' + Buffer.from('WhtnxtAPI:RDdNiY7XIXdfb8rgQDnorlyqKIOSgIIG').toString('base64') }}"
              }
            ]
          }
        }
      },
      {
        "id": "code-1",
        "name": "Compile Report",
        "type": "n8n-nodes-base.code",
        "typeVersion": 2,
        "position": [
          700,
          300
        ],
        "parameters": {
          "jsCode": "// Compile weekly business report from all data sources\nconst companies = $('Get Twenty Companies').first().json?.data?.companies || [];\nconst opportunities = $('Get Twenty Opportunities').first().json?.data?.opportunities || [];\nconst invoiceData = $('Get InvoiceNinja Metrics').first().json?.data || [];\nconst listmonkData = $('Get Listmonk Stats').first().json?.data?.results || [];\n\n// CRM Metrics\nconst totalCompanies = companies.length;\nconst activeDeals = opportunities.filter(o => o.stage && o.stage !== 'WON' && o.stage !== 'LOST').length;\nconst wonDeals = opportunities.filter(o => o.stage === 'WON').length;\n\n// Invoice Metrics\nconst outstandingInvoices = invoiceData.filter(i => ['2','3'].includes(i.status_id));\nconst totalOutstanding = outstandingInvoices.reduce((sum, i) => sum + (i.balance || 0), 0);\nconst overdueInvoices = outstandingInvoices.filter(i => i.due_date && new Date(i.due_date) < new Date());\n\n// Listmonk Metrics\nconst listStats = listmonkData.map(l => ({ name: l.name, subscribers: l.subscriber_count || 0 }));\n\nconst now = new Date();\nconst weekOf = now.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' });\n\nconst report = `# Whtnxt Weekly Report - Week of ${weekOf}\\n\\n## CRM\\n- Total Companies: ${totalCompanies}\\n- Active Deals: ${activeDeals}\\n- Won Deals: ${wonDeals}\\n\\n## Billing\\n- Outstanding Invoices: ${outstandingInvoices.length}\\n- Total Outstanding: $${totalOutstanding.toFixed(2)}\\n- Overdue: ${overdueInvoices.length}\\n\\n## Email Lists\\n${listStats.map(l => `- ${l.name}: ${l.subscribers} subscribers`).join('\\n')}\\n`;\n\nconst htmlReport = report.replace(/# (.*)/g, '<h1>$1</h1>').replace(/## (.*)/g, '<h2>$1</h2>').replace(/- (.*)/g, '<li>$1</li>').replace(/\\n/g, '');\n\nreturn [{ json: { markdown: report, html: htmlReport, weekOf } }];"
        }
      },
      {
        "id": "http-5",
        "name": "Publish to Outline",
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4.2,
        "position": [
          920,
          200
        ],
        "parameters": {
          "method": "POST",
          "url": "https://YOUR_OUTLINE_URL",
          "sendHeaders": true,
          "headerParameters": {
            "parameters": [
              {
                "name": "Authorization",
                "value": "Bearer ol_YOUR_API_KEY"
              }
            ]
          },
          "sendBody": true,
          "specifyBody": "json",
          "jsonBody": "={{ JSON.stringify({ title: 'Weekly Report - ' + $json.weekOf, text: $json.markdown, collectionId: 'f9f25fea-d55e-41ff-9bfe-5c9d8c202f06', publish: true }) }}"
        }
      },
      {
        "id": "gmail-1",
        "name": "Email Report",
        "type": "n8n-nodes-base.gmail",
        "typeVersion": 2.1,
        "position": [
          920,
          400
        ],
        "parameters": {
          "sendTo": "your-email@example.com",
          "subject": "={{ 'Whtnxt Weekly Report - ' + $('Compile Report').first().json.weekOf }}",
          "message": "={{ $('Compile Report').first().json.html }}",
          "options": {}
        },
        "credentials": {
          "gmailOAuth2": {
            "id": "YOUR_CREDENTIAL_ID",
            "name": "YOUR_CREDENTIAL_NAME"
          }
        }
      }
    ],
    "connections": {
      "Monday 8am CT": {
        "main": [
          [
            {
              "node": "Get Twenty Companies",
              "type": "main",
              "index": 0
            },
            {
              "node": "Get Twenty Opportunities",
              "type": "main",
              "index": 0
            },
            {
              "node": "Get InvoiceNinja Metrics",
              "type": "main",
              "index": 0
            },
            {
              "node": "Get Listmonk Stats",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Get Twenty Companies": {
        "main": [
          [
            {
              "node": "Compile Report",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Get Twenty Opportunities": {
        "main": [
          [
            {
              "node": "Compile Report",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Get InvoiceNinja Metrics": {
        "main": [
          [
            {
              "node": "Compile Report",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Get Listmonk Stats": {
        "main": [
          [
            {
              "node": "Compile Report",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Compile Report": {
        "main": [
          [
            {
              "node": "Publish to Outline",
              "type": "main",
              "index": 0
            },
            {
              "node": "Email Report",
              "type": "main",
              "index": 0
            }
          ]
        ]
      }
    },
    "authors": "Edward Chalupa",
    "name": null,
    "description": null,
    "autosaved": false,
    "workflowPublishHistory": [
      {
        "createdAt": "2026-03-25T03:06:36.320Z",
        "id": 112,
        "workflowId": "Qno1QlN4jMFvzwja",
        "versionId": "e98d0148-5483-490a-8131-443ea16b10b8",
        "event": "activated",
        "userId": "e67b6366-69ec-43f2-91cb-2e5098f53def"
      }
    ]
  }
}