CIRI · Chargeback agent

n8n and the API
who asks what of whom

Every reasoning step is a visible node in n8n, and every piece of data that reasoning needs is a named call to the API. n8n decides the order; the API executes and is the only thing that touches the outside world — the database, the vector store, the model. That is why an investigation can be audited by reading the canvas.

Exact value from SQLite Semantic search (RAG) Model call Business rule, no model Someone calling the n8n webhook
01Entry and cache If the case was already investigated, it ends here
Wake the APIWebhook — Entry
01
GET /health
Render sleeps after 15′
Check Cache
02
GET /api/cache/lookup
SQLite
Cache hit? If a stored report exists, the canvas formats it and answers. Nothing else is called.
02Gather the context Seven calls, always the same ones, always in this order
Get Transaction
03
GET /api/transactions/{id}
SQLite
Get Logs
04
GET /api/logs/{tx_id}
SQLite
Search Policies
05
GET /api/policies/search
QdrantVoyage
Search Similar Cases
06
GET /api/cases/similar
QdrantVoyage
Merchant Risk
07
GET /api/merchants/{name}/risk
SQLite
Customer History
08
GET /api/clients/{id}/history
SQLite
Check SLA
09
POST /api/sla/check
business days
Compile Context The canvas merges the seven answers into a single payload. No business rules: it only assembles.
03Resolve and audit The only part that costs money
Synthesize Resolution
10
POST /api/analyze/resolve
HaikuSonnet
Quality Judge
11
POST /api/analyze/judge
Sonnet
Check Guardrails The API has already checked the answer against the verdicts —an APPROVE with an active BLOCKER gets flagged—; the canvas only surfaces it so it shows up in the run.
04Report and close What stops is the case with an unresolved policy violation, not the most severe one
Switch — Routing It asks first for requires_hitl and only then for the risk level. The order matters: a MEDIUM with a violated policy needs an analyst, and a BLOCKER —which is more severe— does not, because the decision is already made.
Notify — HITL Formonly if a person is needed
12
POST /api/alerts/
SQLite
Respond — Approval Required A 303 to the Wait node's form. Its URL is generated at run time and n8n only exposes it before reaching the node: that is why the notification and the response come first. No server can open a window on someone else's machine, so the link goes out through the four channels where somebody might be watching: a browser follows the 303, the stored body carries a meta refresh for whoever used curl, the panel navigates its iframe, and the hitl_form_ready alert waits for the analyst, who is not the person who triggered the case.
Normalize HITL Decisiononly if it had to wait for a person
13
POST /api/hitl/decide
no store
Generate Report
14
POST /api/reports/html
Jinja2SQLite
Record HITL Feedbackonly if an analyst was involved
15
POST /api/feedback
SQLiteQdrant
Respond — Report The HTML report returns through the same webhook the case came in by. And every error ending has its own —400, 404, 502, 503—: no path answers an empty 200.

And the other way round

Twice the conversation runs backwards: something calls the n8n webhook instead of the API. Those are the other two ways a case can come in.

The web panelPOST /api/panel/analyze
↩
POST /webhook/chargeback-agent
paste your n8n URL
The formseparate workflow, with its own Form Trigger
↩
POST /webhook/chargeback-agent
runs the same 36 steps

No threshold lives in the canvas

SLA windows, chargeback ratios and repeat-offender rules are asked of the API, which reads them from domain/constants.py. n8n does not know how much counts as “a lot”.

There is no agent node

No model picks which tool to call. The fifteen calls are written in advance and always in this order. Which ones run depends on the case: with a cached report only two do, and the three in the HITL stretch only when a person is needed. That is what makes an investigation reproducible.

The full circuit

This diagram shows the conversation. The node-by-node walkthrough, with its branches and error exits, is in n8n_workflow_analysis_en.html.