AWS Builder Center
The Complaint Nobody Files (So I Built an AI That Files It For You)

The Complaint Nobody Files (So I Built an AI That Files It For You)

Built a serverless AI agent on AWS that converts multilingual, free-form citizen complaints (text or voice) into structured, department-routed tickets, using Bedrock for field extraction and a custom multi-turn validation flow. Designed and deployed a fully serverless backend handling the full complaint lifecycle – intake, AI drafting, photo/GPS capture, Slack/email notification, and status tracking end-to-end. Companion admin dashboard with live status management and a geospatial complaint map.

AWS Community Builder | Director @ Skill Nebula Private Limited
There's a pothole near my house that's been there for three weeks. I know exactly which department is supposed to fix it. I have no idea how to actually tell them.
That gap — between knowing something is wrong and successfully reporting it — is where most civic complaints quietly die. Not because people don't care, but because complaint portals are in English, forms ask for department names nobody knows, and writing a "proper" complaint feels like unpaid admin work. So the streetlight stays broken. The garbage stays uncollected. Everyone just works around it, forever.
For AWS's First Commit hackathon, I decided to close that gap with an AI agent instead of another form. This post is less "look what I built" and more "here's what building it actually taught me" — the architecture decisions, the bugs that looked like something else entirely, and the one redesign that mattered more than every feature I added afterward.

What It Does

Nagar Sahayak ("civic helper") lets someone describe a problem the way they'd describe it to a friend — in Hindi, English, or eight other languages, typed or spoken aloud. There's no dropdown asking "select your department." The system asks for whatever's still missing, drafts a formal complaint once it has enough, files it, and notifies the responsible department over Slack and email — with any photos and GPS location attached. The citizen gets a ticket ID and can check its status anytime. A companion admin console lets civic staff triage tickets, mark them acknowledged or resolved, and see everything plotted on a live map.
None of that is the interesting part, though. The interesting part is why it works reliably, because my first version didn't.

The Architecture, and Why Each Piece Is There

The whole thing is serverless, which mattered more for a four-day solo build than I expected going in. Amazon Bedrock (Claude Haiku 4.5) handles language understanding and drafting. AWS Lambda orchestrates every request. DynamoDB holds two tables — one for finalized tickets, one for in-progress conversation state. S3 stores photos via presigned URLs, so images never pass through Lambda at all. SES and a Slack webhook handle department notification. Amplify Hosting serves both the citizen-facing chat and the admin console as plain static files.
The part worth dwelling on is the DynamoDB  sessions  table, because it's doing something that's easy to skip when you're moving fast: it's the only reason a multi-turn conversation can exist at all in a stateless architecture. Each Lambda invocation knows nothing about the previous one — no memory, no persistent process. So every time a citizen sends a follow-up message, the function has to reload what's already known (issue type? location? severity?), merge in whatever the new message adds, and decide whether it's done. That reload-merge-decide loop, backed by a single DynamoDB item per conversation, is the entire mechanism that makes the bot feel like it's "remembering" the conversation. It isn't remembering anything — it's re-deriving the whole state from storage on every single turn.

The Mistake That Taught Me the Most

My first version let the LLM manage that state directly. On every turn, I'd hand Bedrock the conversation so far, ask it "what's still missing, and what should you ask next," and trust its judgment on both the decision and the phrasing.
It worked beautifully for exactly three test messages. Then it started asking for the location twice. Then it forgot it already knew the issue type and asked again. Then, worst of all, it occasionally decided a vague answer was "good enough" and skipped straight to drafting a complaint with almost no real information in it. The lesson generalizes past this one project: an LLM is a poor state machine, even when it's a good reasoner. Every time you ask it to track multi-step progress across turns using nothing but re-read conversation history, you're relying on it to correctly infer state from unstructured text, every single time, with zero margin for a bad inference. That's a much harder ask than it looks.
The fix was to split responsibilities cleanly. Bedrock's only job became narrow and mechanical: given one message, extract whatever structured fields it contains — nothing more.
def extract_fields(latest_message, known_fields):
prompt = f"""Extract structured fields from ONE message. It may be a
full complaint, or just a short follow-up answer.

Message: "{latest_message}"
Already known: {json.dumps(known_fields)}

Extract: issue_type, location, incident_date, condition.
Respond with ONLY valid JSON."""
# ...call Bedrock, return the parsed fields
Deciding what's still missing, and what to ask next, moved entirely into plain, boring, deterministic Python:
missing = [f for f in ["issue_type", "location", "condition"] if not merged.get(f)]
if missing:
next_field = missing[0]
return QUESTION_FOR_FIELD[next_field] # one fixed, specific question
The AI didn't get less capable when I gave it less responsibility — it got more reliable, because I stopped asking it to do the one thing language models are worst at: silently tracking exact state across many turns with no error-correction. Once I made that split, the "asks the same question twice" bug disappeared completely and never came back, across every test I threw at it afterward.

Making "Good Enough" Not Good Enough

The second real problem showed up once I started testing with real, messy input instead of tidy examples: the system would happily file a ticket for "there's an issue in my village" — no actual place name, nothing a department could act on. Technically the citizen "provided a location." Practically, it was useless.
I ended up validating in three layers, and I think all three earned their place:
  1. Prompt-level instruction telling the extraction model that vague self-referential phrases ("my village," "here," "yahan") don't count as a location, even though they reference one existing.
  1. A Python-side blocklist as a backstop, since prompts are guidance, not guarantees — if the model lets a vague phrase through anyway, a plain string check catches it.
  1. A length threshold on typed addresses (unless GPS was shared directly, which is unambiguous by definition) — because even a specific-sounding but short answer like "Rampur" isn't enough for a department to physically locate the problem without more context.
The same pattern applied to incident dates. I originally accepted anything the model returned. Then I actually tried entering "32nd September" during testing — and it went straight through, because I'd never told the model what a valid date looks like, only what a date looks like. The fix wasn't smarter AI prompting; it was almost embarrassingly simple: normalize whatever date phrase the model extracts into ISO format, then let Python's own date parser do the real validation.
try:
parsed = datetime.strptime(date_str, "%Y-%m-%d").date()
except ValueError:
return None, "That doesn't look like a valid date."
 strptime  already rejects impossible calendar dates for free. I didn't need to teach a language model calendar arithmetic; I needed to stop assuming its output was pre-validated just because it came out formatted correctly.

Three Infrastructure Bugs That Taught Me More Than Any Tutorial

Bedrock's model IDs aren't as stable as I assumed. Mid-build, a Claude 3.5 Sonnet version I'd been using returned "this model version has reached end of life" with no warning beforehand. I'd never had to think about model deprecation as an operational concern before — it turns out production AI systems need the same dependency discipline as any other software dependency, pinned versions included.
DynamoDB rejects plain Python floats outright. GPS coordinates from a browser's geolocation API are just floats. The DynamoDB SDK throws immediately on them — you have to wrap every number in  Decimal(str(value))  before writing. It's a one-line fix, but the error message doesn't obviously point you there, so I spent longer confused than the fix actually took.
A crashing Lambda silently breaks CORS. The first time my function threw an unhandled exception, the browser reported a vague network failure with no useful detail. The real cause: API Gateway's default error page for an unhandled 500 doesn't carry CORS headers, so the browser blocks the response before you even see it. The fix was wrapping the entire handler in try/except and explicitly attaching CORS headers to every response path — success and failure alike — which turned a confusing, hard-to-reproduce bug into something that simply couldn't happen again.

What's Still Genuinely Unfinished

The admin console has no authentication yet — anyone with the URL can change a ticket's status, which is fine for a hackathon demo and not fine for anything beyond it. Department routing only covers one city's mapping right now; a real deployment would need per-city, per-ward routing logic. And the AI-drafted complaint text stays in English even when the rest of the interface switches languages, because translating structured AI output well turned out to be a meaningfully harder problem than translating static UI strings — one I didn't have runway left to solve properly this round.

The Actual Takeaway

The interesting engineering problem here was never "can an LLM write a formal paragraph" — that part was almost trivial. It was whether an AI-driven process can be trusted to manage a stateful, multi-step interaction reliably enough that a stranger's real complaint about a real problem doesn't get lost, duplicated, or quietly filed with garbage data inside it. Getting that right meant giving the AI less freedom, not more — using it for narrow, well-scoped extraction and generation, while keeping the actual decision-making in code I could read, test, and trust.
That's a small, unglamorous lesson. It's also the one I'd want to walk into an AWS interview able to defend in detail — because it's the difference between a demo that works once for a video, and a system you'd actually trust with someone's report about a pothole they've been tripping over for three weeks.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article