Track OpenAI token usage and AI agent metrics with Google Sheets dashboard
Needs changesWhat this workflow does
This AI workflow has 7 nodes and runs when a chat message arrives. Along the way it connects Google Sheets.
How it runs
Trigger: When a chat message arrives.
- Set • Workflow + Client Metadata (Edit Fields (Set)): sets 3 fields: workflow_id, execution_id, client_id
- AI Agent: runs an AI agent, with model: LangChain Chat Model + Token Callback
- Branch • Tool Used? (If): checks a condition and branches into true / false
- Log • Token Metrics to Sheets (Tool) (Google Sheets): append
Services it uses
Before you upgrade to n8n 3.0
1 thing in this workflow is removed in n8n 3.0. Fix it before you upgrade:
- LangChain Code (legacy) in LangChain Chat Model + Token Callback: no direct replacement.
Rather not rewrite it? Many of these flows can be rebuilt in Make (free plan).
| Removed in 3.0 | Replace with |
|---|---|
| LangChain Code (legacy) LangChain Chat Model + Token Callback | No direct replacement |
Nodes used (7)
- Chat Trigger
@n8n/n8n-nodes-langchain.chatTrigger - AI Agent
@n8n/n8n-nodes-langchain.agent - Google Sheets Tool
n8n-nodes-base.googleSheetsTool - Edit Fields (Set)
n8n-nodes-base.set - LangChain Code
@n8n/n8n-nodes-langchain.code - If
n8n-nodes-base.if - Google Sheets
n8n-nodes-base.googleSheets
From the author
What it does Captures token usage and cost from your AI Agent/LLM. Logs model, tokens, cost, tool use, and conversation I/O to Google Sheets for simple observability and billing. Perfect for Developers adding usage monitoring to AI agents. Teams needing cost…