Skip to content
NEWMarketplace and your team: sell what you build, and get plans and changes that are tested before you see them. See what is new

Library / Monitoring, Ops & Incidents

Monitoring, Ops & Incidents

Cap daily AI spend per workflow with Data Table, Google Sheets and Slack

Sub-workflow that AI workflows call before and after each model call to check and record spend against a daily budget, stopping runaway usage and sending Slack alerts.

What it does

## Cap daily AI spend per workflow and alert in Slack n8n counts executions, not dollars. A looping agent, an unexpectedly busy day or a prompt that pulls in far more context than you planned can run up a large model bill overnight, and nothing in the platform stops it or tells you. This is a sub-workflow that gives every AI workflow its own daily ceiling. ### How it works An AI workflow calls this twice. Before the model, with action check, it gets back whether the call fits inside today's remaining budget, so a runaway is stopped at the next call rather than found on the invoice. After the model, with action record, it passes the usage object straight through and the call is priced and added to the day's total. Prices sit in a sheet rather than in the code, because they change every few weeks, and a model missing from that sheet is charged at a deliberately pessimistic fallback rate rather than counted as free, which is how budgets quietly stop working. Each workflow gets its own cap and its own Slack channel from a Budgets tab, with one row named default catching everything else. The day boundary follows the offset you set, not UTC midnight. Slack is told once when the warning line is crossed and once when the cap is reached, never on every call after. The next morning, one message reports what each workflow cost and which ones ran into their ceiling. ### Setup Connect Sheets and Slack, create the data table with the columns on the ledger node, and fill the Budgets and Model Prices tabs. ### Note This caps workflows that call it. It cannot police one that does not, so wire it into the expensive ones first.

The steps

  1. Called By Your AI Workflow
  2. Read The Request
  3. Load Budgets
  4. Load Model Prices
  5. Resolve Budget And Day
  6. Read Today's Ledger Row
  7. Check Or Record?
  8. Decide Allow Or Block
  9. Return The Decision
  10. Price The Call
  11. Update The Ledger
  12. Crossed A Threshold?
  13. Send The Budget Alert
  14. Return The New Total

19 steps in total.

Similar automations