WhatsApp AI Assessment Platform
WhatsApp-based AI assessment flow for applicants with an HR dashboard to create roles, questions, and see submissions — powered by Twilio (WhatsApp), Node.js, MongoDB, and Groq.
Quick Start
-
Requirements
- Node.js 18+
- Twilio account with WhatsApp Sandbox or WABA number
- Groq API key (https://console.groq.com)
- MongoDB (Atlas recommended) — set
MONGODB_URI
-
Setup
- Fill
.envwith at least:TWILIO_SID,TWILIO_AUTH_TOKEN,TWILIO_WHATSAPP_FROM,GROQ_API_KEY, andMONGODB_URI - Install deps:
npm install - Start server:
npm start(default port 3000)
- Fill
-
Admin Dashboard
- Open http://localhost:3000/admin
- Jobs List page: shows all jobs; click a job to open details
- Job Details page has two tabs:
- Job Details: edit job info, questions, candidate recipients; Save updates MongoDB
- When creating a job, all candidate recipients receive the welcome message automatically
- When adding new candidate numbers later, only new numbers receive the welcome message
- Submissions: read-only list of applicant submissions with AI results
- Job Details: edit job info, questions, candidate recipients; Save updates MongoDB
-
Twilio Webhook
- Expose server (e.g.,
ngrok http 3000) - In Twilio WhatsApp Sandbox, set WHEN A MESSAGE COMES IN to:
https://<your-host>/webhook - The system proactively sends a welcome message to candidate recipients upon job creation (and to newly added numbers on update)
- Applicants can also send: "ابدأ عزّام" (or "start") to begin; bot asks questions one by one
- Expose server (e.g.,
Data Model
-
Job (MongoDB collection
jobs)- jobId, title, description, responsibilities, requirements, skills, benefits
- questions: [String]
- candidateRecipients: [String] (candidates to receive welcome/start prompt)
- createdAt
-
Submission (MongoDB collection
submissions)- applicantPhone, jobId, answers: [{ question, answer }]
- aiScore, aiStrengths, aiWeaknesses, aiDecision, aiSummary
- createdAt
AI Evaluation
- Uses Groq’s OpenAI-compatible Chat Completions API:
https://api.groq.com/openai/v1/chat/completions - Default model:
llama-3.1-8b-instant(override with envGROQ_MODEL) - Prompt returns strict JSON with: score, strengths, weaknesses, decision, summary
- Candidates receive only a final thank-you message; AI evaluation appears only in the dashboard (never sent on WhatsApp)
Railway Deployment (Backend)
- Create a Railway project and deploy this repo.
- Set environment variables (Service → Variables):
TWILIO_SID,TWILIO_AUTH_TOKEN,TWILIO_WHATSAPP_FROMGROQ_API_KEY, optionalGROQ_MODELMONGODB_URI(use MongoDB Atlas connection string), optionalMONGODB_DB
- After deploy, set Twilio webhook to
https://<railway-url>/webhook
Notes
- Webhook deduplication handled via Twilio
MessageSidstored on session documents. - First answer per question is stored; subsequent messages do not overwrite.
- Admin UI is a lightweight React app served from
/admin(no build step).
Project Structure
-
server.js- Express app bootstrapping,
.envloading - MongoDB connection + models
JobSchema(jobId, language, title, description, responsibilities, requirements, skills, benefits, questions[], candidateRecipients[])SessionSchema(applicantPhone, jobId, currentIndex, answers[], processedMessageSids[], started/completed)SubmissionSchema(applicantPhone, jobId, answers[], aiScore, aiStrengths[], aiWeaknesses[], aiDecision, aiSummary)
- WhatsApp/Twilio webhook:
POST /webhook- Starts sessions, asks questions, handles conversational replies
- Sends localized welcome, question prompts, final message
- Admin REST API
POST /api/jobs(create with title + language)PUT /api/jobs/:jobId(edit details/questions/candidates)GET /api/jobs(list)GET /api/jobs/:jobId(get)GET /api/jobs/:jobId/submissions(list submissions)GET /api/submissions/:id(get one)
- AI integration (Groq)
converseOnAnswer()conversational handleranalyzeCandidate()evaluation after last question
- i18n helpers for WhatsApp/server messages
- Loads
locales/en.json,locales/ar.json t(lang, key, vars)andwhatsapp.*keys usage
- Loads
- Static + config endpoints
GET /__app_config.json(brand icon/name)app.use('/locales', express.static('locales'))app.use(express.static('public'))
- Express app bootstrapping,
-
public/admin.html— Single-file React Admin panel- Jobs List (cards with language, questions, candidates)
- Create Job modal (title + language)
- Job Details tab (edit fields, questions, candidates)
- Submissions tab (answers + AI summary)
- Header language toggle (ar/en), RTL/LTR support, skeleton loader
- Frontend i18n loader for
admin.*keys
images/brand-icon.png(optional brand image; auto-detected)
-
locales/en.json— English strings:whatsapp.*,admin.*,submission.*ar.json— Arabic strings:whatsapp.*,admin.*,submission.*
-
.envTWILIO_SID,TWILIO_AUTH_TOKEN,TWILIO_WHATSAPP_FROMGROQ_API_KEY,GROQ_MODELMONGODB_URI,MONGODB_DB,PORT
-
package.json- Scripts:
npm start - Deps:
express,mongoose,twilio,axios,dotenv,body-parser
- Scripts:
Search Cheatsheet (quick entry points)
- WhatsApp flow: search
app.post('/webhook'inserver.js - Conversational AI prompt/logic:
function converseOnAnswerinserver.js - AI evaluation:
function analyzeCandidateinserver.js - Job APIs: search
/api/jobsroutes inserver.js - Submissions API: search
/api/jobs/:jobId/submissionsinserver.js - Admin UI:
public/admin.html(Jobs List, CreateJobModal, JobDetailsTab, JobSubmissionsTab) - i18n strings (Admin/WhatsApp):
locales/en.json,locales/ar.json - Branding:
GET /__app_config.json,public/images/brand-icon.png