- Assuming we will need the history of the conversation, I am just giving one conversation thread, depending upon design and product decision, we can provide multiple threads in case the patient does not want to talk about something or has given some crappy information.
Initial Design Initial Design.pdf
- It's a full stack project from Frontend in React, Backend in Express-Nodejs, and Database in Mysql.
- The project is a chatbot named care chat which hits the open ai API in the backend to get answers to students query.
- It uses JWT token authentication to login and send/receive data.
- It sends the verification link using gmail smtp
- Install mysql
- create a db named chatbot_db
- Run the following queries to build the tables
CREATE TABLE `Conversations` (
`messageId` int NOT NULL AUTO_INCREMENT,
`userId` int NOT NULL,
`message` text NOT NULL,
`isUserMessage` tinyint(1) NOT NULL,
`createdAt` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`updatedAt` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`messageId`),
KEY `userId` (`userId`),
CONSTRAINT `conversations_ibfk_1` FOREIGN KEY (`userId`) REFERENCES `Users` (`userId`)
) ENGINE=InnoDB AUTO_INCREMENT=50 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `Users` (
`userId` int NOT NULL AUTO_INCREMENT,
`email` varchar(255) NOT NULL,
`userName` varchar(255) NOT NULL,
`reqCount` int DEFAULT '0',
`lastLoginTimeStamp` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`password` varchar(255) NOT NULL,
`isVerified` tinyint(1) DEFAULT '0',
`createdAt` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`updatedAt` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`userId`),
UNIQUE KEY `email` (`email`),
UNIQUE KEY `userName` (`userName`)
) ENGINE=InnoDB AUTO_INCREMENT=47 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
- brew services start mysql
- brew services stop mysql
- brew services restart mysql
- Clone the repository
- Open the terminal and move to /backend in the project
- Use
npm i
to install all the dependencies for the project. - Edit the .env file in the backend and replace the values as needed
- Run the server
node server.js
This project is a full-scale chatbot interface developed as a technical take-home assessment for a Software Engineering (SWE) Intern position. It includes user authentication, a chat interface, conversation functionality, and integration with the OpenAI API.
- User authentication with email confirmation
- Real-time chat interface
- Conversation history stored in a SQL database
- Integration with OpenAI API for chatbot responses
- Clone the repository
- Navigate to the backend directory:
cd chatbot-project
- Install dependencies:
npm install
- Edit the backend .env file and update the variables according to your system.
- Set the openAi API key in the ~/.bash_profile with
export OPENAI_API_KEY=`<key>'
- Start the server:
node server.js
- Navigate to the frontend directory:
cd chatbot-frontend
- Install dependencies:
npm install
- set the .env variables in frontend
- Start the React development server:
npm start