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

Library / Email Automation

Email Automation

Track LLM spend per workflow and send budget alerts via the n8n API

On a schedule, it handles email with Claude and Google Gemini using Data Table, SMTP Email, n8n API, Slack.

What it does

## START HERE: Track LLM spend per workflow Who it's for: teams running AI workflows on n8n who want to see which workflow, node and model spends the tokens, and get warned before a looping agent burns the budget. Nothing to add to your existing workflows. ### How it works 1. Every 15 minutes it reads only the executions finished since the last run, through the n8n API. 2. It finds every LLM call: chat model sub-nodes (OpenAI, Anthropic, Gemini...), and raw LLM responses from HTTP Request and standalone AI nodes such as *Message a model*. 3. New calls go into a data table, one row per call, priced from your price list. 4. It checks today's spend and sends alerts for: budget overruns, spikes vs the 7-day average, loops (too many calls in one execution) and models with no price. 5. Alerts go to Slack, email, Telegram or any webhook (Discord, Google Chat...). 6. Optional: unpublish a workflow that goes over budget. Off by default. ### Setup checklist 1. In n8n, open *Settings > n8n API* and create an API key. Create an n8n API credential with it (Base URL: https://your-n8n.example.com/api/v1). Select it in *Get new executions* and *Unpublish workflow*. 2. Create the data table from the note on the right. Select it in the 3 data table nodes. 3. Fill in Set configuration (see the Configuration note). 4. Add a credential only for the alert channel you use. 5. Click Execute workflow once and check the new rows. 6. Publish the workflow. The checkpoint and the once-per-day alert memory are saved only in production runs. Requirements: n8n with the public API (self-hosted, or a Cloud plan with API access) and Data tables.

The steps

  1. Every 15 minutes
  2. Set configuration
  3. Read checkpoint
  4. Get new executions
  5. Extract LLM calls and cost
  6. Skip calls already logged
  7. Insert usage rows
  8. Get last 8 days of usage
  9. Analyze usage and find alerts
  10. Pause over-budget workflow?
  11. Unpublish workflow
  12. Route alert by channel
  13. Send alert by email
  14. Send alert to Telegram

16 steps in total.

Similar automations