Track AI costs, guard prompts and rebill clients with Claude and Google Sheets
Ready for 3.0What this workflow does
This AI workflow has 38 nodes and runs when another workflow calls it (plus 2 other triggers). Along the way it connects Google Sheets, Slack, Guardrails and Anthropic Chat Model and 1 more.
How it runs
Trigger: When another workflow calls it (plus 2 other triggers).
- Workflow Configuration (Edit Fields (Set)): sets 12 fields: cost_alert_usd, block_when_over_cost_limit, pricing_per_million_tokens…
- Sample Guard Requests (Code): runs custom JavaScript code
- Route by Guard (Switch): routes items into 4 branches
- Call AutoGuard (Execute Sub-workflow): calls another n8n workflow
- Calculate AI Cost (Code): runs custom JavaScript code
- Validate Workflow Output (Code): runs custom JavaScript code
- Mask Personal Data (Guardrails): sanitize
- Read Cost Ledger (Google Sheets): uses Google Sheets
- Return Unknown Guard Error (Edit Fields (Set)): sets 4 fields: guard, allowed, verdict…
- Log to Cost Ledger (Google Sheets): append
…plus 24 more steps. See the full node list below.
Services it uses
Other Google Sheets + Gmail templates (2,102) · Other Google Sheets + Slack templates (1,314) · Other Gmail + Slack templates (957)
Before you upgrade to n8n 3.0
Nothing in this workflow is removed in n8n 3.0, so it should import and run after the upgrade.
- Code node: the task timeout drops from 300s to 60s. Test with a realistic data volume.
Nodes used (15)
- Execute Workflow Trigger
n8n-nodes-base.executeWorkflowTrigger - Edit Fields (Set)
n8n-nodes-base.set - Schedule Trigger
n8n-nodes-base.scheduleTrigger - Switch
n8n-nodes-base.switch - Code
n8n-nodes-base.code - Google Sheets
n8n-nodes-base.googleSheets - If
n8n-nodes-base.if - Slack
n8n-nodes-base.slack - Merge
n8n-nodes-base.merge - Guardrails
@n8n/n8n-nodes-langchain.guardrails - Anthropic Chat Model
@n8n/n8n-nodes-langchain.lmChatAnthropic - Filter
n8n-nodes-base.filter - Gmail
n8n-nodes-base.gmail - Manual Trigger
n8n-nodes-base.manualTrigger - Execute Sub-workflow
n8n-nodes-base.executeWorkflow
From the author
Quick overview This workflow acts as a shared governance sub-workflow that other n8n workflows call to track per-run AI costs, validate workflow outputs, and screen inputs for prompt injection using Anthropic Claude plus Guardrails. It logs to Google Sheets…