{"product_id":"n8n-ai-spend-cap-per-workflow-with-google-sheets-slack","title":"n8n AI Spend Cap per Workflow with Google Sheets \u0026 Slack","description":"\u003ch3\u003eAI Spend Cap per n8n Workflow—Budgeted with Google Sheets + Slack Alerts\u003c\/h3\u003e\n\u003cp\u003eStop surprise AI costs. This n8n workflow enforces a \u003cstrong\u003eper-workflow daily AI spend cap\u003c\/strong\u003e by tracking token usage in an n8n Data Table, consulting budgets and model pricing in \u003cstrong\u003eGoogle Sheets\u003c\/strong\u003e, and sending targeted \u003cstrong\u003eSlack\u003c\/strong\u003e alerts when thresholds are crossed.\u003c\/p\u003e\n\n\u003ch3\u003eWhat this workflow does\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eReceives a call\u003c\/strong\u003e from another workflow via an \u003ccode\u003eExecute Workflow\u003c\/code\u003e action with an \u003ccode\u003eaction\u003c\/code\u003e of \u003cstrong\u003echeck\u003c\/strong\u003e (pre-flight) or \u003cstrong\u003erecord\u003c\/strong\u003e (post-call), plus the workflow name and usage or estimates.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eLoads budget rules\u003c\/strong\u003e from Google Sheets tab \u003cstrong\u003e“Budgets”\u003c\/strong\u003e and \u003cstrong\u003emodel token pricing\u003c\/strong\u003e from tab \u003cstrong\u003e“Model Prices”\u003c\/strong\u003e.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eResolves the correct budget\u003c\/strong\u003e row (or uses a configured default), applies the configured \u003cstrong\u003eUTC offset\u003c\/strong\u003e to determine the current budget day, and reads spend totals from an \u003cstrong\u003en8n Data Table\u003c\/strong\u003e ledger.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eFor action = check:\u003c\/strong\u003e calculates whether the estimated token cost fits within the remaining daily cap and returns \u003cstrong\u003eallowed\/blocked\u003c\/strong\u003e back to the calling workflow.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eFor action = record:\u003c\/strong\u003e prices actual token usage using Google Sheets rates (or a fallback rate for unknown models), updates the ledger, and posts \u003cstrong\u003eSlack\u003c\/strong\u003e alerts \u003cem\u003eonly\u003c\/em\u003e when warning\/cap thresholds are crossed.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eDaily summary:\u003c\/strong\u003e runs on a schedule, reads \u003cstrong\u003eyesterday’s\u003c\/strong\u003e ledger entries, and sends a single Slack message summarizing spend by workflow (posts nothing if there were no entries).\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eUse cases\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003ePrevent runaway spend in AI-driven n8n automations (chat, summarization, extraction) by blocking requests before they exceed daily caps.\u003c\/li\u003e\n  \u003cli\u003eRoute operational visibility to teams via Slack when a workflow approaches (warning) or hits (cap) its daily budget.\u003c\/li\u003e\n  \u003cli\u003eProvide SaaS operators with daily, per-workflow cost reporting using an audit-friendly ledger in n8n Data Table.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eTechnical details\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eGoogle Sheets\u003c\/strong\u003e: reads \u003cstrong\u003eBudgets\u003c\/strong\u003e and \u003cstrong\u003eModel Prices\u003c\/strong\u003e tabs (spreadsheet ID required).\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003en8n Data Table\u003c\/strong\u003e: stores token\/cost totals as a ledger and supports daily rollups.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eSlack\u003c\/strong\u003e: sends one-time threshold alerts and a daily spend summary.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eCore nodes\u003c\/strong\u003e: if, set, code, slack, switch, data table.\u003c\/li\u003e\n\u003c\/ul\u003e\n\u003cp\u003e\u003cstrong\u003eSetup note:\u003c\/strong\u003e Create and connect Google Sheets credentials, set the spreadsheet ID, and ensure the required \u003cem\u003e“Budgets”\u003c\/em\u003e and \u003cem\u003e“Model Prices”\u003c\/em\u003e tabs match the node’s expected columns.\u003c\/p\u003e","brand":"N8N Commerce","offers":[{"title":"Default Title","offer_id":46190203863219,"sku":"N8N-20655","price":75.99,"currency_code":"GBP","in_stock":true}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0749\/6279\/6723\/files\/bdPjqGHtB_WRjY_ok9k1S_UKuS0QFG.png?v=1791450171","url":"https:\/\/buyflowscripts.com\/products\/n8n-ai-spend-cap-per-workflow-with-google-sheets-slack","provider":"N8N Commerce","version":"1.0","type":"link"}