A Dribba case with CityXerpa: a customer-service agent that takes tickets from chat, email and Freshdesk, identifies the customer against BigQuery and writes the reply citing its sources. The model never writes SQL, the agent replies to the customer directly, and fixed rules hand the delicate cases to a person: refunds, VIP customers or complaints.
It is in production, connected to CityXerpa's Freshdesk and BigQuery. Here is how it is built, what the code decides and what the model decides.
Respuesta directa
In production at CityXerpa (Andorra's SuperApp): a customer-service agent built as an 8-step TypeScript pipeline with Claude (Anthropic) over chat, email and Freshdesk. It identifies the customer against BigQuery using closed queries (the model never writes SQL), answers with cited sources from a hybrid RAG in pgvector, and a rule-based judge decides escalation. It replies to the customer directly; delicate cases and compensations go to a person.
8 steps
Fixed pipeline; only the drafting step uses tools
0 SQL
Written by the model: it fills parameters of closed queries
€100
Refunds above this always go to a person
4 languages
Catalan by default; Spanish, English or French to match the customer
The actual problem
At CityXerpa, almost everything a customer asks is answered by their own data: where their order is, what they were charged, what happened with a delivery. That data lives in BigQuery, and the support knowledge (opening hours, delivery areas, billing, style guide) lives in documents. To answer well you need to know who is asking before looking at anything.
The usual trap is to build a generic RAG over the documentation and find out later that the answer was in that customer's order history, which no PDF contains. The opposite trap is letting the model write free-form SQL against the warehouse.
What we did: code identifies the customer and pins their ID; the model can only pick from predefined queries and fill in their parameters. Documentation goes through a hybrid RAG that cites its source. And before anything leaves, a judge with fixed rules decides whether the reply is sent or handed to a person.
Stack
A Next.js console that orchestrates the steps, Claude to read and write, and BigQuery plus Postgres with pgvector as sources. Every step is logged and the console shows it live.
Orchestration
Console and pipeline in Next.js and TypeScript on Node, with Postgres and pgvector. Eight fixed steps: Intake, Identity, Profile, Router, Responder, Judge, Output and Memory. Each step writes its trace and the console streams it over SSE. If a step fails, the ticket is retried with growing back-off and, if it keeps failing, it goes to the human queue with the reason.
When to scale: A fixed-step workflow goes further than people expect. When volume calls for it, the next move is splitting channel intake and the pipeline into queue-backed workers, without touching the steps.
Reading, drafting and tool use
Haiku on the fast steps (Intake, Router, Judge and support for Identity) and Sonnet on the Responder, the only step that calls tools. Steps that return JSON use structured output validated with Zod. Customer text always enters delimited as data, so it cannot smuggle in instructions.
When to scale: The model for each step can be changed from the console, with cost per ticket in view. Opus is kept for cases that genuinely need long reasoning.
Data
BigQuery to identify the customer and read their orders, order lines and incidents, always through fixed parameterised queries with a cap on billed bytes. Postgres with pgvector for the knowledge base: hybrid search (vector plus full text) whose answers cite the source document.
When to scale: A new question that no query covers gets a new query, reviewed and tested in code. The model still does not write SQL.
Real case
CityXerpa is Andorra's SuperApp, with more than 120,000 active users. The agent, in production, handles support questions about orders, deliveries, accounts and billing, connected to their Freshdesk and BigQuery. This page gives no outcome figures: they are the client's data.
Identity
Verified
The customer is identified against BigQuery and Freshdesk. Two identities are only merged on a strong identifier that matches exactly (email, phone, customer ID or order ID). Without one, the profile stays provisional and receives no personal data.
Reply
With sources
The Responder looks up the customer's orders through closed queries, searches the knowledge base and writes in Catalan or in the customer's language, citing the documents it used.
Escalation
Fixed rules
Low confidence, a refund over €100, a VIP customer with an incident, a legal complaint, a request to talk to a person… The judge applies these rules in code, and the model can only make the decision stricter, never softer.
How it works
Next steps
What we would do next, in order. Each item says what changes and the effort we estimate.
Each frequent question that escalates today for lack of data becomes a new parameterised BigQuery query, reviewed and tested. The catalogue grows and the model still writes no queries.
Estimated effort: 1–3 days per query
The style guide, rules and per-step instructions repeat on every call. With prompt caching, that part is billed at a fraction of the price within the cache window.
Estimated effort: 1–2 days
The agent already has a scripted set of cases and compares against the team's real replies on anonymised tickets. The next step is running it with Claude on every change and blocking the deploy if results get worse.
Estimated effort: 1 week
In the chat, token streaming from Anthropic to the widget over Server-Sent Events. An AbortController carries a closed browser tab all the way to the model call and cuts it. If data has to be looked up first, clear microcopy (“Checking your order…”) instead of a silent spinner.
Estimated effort: 1 week
Each ticket's trace already lives in the database. Exporting it as OpenTelemetry spans (one per step, per Claude call and per BigQuery query, with tokens and bytes scanned) lets you see it in Cloud Trace, Datadog or Grafana next to your other systems.
Estimated effort: 1 week
Split channel intake from the pipeline: tickets go into a queue (Pub/Sub, or a Postgres table with SKIP LOCKED) and Node workers process them with bounded concurrency. The console stays responsive even when a flood of emails arrives.
Estimated effort: 1–2 weeks
Other use cases
If your company has data in BigQuery (or Snowflake, Redshift, ClickHouse) and a team that loses hours pulling answers by hand, this pattern applies.
Non-technical staff ask in natural language and the agent answers from a catalogue of reviewed queries, with the result and the chart. Repetitive questions stop landing on the data team.
Agents that combine business rules with competitor data and historical demand in BigQuery to suggest prices, with a person validating before anything is published.
The agent cross-references warehouse signals, contextualises the suspicion and proposes opening or closing the case with a readable rationale. Cuts noise in risk teams.
Weekly or monthly summaries combining structured data (KPIs in BigQuery) with LLM-generated narrative. Each figure is backed by the query that produced it.
Agent over the HR and operations knowledge base. Employee onboarding, questions about leave, expenses or internal policy without flooding the helpdesk.
The agent compares records across systems, identifies discrepancies and proposes resolutions. For finance, ops and compliance.
Technical FAQ
Partly. The knowledge base (opening hours, delivery areas, billing, style guide) goes through a hybrid RAG in pgvector that combines vector and full-text search and cites its source. Customer data comes from BigQuery through tools with predefined queries. Two different sources for two different kinds of question.
Because “where is my order?” is answered by a row in a table, and searching for a similar paragraph does nothing for it. Vectorising BigQuery would add complexity with no benefit. Where there is real text (the support documentation), pgvector in the console's own Postgres avoids running yet another database.
Because of how it uses tools: it fills in the parameters it is asked for and rarely invents one that does not exist, which is exactly what a closed-query design needs. Haiku covers the fast steps at low cost and Sonnet the drafting step. The model for each step can be changed from the console, so trying another provider on one step does not mean rebuilding anything.
Because in customer service, being able to explain every decision matters more than flexibility. With fixed steps, every ticket leaves a readable trace: what the model understood, who it identified, what it looked up, which rules fired and why it was or was not escalated. Only the reply step iterates with tools, and it does so within a closed set.
Yes, except for the delicate cases. The agent posts the reply directly on the customer's channel, and whatever the judge's rules flag (low confidence, refunds over €100, VIP customers with an incident, legal complaints) goes to a person. Monetary compensation always needs a supervisor's approval. The model can make the judge's decision stricter, never softer. No design guarantees a model is never wrong, but this one narrows where it can be: customer data comes from fixed queries, documentation is cited and, if no source clears the confidence bar, a rule escalates the ticket.
With the right model on each step (Haiku to classify and judge, Sonnet only to write the reply), with a judge that only asks the model when the rules have not already decided, and with BigQuery queries capped on billed bytes. The console shows cost per step and per ticket, and Anthropic prompt caching is one of the next steps.
Yes, with caveats. The pipeline and its Postgres deploy on the customer's infrastructure (Cloud Run or GKE with VPC Service Controls, or their own servers), and BigQuery supports VPC Service Controls too. For Claude, Anthropic offers the model via AWS Bedrock or Google Vertex AI, both with private connectivity, so data never leaves your cloud. Under full restriction (banking, defence) a self-hosted LLM can be used instead, accepting that quality drops a notch.
For a focused agent over a bounded domain (one ticket type, one set of BigQuery tables), 4 to 8 weeks with two senior engineers. The bottleneck is never the code — it is scoping correctly, getting access to the data, and building the eval dataset with real queries. ROI is unclear in month one; from month two onwards it is usually obvious.
A well-scoped agent with BigQuery + Claude + a TypeScript pipeline and a bounded domain starts at €35,000–50,000 in development. With an added vector layer, legacy-system integrations or a mature eval pipeline, it climbs to €60,000–90,000. Monthly support and evolution from €3,500/month depending on volume and SLA.
Got data in BigQuery and a similar case?
Tell us the case, show us the schema and we will tell you whether an agent makes sense, what stack fits and what it costs at your real volume. If it does not fit, you will know on the same call.
100% senior in-house team in Barcelona and Andorra · Reply within 1 h