Retry LLM calls with OpenAI and Anthropic and log costs in Data Tables
Ready for 3.0What this workflow does
This AI workflow has 16 nodes and runs when a chat message arrives (plus 1 other trigger). Along the way it connects Telegram.
How it runs
Trigger: When a chat message arrives (plus 1 other trigger).
- Set Reliability Settings (Edit Fields (Set)): sets 18 fields: prompt, systemPrompt, primaryProvider…
- Prepare LLM Request (Code): runs custom JavaScript code
- Route by Provider (If): checks a condition and branches into true / false
- Post to OpenAI API (HTTP Request): calls an HTTP API (POST)
- Post to Anthropic API (HTTP Request): calls an HTTP API (POST)
- Analyze API Response (Code): runs custom JavaScript code
- Route by Response Status (Switch): routes items into 4 branches
- Compile Final Result (Code): runs custom JavaScript code
- Wait: pauses before continuing
- Check Log Table Exists (Data table): create (table)
…plus 4 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 (10)
- Chat Trigger
@n8n/n8n-nodes-langchain.chatTrigger - Execute Workflow Trigger
n8n-nodes-base.executeWorkflowTrigger - Edit Fields (Set)
n8n-nodes-base.set - Code
n8n-nodes-base.code - If
n8n-nodes-base.if - HTTP Request
n8n-nodes-base.httpRequest - Switch
n8n-nodes-base.switch - Wait
n8n-nodes-base.wait - Data table
n8n-nodes-base.dataTable - Telegram
n8n-nodes-base.telegram
From the author
Quick overview This workflow accepts a prompt from n8n Chat or another workflow, calls OpenAI with automatic retries, falls back to Anthropic on hard failures, logs each run to an n8n Data Table with token and cost estimates, and sends a Telegram alert if all…