Track AI agent costs and decisions via webhooks and WhatsApp digests
Quick overview This workflow exposes webhooks to record AI agent events (LLM calls, tool calls, decisions, and errors), calculates estimated cost from token usage, stores a persistent execution ledger in n8n static data, and sends WhatsApp alerts and daily digests with spend and activity summaries.
How it works Receives a POST webhook request with one event or a batch of agent events to log. Validates each event and calculates cost from input/output token counts and model pricing (or an explicit USD cost plus optional tool cost). Appends the priced events to a persistent ledger in n8n workflow static data, updates per-run summaries, and enforces retention limits for total entries and runs. Responds to the webhook caller with a JSON summary including how many events were recorded and the updated run totals. Sends a WhatsApp message if a run exceeds the configured per-run budget and no alert has been sent for that run yet. Receives a GET webhook request to generate a JSON ledger report filtered by run ID, agent, time window, and limit. Runs daily on a schedule to build a 24-hour cost/activity digest and sends it via WhatsApp.
Setup Add WhatsApp Business credentials for the WhatsApp nodes and set your WhatsApp phone number ID and recipient phone number. Configure the ledger settings (per-run budget, token pricing per 1M tokens, and retention limits) in the workflow’s configuration values. Activate the workflow so the ledger persists in workflow static data, then copy the webhook URLs and configure your agents/supervisor to POST events to the event endpoint and query reports from the report endpoint.
Related Templates
Automated Work Attendance with Location Triggers
his workflow automates time tracking using location-based triggers. How it works Trigger: It starts when you enter or e...
Automated SEO Performance Collection from Google Search Console to NocoDB
Problem Monitoring SEO performance from Google Search Console (GSC) manually is repetitive and prone to human error. Fo...
Summarize SERPBear data with AI (via Openrouter) and save it to Baserow
Who's this for? If you own a website and need to analyze your keyword rankings If you need to create a keyword report on...
🔒 Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments