Skip to content

Upgrade Chatbot Scope via Gemini API . #70

@singh-odyssey

Description

@singh-odyssey

Problem

Current chatbot (src/components/help-chatbot.tsx) only has 4 hardcoded Q&A responses. Users can't ask natural questions about platform features (ticket uploads, matching, dashboard).

Proposal

Add AI chatbot using Google Gemini 1.5 Flash (free tier)

Setup

npm install @google/generative-ai

Get free API key: https://aistudio.google.com/app/apikey
(use your for testing purpose , later I'll update it )

# .env.local
GEMINI_API_KEY=your_key_here

Implementation

1. API Route (src/app/api/chat/route.ts)

  • Validate input: type check, max 500 chars
  • System prompt restricts to platform topics only
  • Return { reply: string } or { error: string }
  • No secrets/stack traces in responses

2. Update Component (src/components/help-chatbot.tsx)

  • Replace hardcoded Q&A with API calls
  • Message history state
  • Loading states, auto-scroll
  • ARIA labels, keyboard support

3. Security

  • API key only in .env.local (in .gitignore)
  • Input validation on client + server
  • Sanitize errors

Acceptance Criteria

  • Answers platform questions (tickets, matching, dashboard)
  • Redirects off-topic questions
  • No secrets committed
  • Input validated (≤500 chars)
  • Accessible (ARIA, keyboard nav)
  • No TypeScript/ESLint errors
  • Works locally with PostgreSQL

Gemini chosen: Free, simple setup, good enough quality ✅

Metadata

Metadata

Assignees

Labels

ECWoC26bugSomething isn't workingenhancementNew feature or request

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions