Auto-Inject: How to Connect Your APIs Directly to the Chat Widget
Citai Team
March 28, 2026 · 8 min read
The problem: real-time user data
Imagine this scenario: a customer opens your chat widget and enters their account code. They want to know their balance, order status, or when their next invoice is due. Your KB has all the procedure and policy documentation, but doesn’t have THAT customer’s specific data.
Until now, tools (Tool Calling) relied on the LLM to “decide” when to call the API. This works fine for optional data like weather, but for mandatory customer data, you need something more reliable.
Two trigger modes
Citai now offers two modes for each tool:
Mode A: LLM decides
The AI model analyzes the user’s question and decides whether it needs to call the external API. It’s flexible but probabilistic (~85% accuracy).
Ideal for: optional tools like weather, exchange rates, news.
Mode B: Auto-Inject
The tool runs automatically with widget intake filter data. No LLM dependency. 100% deterministic.
Ideal for: CRM, ERP, ticketing — any system where you need user data from the first message.
How the flow works
Widget opens
↓
Intake filter: "Enter your customer code" → ABC-7842
↓
User asks: "What's my balance?"
↓
Auto-Inject: calls CRM API with code=ABC-7842
↓
API returns: { name: "Maria", plan: "Pro", balance: "$1,250" }
↓
LLM responds with KB (policies) + real customer data
↓
"Maria, your current balance is $1,250 on the Pro plan.
Your next invoice is due April 15th."
Step-by-step guide
Step 1: Configure the intake filter
- Go to Settings > API Keys
- Edit your widget API key
- In Intake Filters, add a field:
- Key:
customer_code - Question: “Enter your customer code”
- Type: text
- Required: yes
- Key:
Step 2: Create the tool with Auto-Inject
- Go to Tools > New Tool
- Configure your API endpoint (URL, method, auth)
- Add the
codeparameter (string, required) - Under Trigger mode, select “Auto-inject from filters”
- Under Frequency, choose:
- First message: for static data (profile, plan)
- Every message: for dynamic data (real-time balance)
- In the mapping, connect:
code→customer_code
Step 3: Test
- Open the widget on your website
- Complete the intake with a test code
- Send any message
- You’ll see “Loading your data…” before the response
Use cases by industry
| Industry | Intake | API | Data |
|---|---|---|---|
| Telecom | Phone number | CRM | Balance, plan, invoices |
| E-commerce | Order number | Logistics | Shipping status, tracking |
| Fintech | Account number | Core banking | Balance, transactions |
| Healthcare | Patient ID | HIS | Appointments, history |
| Support | Ticket ID | Helpdesk | Status, assignee |
Combining both modes
A single tenant can have tools in both modes. For example:
lookup_customer→ Auto-Inject (always runs with the code)weather→ LLM decides (only when the user asks about weather)
Auto-Inject tools are automatically excluded from LLM function calling to avoid double calls.
Fault tolerance
If the external API fails (timeout, HTTP error), the agent continues responding using only the KB. The error is logged but not shown to the end user. The flow never blocks.
Connect your APIs instantly. Try Citai →
Try Citai for free
Create your intelligent knowledge base in minutes. No credit card required.
Create free accountRelated articles
Embeddable Chat Widget: From Zero to Production in 5 Minutes
Install an AI assistant on your website with one line of code. Shadow DOM, SSE streaming, themes, pre-chat forms, and smart escalation.
Read article → ProductSmart Escalation: When AI Should Hand Off to a Human
How to configure confidence-based, manual, and schedule-based escalation. Webhooks with full context to Slack, email, or Zendesk.
Read article → ProductAutomatic Language Detection in AI Assistants
How Citai detects the user's language and responds in their language. Heuristics, multilingual embeddings, and content rules.
Read article →