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
- Every 15 minutes
- Set configuration
- Read checkpoint
- Get new executions
- Extract LLM calls and cost
- Skip calls already logged
- Insert usage rows
- Get last 8 days of usage
- Analyze usage and find alerts
- Pause over-budget workflow?
- Unpublish workflow
- Route alert by channel
- Send alert by email
- Send alert to Telegram
16 steps in total.
Similar automations
Code, Git & Developer ToolsTrack LLM token spend per workflow with n8n API, data tables, and Slack alerts11 stepsFinance, Invoices & AccountingExtract Gmail Invoice Spend Details with Claude and Gemini27 stepsFinance, Invoices & AccountingExtract Gmail Invoice Spend Details with Claude and Gemini27 stepsFinance, Invoices & AccountingExtract Spend Details from Invoice Emails with AI21 steps