All AI Monetization Opportunities
DevelopmentAI MONETIZATION

Overlapping polls, nothing counted twice: Retailbox Automation's n8n template that tracks LLM token spend per workflow, explained node by node

This shared template monitors the cost of n8n workflows: it polls executions, deduplicates model calls, compares daily spend with workflow budgets and sends Slack alerts or optionally pauses over-budget runs.

RedditFresh-Daikon-9408
n8nCursor

Original Reddit post

View on Reddit

Overlapping polls, nothing counted twice: Retailbox Automation's n8n template that tracks LLM token spend per workflow, explained node by node

Not my template: it is Retailbox Automation's, published on n8n.io in October 2026. The video stops on each step: a Schedule Trigger fires every 15 minutes, and an Edit Fields node holds the settings: a price per 1M input and output tokens for each model, a daily budget ($5 by default), per-workflow budget overrides, and a pause switch that is off. An n8n node reads the last 100 executions of active workflows through the n8n API. A Code node walks each execution's run data, finds every chat model call, takes its token usage (or n8n's own estimate when the provider returned none), matches the model to the price list by its longest prefix, and outputs one row per call with a cost in USD.

Two Data Table nodes follow: the first keeps a call only if its callKey is not in the table yet, the second inserts the new rows. A third reads back every row finished since midnight. Another Code node sums the spend per workflow, compares it with the budget, and uses workflow static data so each workflow is flagged at most once a day. An If node follows the pause switch: true unpublishes the workflow through the n8n API, then both paths end on a Slack message with the workflow's name, today's spend, the budget and the number of calls.

What I like: the poll deliberately overlaps (the same 100 executions come back every 15 minutes), and the "row does not exist" check on a unique call key is what makes that safe. No cursor to store, nothing counted twice.

Discover your next business idea

A work in progress.

2026.11.08 · V0.4

Refined product categories and extension rankings. Added one-line Agent setup and three membership options.