Developed a RESTful API using Express.js that implements a chatbot capable of handling hotel booking queries. The chatbot uses Gemini-1.5-Flash for natural language processing and maintains conversation history.
Here's the link of the hosted project (AWS + Render): Simplified Hotel Booking Chatbot
- Used Express.js as the framework for building the API.
- Integrated Gemini-1.5-Flash for natural language processing.
- Implemented conversation history storage using sqlite and sequelize.
- Implemented function calling to get rooms data & simulate booking a room.
- POST /chat - Handles user messages and returns chatbot responses.
- User initiates a conversation about booking a resort room.
- Bot fetches room options from an API and responds with a list of room options.
- User selects a room.
- Bot provides pricing information.
- User confirms they want to proceed with booking.
- Bot makes a simulated API call to book the room and returns a booking confirmation with a booking ID.
- Creating a RESTful API with Express.js.
- Integrating and using Gemini-1.5-Flash for natural language processing.
- Maintaining conversation history throughout the chat session.
- Implementing function calling to simulate external API interactions (room booking).
- Implemented basic error handling for invalid user inputs or API failures.
- Added a simple frontend interface for interacting with the chatbot (using HTML, CSS, and JavaScript or React).
- Node.js (>=18.x)
- npm
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Install the dependencies:
npm install
-
Create a
.env
file in the root directory and add your Gemini-1.5-Flash API key:GEMINI_API_KEY=your_gemini_api_key
-
Start the server:
npm start
-
The API will be accessible at
http://localhost:3000
.
Request:
{
"message": "I want to book a resort room."
}
Response:
{
"response": "Sure! Here are some room options...",
"rooms": [
{
"id": 1,
"type": "Deluxe Room",
"price": "$200/night"
},
{
"id": 2,
"type": "Suite",
"price": "$350/night"
}
]
}
To set up the Gemini-1.5-Flash API key:
- Sign up on the Gemini platform and obtain your API key.
- Add the key to your
.env
file as shown above.