This is the starter repository for Challenge 1.12. The structure is set up. Your job is to fill the gaps.
| File | Status | What it does |
|---|---|---|
| backend/server.js | Express server. /chat route is empty. Fill it. | |
| frontend/index.html | ✅ Ready | Chat UI. Input, send button, display area all wired. |
| frontend/script.js | sendMessage() exists. Fetch call is missing. Add it. | |
| frontend/style.css | ✅ Ready | Dark chat UI. No changes needed. |
| backend/.env.example | ✅ Ready | Copy to .env and add your keys. |
Copy .env.example to .env inside the backend/ folder:
cp backend/.env.example backend/.envAdd your OpenRouter key. Get one at openrouter.ai (free credits included).
Open backend/server.js. Find the TODO comment. Implement the AI API call there.
Open frontend/script.js. Find the TODO comment inside sendMessage(). Wire it to your backend.
The messages array is already declared. Make sure you send the full array to the backend every time — not just the latest message. This is what makes the chatbot remember context.
cd backend
npm install
npm startOpen frontend/index.html in your browser (or use VS Code Live Server).
User → Frontend (index.html) → Your Backend (/chat) → OpenRouter API
↑
API key lives here
Never in the frontend
OpenRouter (primary): openrouter.ai → API Keys → Create Key
Gemini (fallback, free): aistudio.google.com → Get API Key
Backend: Render (render.com) — New Web Service → Connect repo → Build: cd backend && npm install → Start: cd backend && npm start → Add env vars in dashboard
Frontend: Netlify — Deploy manually → drag the frontend/ folder
Frontend URL:
Backend URL:
- GitHub PR link (branch:
feature/ai-chatbot) - Google Drive video link (Anyone with link can view)
Updated chatbot implementation