Meter AI token usage and prepaid Lago credits with webhook receipts
UnknownWhat this workflow does
This workflow has 15 nodes and runs when an HTTP POST request hits its webhook URL. Along the way it connects Lago (community).
How it runs
Trigger: When an HTTP POST request hits its webhook URL.
- Normalize AI Usage Data (Code): runs custom JavaScript code
- If: checks a condition and branches into true / false
- Compute Usage Fees (Lago): estimate fees (event)
- Send Validation Error Response (Respond to Webhook): sends the response back to the webhook caller
- Total Estimated Fees (Code): runs custom JavaScript code
- Retrieve Prepaid Wallet (Lago): get (wallet)
- Determine Credit Level (Code): runs custom JavaScript code
- Transmit Usage Event (Lago): work with event
- Create Metering Receipt (Code): runs custom JavaScript code
- Check Low Credit Alert (If): checks a condition and branches into true / false
…plus 4 more steps. See the full node list below.
Services it uses
Before you upgrade to n8n 3.0
We can't fully verify this one: it relies on 1 community package, and n8n 3.0 turns unverified community packages off by default (N8N_UNVERIFIED_PACKAGES_ENABLED=false).
- Check that @blackswampai/n8n-nodes-lago is verified or supports 3.0 (used in Compute Usage Fees, Retrieve Prepaid Wallet, Transmit Usage Event).
Nodes used (6)
- Webhook
n8n-nodes-base.webhook - Code
n8n-nodes-base.code - If
n8n-nodes-base.if - Lago
@blackswampai/n8n-nodes-lago.lago - Edit Fields (Set)
n8n-nodes-base.set - Respond to Webhook
n8n-nodes-base.respondToWebhook
From the author
Quick overview This workflow receives AI token usage via a webhook, estimates the prepaid cost and projected credit balance in Lago, records the usage as a Lago event, and returns a receipt that warns when credits are at or below a configurable threshold. How…