Selected AI Work

BrokeMe: Multilingual Multi-Agent Job & Service Platform

MSc research · CrewAI multi-agent · Voice AI

MSc Data Science research · Coventry University UK (NIBM) · 2025/26 · Thesis: “A Multi-Agent Multilingual Voice-and-Text Job Posting Platform for Inclusive Digital Recruitment”

A conversational AI platform for Sri Lanka's informal employers and service providers. They talk or text in their own language, and a team of specialised AI agents turns it into a structured, moderated, published listing. No forms, and no English required.

Voice, SMS, WhatsApp and web-chat messages in Sinhala, Tamil and English flow through a six-agent pipeline into validated job and service listings across Sri Lanka
Role
Researcher · AI Engineer · Full-stack
Year
2025 – 26
Focus
MSc research
Stack
11 technologies
  • CrewAI
  • OpenAI GPT-4o-mini
  • FastAPI
  • Twilio Voice number
  • ConversationRelay
  • WebSockets
  • Next.js
  • PostgreSQL + pgvector
  • Redis
  • MCP
  • Railway
  • 0.83

    Extraction F1 (P 0.87 / R 0.80)

  • 433ms

    Real-time search latency

  • 1.00

    Scam-detection recall

  • 92.5%

    Intent routing accuracy (37/40)

  • 95.8%

    Test scenarios passed (23/24)

  • 0

    False positives on clean posts

  • 6

    Specialised CrewAI agents

  • 4

    Channels: voice, SMS, WhatsApp, web

  • 5 → 7

    Repos → Railway services

Client web app & deployment

Screens from the deployed Next.js web app and its Railway project, as submitted in the thesis · tap to enlarge

AI provider onboarding
AI-generated listings
Two ways to search
Nearby providers map
Listing page & trust badges
Icon-first categories
Railway: 7 services

About 70% of employment in Sri Lanka is informal. Small businesses hire through word of mouth, signs, and WhatsApp, because job portals are desktop-first, English-only, and full of forms. 80% of people get online through a smartphone, but computer literacy is only 36.4% and just 19.5% of households own a computer. People also mix languages ("Mama plumber kenek. Kalutara side.") and type Sinhala in Latin letters, which breaks ordinary NLP. And unmoderated posts expose job seekers to scams and discrimination.

The idea is simple: instead of making people learn a form, let them talk, and give the hard work to a team of AI agents. BrokeMe accepts a live phone call, SMS, WhatsApp, or a web chat. It detects the language and what the person wants, asks follow-up questions when details are missing, and builds a structured listing with name, profession, location, skills, experience, availability, price, and contact.

Requests take one of two paths. A customer looking for someone ("Need a delivery driver in Colombo") gets a real-time answer in about 433ms. A provider creating a listing gets an instant confirmation, while the heavy AI work (about 7.6s) runs in the background, so nobody waits on a phone call, which matters for people on prepaid plans.

That background work is a six-agent CrewAI pipeline: validation, enrichment, category classification, moderation, marketing copy, and image prompt. A deterministic orchestrator runs the agents in a fixed order, saves each stage to the database, and stops the moment a stage fails or flags the listing for human review. Agents are never left to decide on their own what happens next.

I followed Design Science Research (Hevner et al., 2004) in eight two-week sprints. The system grew from a single-repo prototype (HireAgent, v1) into five repositories deployed on Railway as seven services. I evaluated it on scenario sets covering clean English, broken Singlish, Tamil-English mixes, Romanized Sinhala, and deliberate scam and discriminatory posts.

System architecture

Five repositories, each with one job. The channels feed one intake gateway, real-time and background work are split by a Redis queue, and the agent pipeline is a separate library the worker installs. Every service layer links to its code.

  • Channels
  • Service
  • Data & infra
  • AI agents
  1. Channels

    How people reach the platform
    • Phone call

      Dial the Twilio number; ConversationRelay streams speech as text over a WebSocket

    • SMS

      Twilio webhook, signature checked

    • WhatsApp

      Twilio webhook, signature checked

    • Web chat

      Free-text box in the Next.js web app

    signed webhooks · WebSocket /realtime/voice/ws
  2. Intake & understanding gateway

    brokeme-intent · FastAPI
    Code
    • Language detection

      Sinhala, Tamil, English, and code-mixed or Romanized input

    • Intent classification

      Provider creating a listing, or customer searching

    • Entity extraction

      Free text to an 8-field JSON schema

    • Voice & clarification

      Turn-by-turn voice sessions; asks for missing fields, state kept in Redis

    normalised event → route decision (internal HTTP)
  3. Core API

    brokeme-api · FastAPI · clean architecture
    Code
    • Real-time search

      Customer requests answered directly, ~433ms

    • Listing intake

      Creates a draft with idempotency protection, then queues it

    • OTP auth

      Phone number + one-time code, no passwords

    • Listings, bookings, reviews

      Public service listings and notifications

    LPUSH service_queue
  4. Queues & sessions

    Redis
    • service_queue

      New listings waiting for the AI pipeline

    • notification_queue

      "Your listing is live" messages

    • social_publish_queue

      Posts to social channels

    • Sessions & OTP

      Conversation state, codes (300s expiry), tokens

    BRPOP · three daemon threads
  5. Background worker

    brokeme-worker
    Code
    • Service worker

      Hands each draft to the agent pipeline

    • Notification worker

      Tells the user the result

    • Publish worker

      Sends the listing to social channels

    imports the pipeline (private package, token-authenticated pip install)
  6. Multi-agent pipeline

    brokeme-agents · CrewAI
    Code
    • ServiceOrchestrator

      Runs the six crews in a fixed order and halts on failure or a review flag

    • Validation → Enrichment → Classification

      Clean the data, add tags, pick one of 45 categories

    • Moderation

      Blocks scams and discriminatory posts before anything is published

    • Content → Image prompt

      Writes the title, ad copy, and social captions, plus a prompt for the cover image

    upsert service_ai_content · store embeddings · queue follow-up events
  7. Data, AI & storage

    Managed services
    • PostgreSQL

      Main database, Alembic migrations, PostGIS for nearby search

    • pgvector memory

      text-embedding-3-small (1,536-d), cosine search for similar past listings

    • OpenAI GPT-4o-mini

      The model behind every agent

    • Cloudflare R2

      S3-compatible storage for images

    published listings
  8. Client web app

    brokeme-webapp · Next.js
    Web app code
    • AI provider onboarding

      Describe your service in your own words

    • Two ways to search

      Keyword browsing, or "describe what you need"

    • Nearby providers map

      Google Maps with distance and arrival time

    • Listing pages

      AI-written listings with trust badges

These are the design diagrams from the thesis, in the order the system was designed: the big picture first, then the internals, the runtime flows, the users, and finally the data. They describe the intended design. In the build, the publishing step became two CrewAI agents (content and image prompt), and enrichment moved ahead of classification so the category agent can use the enriched text.

  1. Fig. 01 · Architecture diagram

    High-level system architecture

    Three different front doors (a phone call, a text message, or a web prompt) each get their own handler, then all of them merge at one Intake Router / Normaliser. After that point there is only one pipeline, so the logic for validation, moderation, and publishing is written once rather than once per channel.

    • Left: each channel has a gateway and an intake handler, e.g. Twilio → Voice Service
    • Middle: the API saves the event to PostgreSQL and pushes a job onto the Redis queue
    • Right: the worker hands the job to the multi-agent orchestrator, and approved posts reach the web job board, the notification service, and the admin dashboard
    • The split at the Redis queue is the key decision: users get a fast reply, and the slow AI work happens afterwards
  2. Fig. 02 · Component diagram

    Component design

    Zooms in on the software modules and their order. Every input goes through the same chain of small, single-purpose components before it reaches the API, which makes each one easy to test and replace.

    • Voice goes through a Conversation Manager; SMS, WhatsApp, and web go through a Channel Router
    • Language Detector → Intent Detector → Phone Normaliser → Structured Extractor turn raw text into clean data
    • The API Service splits into User Service, Job Service, and Queue Publisher
    • The Agent Orchestrator fans out to the individual agents, which all write to PostgreSQL
  3. Fig. 03 · Data flow

    Multi-channel intake & normalisation

    Shows what brokeme-intent does to every message. Whatever comes in (a spoken sentence, a Singlish SMS, or a web prompt) leaves as one standard "normalised intake event" with the same JSON shape, ready to be queued.

    • Each channel needs its own parsing first: voice conversation handling, message parsing, or text input parsing
    • Phone / user normalisation matches the sender to an account, so a WhatsApp number and a caller ID resolve to the same person
    • The normalised event is stored as an intake_event with the channel, raw text, normalised JSON, detected intent, and an idempotency key
  4. Fig. 04 · Agent workflow

    Multi-agent workflow

    The core idea of the research: instead of one large prompt doing everything, a chain of specialised agents each does one job and passes structured output to the next. It isn't a straight line, though. Moderation can branch to a person.

    • Validation: completeness and consistency checks
    • Classification: assigns the job category
    • Moderation: safety and policy review, with "Human Review if needed" as an escape hatch
    • Enrichment: makes the post easier to read; Publishing: produces the final output
    • In the CrewAI build this became six agents run in a fixed order by ServiceOrchestrator (see "AI agents" below)
  5. Fig. 05 · UML sequence diagram

    Voice posting sequence

    The timeline of a phone call. Note where "Confirm capture / end session" sits: the caller hangs up before the worker and agents start. Someone on a prepaid plan never pays for airtime while the AI is thinking.

    • User → Twilio → VoiceService: short, guided questions in the caller's language
    • VoiceService → API: a structured job draft, enqueued in Redis
    • Later, Redis → Worker → Agents: validation, classification, moderation, and enrichment
    • Agents → API → WebPlatform: the approved posting is published
  6. Fig. 06 · UML sequence diagram

    Text posting sequence

    The same pattern for SMS, WhatsApp, and web. The text handler detects language and intent itself, then the API acknowledges straight away, so the user gets a reply even on a weak connection, while the agents finish in the background.

    • From the API onwards, the voice and text flows are identical: that's the point of normalising
    • If details are missing, the handler asks a follow-up question before submitting the draft
  7. Fig. 07 · Flowchart

    End-to-end process flow

    The whole journey from a user's point of view, including the clarification loop. If required data is missing, the system asks for exactly that information and goes back to capture, rather than guessing or rejecting.

    • Decision 1: voice or text? Voice is transcribed first, and both meet at extraction
    • Decision 2: is the data complete? If not, the clarification loop runs (1.2 turns on average in testing, 2.5 for Romanized Sinhala)
    • Decision 3: is the content acceptable? If yes: save, publish to web and social, and confirm. If no: reject and tell the user why
  8. Fig. 08 · UML use case diagram

    Users and what they can do

    Four actors use the platform. Posters submit by voice and add details; seekers search and view; admins review, approve or reject, and manage users; external services receive published posts and send notifications.

    • Job Poster / Service Provider: submit by voice, give extra details, receive confirmation
    • Internal steps triggered automatically: detect language, voice to text, extract, validate, moderate, publish
    • Job Seeker / Customer: search jobs and services, view details
    • Admin: human-in-the-loop moderation for anything the agents flag
  9. Fig. 09 · UML state machine

    Posting lifecycle states

    Every posting is always in exactly one state, stored in the database (processing_stage on the services table). That makes the pipeline auditable (you can see where a post stopped and why) and recoverable after a crash.

    • The happy path: Received → Normalized → DraftCreated → PendingValidation → Validated → Classified → ModerationCheck → Enriched → ReadyToPublish → Published
    • NeedsCorrection sends incomplete drafts back to the user
    • HumanReview can approve a flagged post (on to Enriched) or reject it
  10. Fig. 10 · Entity-relationship diagram

    Database design

    The PostgreSQL schema behind brokeme-api, managed with Alembic migrations. The services table is the hub, and the AI pipeline's work is stored alongside it rather than overwriting what the user said.

    • users with customer_profile and provider_profile; sessions and otp_codes for passwordless login
    • services: description and enriched_description, lat/long, price, plus moderation_status and processing_stage
    • service_ai_content: AI-generated title, tags, marketing text, social caption, and image prompts
    • processing_stages_log and audit_logs record every pipeline step; intake_events keep the raw input and an idempotency_key
    • ai_knowledge holds vector(1536) embeddings for the agents' pgvector memory
    • Marketplace tables: service_slot, slot_reservation, bookings, reviews, review_comment, social_media_publish_log

Six-agent CrewAI pipeline

Each agent has a narrow role, a goal, and a backstory that says what it must never do, and it can't delegate. Temperature is tuned per stage: low for checks, higher for writing. Past listings retrieved from pgvector are fed into the prompts as memory.

  1. 01

    Validation agent

    Stage 1 · temp 0.2

    "Service Data Validation Expert." Trims, normalises, and formats phone numbers, and removes invalid fields. It must never invent missing data.

  2. 02

    Enrichment agent

    Stage 2 · temp 0.3 · memory

    Adds tags, synonyms, and a richer description, using the 5 most similar past listings from pgvector as context.

  3. 03

    Category agent

    Stage 3 · memory

    "Service Category Classification Expert." Matches the listing to a category using its meaning, memory, and the existing categories. Never writes copy or moderates.

  4. 04

    Moderation agent

    Stage 4 · temp 0.1 · memory

    The most deterministic stage. Checks for upfront fees, vague overseas jobs, and discrimination, then approves, flags for human review, or blocks.

  5. 05

    Content agent

    Stage 5 · temp 0.4

    "Service Content and Marketing Copy Expert." Writes the title, social captions, and short marketing text from approved data only. It never invents prices or credentials.

  6. 06

    Image prompt agent

    Stage 6 · temp 0.4

    Writes a prompt for the listing's cover image. Then the outputs are saved, the listing is embedded into memory, and notify and publish jobs are queued.

A phone call, end to end

I set up a dedicated Twilio phone number and built the real-time voice path myself in brokeme-intent: a signed webhook, a TwiML hand-off, and a FastAPI WebSocket that talks to Twilio ConversationRelay. Callers need no app, no data plan, and no reading. The call ends before the heavy AI work starts.

  1. 01

    Caller dials the Twilio number

    Twilio phone number

    Any phone, including a basic feature phone, can call the platform's Twilio number. Twilio answers and sends the call to my backend.

  2. 02

    Signed webhook

    POST /webhooks/twilio/voice/incoming

    FastAPI checks the X-Twilio-Signature with the Twilio SDK, then creates a voice session in Redis that expires after SESSION_TTL_SECONDS.

  3. 03

    TwiML hand-off

    TwiML · ConversationRelay

    The webhook replies with TwiML telling Twilio to connect the call to ConversationRelay at wss://…/realtime/voice/ws (REALTIME_VOICE_WS_URL).

  4. 04

    WebSocket session

    WebSocket /realtime/voice/ws

    ConversationRelay does speech-to-text and text-to-speech. It sends a setup message (callSid, caller number), then prompt messages with the caller's words, e.g. {"type":"prompt","voicePrompt":"I provide plumbing services in Kalutara"}. My server replies with text, which Twilio speaks back.

  5. 05

    Turn loop

    RealtimeVoiceOrchestrator · GPT-4o-mini

    It picks the caller's language, extracts fields from each turn, and asks for what's missing. Short system prompts keep the time to the first token low, so the conversation doesn't stall.

  6. 06

    Finish or escalate

    has_minimum_provider_data()

    Once the minimum fields for the intent are collected, it confirms, ends the call, and closes the socket. If the call goes past the turn limit or the roughly one-minute window, it is flagged for manual review.

  7. 07

    Hand off

    brokeme-api → Redis → agents

    The normalised event is sent to the API, saved as a draft, and pushed onto service_queue. The six-agent pipeline runs after the caller has hung up.

Voice & messaging

The real-time phone channel and the text channels.

Twilio phone number
The platform's dedicated number. People call it or text it with no app installed.
Twilio Voice webhooks
Incoming calls hit a FastAPI endpoint, and every request's X-Twilio-Signature is checked (invalid → 403).
TwiML
The webhook's reply that connects the live call to ConversationRelay.
Twilio ConversationRelay
Real-time speech-to-text and text-to-speech, so callers can speak Sinhala, Tamil, English, or a mix.
WebSockets
A bidirectional /realtime/voice/ws endpoint (FastAPI and the websockets library) streams each turn between Twilio and the voice orchestrator.
Twilio SMS & WhatsApp
Text intake through signed webhooks, routed into the same intake pipeline as voice.
Redis session state
Short-lived voice and chat sessions with a TTL, so a conversation keeps its context between turns.

AI & agents

CrewAI
Six agents, each in its own Crew and Task, run in a fixed order by a deterministic orchestrator.
OpenAI GPT-4o-mini
Language and intent detection, extraction, clarification, and every agent in the pipeline.
text-embedding-3-small
1,536-dimension embeddings of published listings, used as agent memory.
pgvector
Cosine-similarity search (<=>) inside PostgreSQL, with no separate vector database.
MCP (Python SDK)
brokeme-provider-search-mcp exposes safe, read-only provider search tools to AI agents.
Prompt files
Versioned prompts for validation, enrichment, moderation, and the other agents, checked at worker start-up.

Backend

Python 3.12
Every backend service and the agents library.
FastAPI + Uvicorn
Async REST APIs, the Twilio webhooks, and the WebSocket server, with Swagger docs at /docs.
Pydantic & pydantic-settings
Request and response schemas, data contracts between services, and settings that differ per environment.
SQLAlchemy + Alembic
Database access and versioned schema migrations, applied on every deploy.
psycopg2 / asyncpg
PostgreSQL drivers: sync in the API and worker, async in the MCP server.
httpx
Service-to-service calls, e.g. intent gateway → core API.
Twilio Python SDK
Signature validation and messaging.

Data & storage

PostgreSQL
The main database: users, services, bookings, reviews, intake events, and pipeline logs.
PostGIS
Location queries for the nearby-providers map.
Redis
Three job queues (service, notification, social publish), OTP codes, session tokens, and conversation state.
Cloudflare R2 + boto3
S3-compatible storage for listing and profile images.

Client web app

Next.js 15 + React 19
brokeme-webapp: the public marketplace and the AI provider onboarding.
TypeScript
Type-safe front-end code.
Tailwind CSS 4
Styling and an icon-first category UI.
Google Maps
The nearby-providers map with distance and arrival time.

Deployment & testing

Railway
Seven services (api, intent, worker, webapp, the agents build, Postgres, Redis) on private networking.
Nixpacks + railway.toml
Builds, start scripts, health checks, and restart policies defined as code.
GitHub
Five repositories. The agents library installs as a private package via token-authenticated pip, pinned by BROKEME_AGENTS_REF.
pytest
Unit and integration tests, with pytest-asyncio and pytest-httpx in the MCP server.
fakeredis + CrewAI stubs
Queues and LLM agents mocked so tests are deterministic and need no external services.
Local voice tests
curl posts to the voice webhook, and hand-written setup and prompt JSON messages simulate ConversationRelay turns over the WebSocket.

v1 prototype (HireAgent)

Twilio voice → WebSocket relay
The first live conversation agent, which built a job_json from the call.
CrewAI (two crews)
Crew A for validation and safety, Crew B for publishing in Sinhala, Tamil, and English.
Jinja2
A server-rendered public job site and admin review dashboard.
bcrypt + itsdangerous
Admin password hashing and signed session cookies.
  • brokeme-agents

    Python · CrewAI

    The six-agent pipeline, ServiceOrchestrator, prompt files, and pgvector memory. Shipped as a private Python package.

    lahirumanulanka/brokeme-agents
  • brokeme-webapp

    Next.js · client UI

    The public marketplace: AI provider onboarding, two ways to search, nearby providers on a map, and listing pages.

    lahirumanulanka/brokeme-webapp
  • brokeme-intent

    FastAPI · Twilio

    The channel gateway: web chat, SMS, WhatsApp, and real-time voice. Handles language, intent, and extraction before passing normalised events to the API.

    lahirumanulanka/brokeme-intent
  • brokeme-api

    FastAPI · Postgres

    The core REST API: OTP auth, providers, listings, bookings, reviews, and the AI intake endpoint, with Alembic migrations and Swagger docs.

    lahirumanulanka/brokeme-api
  • brokeme-worker

    Python · Redis

    Three daemon threads work through the service, notification, and publish queues, calling the agents library for each draft.

    lahirumanulanka/brokeme-worker
  • brokeme-provider-search-mcp

    MCP server

    A Model Context Protocol server that gives AI agents safe, read-only tools: search providers, get provider details, and check open slots.

    lahirumanulanka/brokeme-provider-search-mcp
  • multiagent-voice-job-platform

    v1 prototype

    The original single-repo HireAgent prototype: a live voice agent plus a validation and safety crew and a publishing crew, with Sinhala and Tamil versions of each post.

    lahirumanulanka/multiagent-voice-job-platform

Extraction F1 by language

Higher is better. Code-mixed and Romanized input is the hardest. 30 scenarios.

  • Standard English0.93
  • Partial English0.83
  • Tamil-English0.75
  • Code-mix Singlish0.74
  • Romanized Sinhala0.66

Speech recognition word error rate

Lower is better. Controlled 16kHz audio, 19.1% overall.

  • Clear English7.2%
  • Sinhala21.4%
  • Singlish mix28.6%

Real-time search latency

433ms mean end to end, under the 500ms target for a conversation to feel responsive.

  • Entity extraction~210ms
  • Intent classification~185ms
  • Database lookup~38ms

Moderation recall

15 test posts. Zero false positives on the 5 clean posts.

  • Scam-risk posts5/5
  • Discriminatory posts4/5
  • One agent per job. Each CrewAI agent has a role, a goal, and a backstory that lists what it must never do ("never generates descriptions, never moderates content"), and allow_delegation is off. Narrow agents avoid the instruction dilution a single big prompt suffers on messy code-mixed input.
  • Deterministic orchestration. ServiceOrchestrator runs each crew through _run_stage(), writes the current stage to the database, parses the output, and decides whether to continue or stop. The order is fixed in code; the LLM never picks it.
  • Strict JSON between agents. A defensive parser strips markdown fences and rejects anything that isn't a JSON object, so one chatty response can't corrupt the stages after it.
  • Retrieval-augmented memory. Published listings are embedded with text-embedding-3-small and stored in Postgres with pgvector. Enrichment, classification, and moderation pull the most similar past listings through the <=> cosine operator, with no separate vector database.
  • Two speeds. A small, fast agent setup serves real-time search, and the full six-agent pipeline runs only on the background path.
  • Testable without an LLM. pytest stubs CrewAI's Crew, Agent, Task, and LLM classes and the pgvector extension, and fakeredis replaces Redis, so the orchestration logic runs deterministically in CI.
  • Versioned agents. The pipeline is a private package that the worker installs at deploy time with a token-authenticated pip URL. BROKEME_AGENTS_REF pins a branch or release without changing the worker's code.
  • Find out what informal, mobile-first, multilingual employers in Sri Lanka actually need, and why forms and English-only portals exclude them
  • Design a multi-agent, multichannel architecture: voice and text intake, language identification, extraction, clarification, safety and policy checks, content generation, and publishing
  • Build and evaluate it on speech recognition WER, extraction precision, recall, and F1, intent accuracy, moderation recall and false positives, latency, and functional pass rate
  • Every SMS, WhatsApp, and voice webhook checks the X-Twilio-Signature header, and spoofed requests get a 403
  • Passwordless OTP login: codes live in Redis with a 300-second expiry and are deleted once used
  • Idempotency keys stop retried requests from creating duplicate drafts
  • Moderation sits before publishing, and uncertain cases go to human review instead of being auto-approved
  • All secrets (database, Redis, OpenAI, Twilio, R2, GitHub token) live only in Railway environment variables, with separate development and production settings
  • 01Evidence that a multi-agent conversational design lowers the barrier for low-literacy, informal employers compared with form-based portals
  • 02Controlled speech recognition and extraction benchmarks for Sinhala, Singlish, Tamil-English, and Romanized Sinhala input
  • 03An architecture pattern that separates real-time search from background agent processing, so LLM latency never blocks a user
  • 04A governed agent workflow (explicit states, deterministic order, human review) for using LLMs responsibly with vulnerable users
  • Voice was tested through WebSocket simulation and 16kHz recordings, not live calls on Sri Lankan mobile networks, where WER would likely rise by 8–15 points
  • Agent tests used mocked LLM outputs, so they confirm the architecture rather than the quality of live outputs
  • Romanized Sinhala is the weakest input (F1 0.66), and implicit bias such as "recent graduate preferred" is harder to catch than explicit discrimination
  • Notification and social publishing queues are built, but their external integrations were still stubbed at submission
  • Next: a field usability study (SUS) with Sri Lankan SME owners, token streaming for faster voice replies, worker autoscaling on queue depth, distributed tracing, and fine-tuning on local-language data