[FEATURE]: ChatBot implementation #165
Open
Riya-chandra wants to merge 1 commit intoKushika-Agarwal:mainfrom
Open
[FEATURE]: ChatBot implementation #165Riya-chandra wants to merge 1 commit intoKushika-Agarwal:mainfrom
Riya-chandra wants to merge 1 commit intoKushika-Agarwal:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request: Gemini API Integration (Frontend + Backend)
Description
This PR integrates Gemini AI API into both the backend and frontend of the project.
It allows chatbot-like interactions through Gemini’s service with proper request handling, secure API key usage, and frontend components for a smooth user experience.
Issue no. #118
Changes Implemented
Backend
Created services/geminiAi.js for handling API communication with Gemini.
Added a new route:
POST /api/chatai → Accepts user messages, sends them to Gemini API, and returns AI response.
Implemented error handling to gracefully manage missing/invalid inputs.
Frontend
Added chatbot UI with input + output rendering.
Connected frontend to backend route /api/chatai.
Implemented loading state + error messages for better UX.
Styled using Tailwind + popup hint for chatbot icon.
Setup Instructions
Add a .env file in the root directory with the following variable:
GEMINI_API_KEY=YOUR_GEMINI_KEY...make sure to add the key in GeminiService.ts file in backend
Ensure the API key is correctly referenced in geminiAi.js (backend service).
Without this, the service will crash.
Run backend + frontend together:
Backend
npm run dev
Frontend
npm start
##Video
https://github.com/user-attachments/assets/205875df-f242-428f-ad51-bbeaf2b5b7c9
##backend .env
GEMINI_API_KEY=YOUR_API_KEY
CORS_ORIGIN=http://localhost:5173
PORT=4000
##frontend .env
VITE_API_BASE_URL=http://localhost:3000
##Important Notes regarding this PR
Example .env file structure is provided above—developers need to fill in their own key.
If the GEMINI_API_KEY is missing, backend requests will fail with error.
Riya Chandra || GSSOC Contributor 2025
Thank you !
@Kushika-Agarwal