Run budget-capped client AI agents with OpenAI and n8n data tables
Ready for 3.0What this workflow does
This AI workflow has 44 nodes and runs when an HTTP POST request hits its webhook URL (plus 3 other triggers). Along the way it connects OpenAI Chat Model.
How it runs
Trigger: When an HTTP POST request hits its webhook URL (plus 3 other triggers).
- Settings (Edit Fields (Set)): sets 10 fields: system_message, max_output_tokens, max_iterations…
- Sweep settings (Edit Fields (Set)): sets 1 field: reservation_ttl_minutes
- Monthly settings (Edit Fields (Set)): sets 3 fields: keep_months, summary_email_to, summary_email_from
- Load clients (Data table): get
- Validate request (Code): runs custom JavaScript code
- Find open reservations (Data table): get
- Load last month's ledger (Data table): get
- Load ledger for period (Data table): get
- Valid request? (If): checks a condition and branches into true / false
- Pick stale reservations (Code): runs custom JavaScript code
…plus 28 more steps. See the full node list below.
Services it uses
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.
Nodes used (12)
- Webhook
n8n-nodes-base.webhook - Edit Fields (Set)
n8n-nodes-base.set - Code
n8n-nodes-base.code - If
n8n-nodes-base.if - Respond to Webhook
n8n-nodes-base.respondToWebhook - Data table
n8n-nodes-base.dataTable - AI Agent
@n8n/n8n-nodes-langchain.agent - OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi - Calculator
@n8n/n8n-nodes-langchain.toolCalculator - n8n
n8n-nodes-base.n8n - Send Email
n8n-nodes-base.emailSend - Schedule Trigger
n8n-nodes-base.scheduleTrigger
From the author
Quick overview For agencies and freelancers who run one AI agent for several paying clients. Each client has a monthly budget, a pause switch and its own instructions in an n8n Data table. A run starts only if the client can afford it, and the tokens used are…