Recipes पर लौटें

Alibai

Question a live AI suspect out loud, then call guilty or innocent.

TypeScriptउन्नतdigitallysavvy
Two detectives seated across an interrogation table in a dimly lit room, from the Alibai live website.

बनाने की गाइड

इस गाइड में

दस्तावेज़ की भाषा: भाषा नहीं बताई गई

Alibai

Everyone has a story. Not everyone is telling the truth.

Alibai is a voice detective game. You get a fictional case and one suspect, then question a live AI avatar out loud for three minutes. When time's up, you decide whether they're guilty or innocent and back it up with evidence.

Play it at alibai-game.vercel.app. You'll need a Google account and a microphone.

How to play

  1. Read the case. Study the briefing, the suspect and the evidence on file. The clock hasn't started.
  2. Question the suspect. The interview connects on its own, and your three minutes begin once you can see and hear them. Ask whatever you like. Suggested questions are only hints, and tapping one sends nothing.
  3. Watch the notebook. Evidence appears as the suspect gives up facts, and a live transcript runs alongside it.
  4. File your verdict. Pick guilty or innocent and cite the evidence that convinced you. It's final.
  5. See the truth. Find out what happened, what you missed and where you landed on the leaderboard.

A lie doesn't prove guilt, and a clean story doesn't prove innocence. Guilty suspects lie about the crime, and innocent ones can be hiding something embarrassing that has nothing to do with it. The file alone won't settle a case, so you'll have to ask.

ScoringPoints
Correct verdict500
Pivotal evidence cited300
Facts uncovered150
Time left when the interview ended50
Total1,000

Evidence only counts with the right verdict, and a citation that doesn't hold up cancels one that does. Finish without finding a single fact and there's no time bonus.

Why it's built this way

Most AI characters improvise, which makes them impossible to beat fairly: the answer can shift mid-conversation. In Alibai, the case is fixed before you join and the AI only plays the part.

  • The truth is locked. Each case is validated and immutable. Guilt never changes during a game, and the actor playing the suspect has no bearing on it.
  • Answers stay on the server. Private case data lives in tables the browser can't reach, and the browser only receives allowlisted fields.
  • The AI doesn't keep score. Scores are calculated in Postgres from the answer key and verified events. Neither the model nor the browser can award a point.
  • The clock is fair. It's measured on the server and starts only once the suspect's audio and video are playing.

Built with

LayerTools
AppNext.js 16, React 19, TypeScript, Tailwind CSS 4
Data and sign-inSupabase Postgres, Row Level Security, Realtime, Auth with Google
Live interviewAgora Conversational AI with ARES speech-to-text, gpt-4o-mini and MiniMax voices
AvatarsAnam
HostingVercel

Run it locally

You'll need Node 22 or newer, pnpm, the Supabase CLI, and Agora and Anam credentials.

sh
pnpm install --frozen-lockfile
cp env.example .env.local

Create the tables and cases. For a hosted Supabase project:

sh
supabase login
supabase link --project-ref <your-project-ref>
pnpm data:setup

Or run it locally with Docker:

sh
supabase start
pnpm data:setup:local

scripts/data also covers setup without the CLI. Then run pnpm dev.

Fill in .env.local with these values, and keep it out of git:

VariableWhat it's for
APP_ORIGINThe app's exact origin, such as http://localhost:3000
NEXT_PUBLIC_SUPABASE_URLSupabase project URL
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEYSupabase publishable key
SUPABASE_SECRET_KEYSupabase secret key, server only
NEXT_PUBLIC_AGORA_APP_IDAgora app ID
NEXT_AGORA_APP_CERTIFICATEAgora app certificate, server only
ANAM_API_KEYAnam API key, server only

For Google sign-in, follow docs/google-auth.md. Add http://localhost:3000/auth/callback to your Supabase redirect URLs.

Commands

CommandWhat it does
pnpm devStarts the app
pnpm build --webpackBuilds for production
pnpm typecheckChecks types
pnpm lintLints the server, scenario, script, test and API code
pnpm testRuns the unit tests
pnpm test:dbRuns database tests against a disposable local Supabase
pnpm scenarios:validateValidates every case, and checks the set for guilt tells
pnpm data:buildRegenerates the SQL in scripts/data from the migrations and cases
pnpm data:setupApplies migrations and cases to your linked Supabase project
pnpm agents:cleanup:watchStops expired agents, once a minute

Run the cleanup worker alongside any deployment. Agents expire on their own after five minutes, but the worker also clears stuck sessions, and browsers can't be relied on to do it when a tab closes.

Project layout

text
app/                 Pages and API routes
components/game/     Game screens
lib/agora/           Agent start-up, browser media and live transcript
lib/scenarios/       Case schema, validation and generation
lib/scenarios/cases/ One file per case
lib/server/          Server-only auth, game logic, voice and fact sync
supabase/migrations/ Database schema, policies and game logic
scripts/data/        Generated setup SQL and how to use it
scripts/             Case tooling and the cleanup worker
tests/               Unit and database tests

Status

Alibai began as a hackathon project and has sixteen hand-written cases. Each player can play each case once.

Some things to know:

  • A fact only counts when the suspect uses one of its spoken lines. Punctuation, contractions and a lead-in are fine, but a paraphrase earns nothing, so some clues can be missed. This is the biggest known weakness.
  • A guilty suspect's prompt includes what they did, so a determined player could try to coax it out. Innocent suspects aren't told who did it.
  • The first live games are still being tested, so expect rough edges.

More documentation