Case study 01, 2026
Flamide
I co-founded Flamide and built the product, now in beta with select education consultancies. Its AI agent handles Instagram, Messenger and WhatsApp enquiries in Nepali, English and Romanized Nepali. It collects student details, updates the CRM and follows up on conversations. Counselors take over when a case needs their judgment.
01
The problem
Consultancies in Nepal run on DMs. Most enquiries come in after hours, in mixed script, and ask the same handful of questions about courses, fees and intakes. The answers need to come from the consultancy's current catalog.
The expensive messages are the other ones. "Will my visa get approved?" "I was refused last year." "Can you lower the fee?" A confident but unsupported answer can change a student's plans. The counselor needs to see these cases with enough context to take over.
I built the workflow around the consultancy's own data and explicit handoff rules. The counselor gets the conversation and the reason it was escalated.
02
How it's built
The agent does more than draft replies. Student details from a conversation are extracted into a validated set of CRM fields. Follow-ups use the conversation history and pass through reply checks before they enter the delivery queue. Sensitive cases carry a reason and summary into the counselor handoff.
The main reply path works like this:
- Inbound checks. Prior refusals, complaints, finance questions and requests for a human can trigger escalation before reply generation.
- Generate. A six-layer prompt: style, guardrails, domain reference, consultancy identity, catalog, then conversation state.
- Outbound checks. Code checks for visa predictions, unsupported numerical requirements and claims attributed to the wrong university.
- Repair. A guardrail failure gets one regeneration with the violation named. Script and provider-format failures have their own bounded recovery paths.
- Escalate. If it still fails, the conversation goes to a human with the reason attached.
Decisions that mattered
-
Workspace isolation is enforced in the database.
Workspace-scoped records use row-level security policies and
composite
(workspace_id, id)foreign keys. The database rejects references across workspaces instead of leaving that check to each screen. - CRM updates have a narrow write path. Extracted fields are validated with Zod and passed to scoped SQL functions with the workspace and source message attached. Internal university fields stay out of prompts through an explicit column allowlist, checked against the schema.
- The prompt keeps a stable prefix. Workspace instructions, domain reference and catalog context precede the changing conversation state. This gives the provider a reusable prefix without assuming that every request will hit its cache.
- Replies wait in a durable queue. Workers claim jobs with a lease and record completion transactionally. Pending replies can be recovered after a restart; external delivery still needs to account for a send succeeding before its completion is recorded.
-
Transport sits behind a channel adapter.
Instagram, Messenger and WhatsApp sit behind
ChannelAdapter. The core workflow stays separate from each platform's payloads and can be exercised through a mock adapter during development.
Staff can query the pipeline too
A separate assistant turns staff questions into validated filters and groupings. Application code applies them to the caller's records and calculates the counts. The model helps interpret the question; it does not invent the result or run arbitrary SQL.
03
What broke, and what I changed
The parts a demo never shows.
Green suite, silent product
The first live call to the model returned nothing. Every reply, every time. In the "careful" effort mode the model spent the whole token budget reasoning and got cut off before writing a character, and the engine quietly logged that as "silent." The mock-provider tests had missed the failure because their responses had no token ceiling.
I sized the ceilings per effort level from measured completions, added a guard that fails loudly on an empty completion, and started treating live runs as a separate gate.
Every fact true, the sentence false
A reply told a student that CQUniversity needs 75% for CBSE students. CQUniversity had no CBSE requirement on file, and 75% belonged to Coventry, in another country. Each piece was real, so an existence check could never catch it.
The guardrail now validates the whole tuple (university, board, value) against the database, and a missing row counts as a violation. That turns "requirement unknown" into an escalation instead of a guess.
The provider answered with 86 spaces
Certain JSON-mode requests came back as pure whitespace with a normal stop reason, deterministically, at temperature 0. I isolated the trigger to the JSON-mode flag with five variations of the captured payload.
The engine now retries that one turn without the flag and parses the result through the same reader. It's documented as a mitigation rather than a fix, because the provider behavior is still unexplained.
04
How I check behavior
Mock-provider tests cover the application's decisions. Database tests check isolation and constrained writes. Browser tests exercise the counselor workflow. These answer different questions, so a green unit suite does not stand in for all of them.
I also use scripted live-model evaluations to inspect replies and guardrail behavior in English, Nepali and Romanized Nepali. They produce conversation reports for review; they are not an automatic guarantee that a model change is safe to ship.
05
Limits, stated plainly
- The product is in beta with select consultancies; the case study describes that stage of deployment.
- The reply checks cover specific failure patterns. They do not catch every unsupported claim, especially requirements stated only in prose.
- The live evaluation runner records outputs for inspection. A passing automated canary for the current model is a separate piece of work.