Automate AI token tracking for agent usage from WhatsApp and Telegram, logging all interactions, audio transcriptions, and costs directly to Google Sheets using this powerful n8n workflow.
Download this n8n workflow template and start using it instantly.
Managing AI operational costs is crucial, especially when conversational agents are deployed across multiple platforms. This specialized n8n workflow addresses this challenge by providing a centralized tracking system. Whether the input originates from a WhatsApp message (via Evolution API webhook) or a Telegram bot, this automation ensures that every interaction, including the input text, model response, and associated token counts, is meticulously logged to Google Sheets. This n8n solution handles complexity, such as automatically transcribing audio messages before processing them with the AI Agent. By leveraging this sophisticated n8n node structure, users gain real-time visibility into cost centers and usage patterns, enabling better resource management and detailed reporting.
This automation begins with one of two starting points: the Evolution API webhook for WhatsApp or the Telegram n8n trigger. Once activated, the n8n workflow standardizes the data using Set nodes (Map/Map1).
Audio or Text Separation If n8n node. If the input is audio (often encountered in voice messages on WhatsApp/Telegram), the workflow executes an HTTP Request (GET Media) to fetch the audio file, converts it, and runs it through the Audio Transcription n8n node (OpenAI/LangChain) to convert speech to text. If the input is standard text, it bypasses transcription.AI Agent (LangChain Agent n8n node). This agent, configured with a Chat Model (likely via OpenRouter), can utilize various tools like Gmail (Send Email), Airtable (Get Contacts), and Google Calendar (Create Event) based on the user's request. The n8n Agent handles the complex interaction and provides token usage statistics in its output.Clean Up/Clean_Up) processes the result, extracting essential data including tokens used. This data is then written to a Google Sheet via the Log or Errors Google Sheets n8n node, effectively acting as your AI token tracker.Input Source Switch n8n node determines the originating platform (WhatsApp or Telegram) and uses the appropriate HTTP Request or Telegram n8n node to send the AI agent’s response back to the user, completing the full conversational loop within the n8n workflow.Evolution API Webhook n8n trigger URL in your WhatsApp provider settings, and ensure the Telegram n8n trigger is correctly configured with your Bot Token.WhatsApp and WhatsApp Erro HTTP Request n8n nodes with your specific Evolution API (or similar platform) authentication details and endpoint URLs for sending replies.Chat Model and Audio Transcription n8n nodes with your relevant OpenAI/LangChain/OpenRouter API keys.Log and Errors Google Sheets n8n nodes to point to your desired spreadsheet ID and sheet names where the usage data will be stored.Use this robust n8n workflow to automate hourly monitoring of BTC and ETH exchange rates using the Alpha Vantage API. Logs data directly to Google Sheets and alerts your team via Telegram.

Convert PDF documents into structured, SEO-optimized blog posts automatically using this advanced n8n workflow. Leverage AI extraction and Ghost CMS publishing.

Automate content creation using this advanced n8n workflow. Transform PDF documents into SEO-optimized WordPress blog posts with GPT-4o-mini and human-in-the-loop approval via Gmail.

Use this efficient n8n workflow to capture your insightful LinkedIn likes, filter recent posts, and automatically save them as structured content ideas in Airtable. Get started with this n8n templates today.

Automate daily alerts for nearby garage sales and flea markets. This powerful n8n workflow scrapes web data, filters events by distance (<= 20km), and sends timely Telegram notifications. Use this n8n template for web scraping automation.

Hi loves! I've been making workflows for n8n for two years, and I hope you like my flows <3







































