An intelligent conversational interface for querying hotel booking data using natural language processing and SQL generation.
Check out the deployed version on: URL
Video demo: Youtube
This hotel booking chatbot allows users to interact with hotel reservation data through natural language queries. The system interprets questions, generates appropriate SQL queries, executes them against the database, and provides human-readable answers based on the results.
- Natural Language Understanding: Process user queries about hotel booking data
- Automated SQL Generation: Convert natural language to optimized SQL queries
- RAG: Query any hotel related details from the sample file
data/sample_hotel_brochure.txt
. - Graphs: Generate graphs dynamically straight from the chat interface
- Data Analysis: Extract insights from hotel bookings and reservations
- Contextual Responses: Generate human-friendly answers from query results
The dataset was cleaned, and all graphs were generated using Kaggle.
You can find the complete notebook in notebooks/hotel-booking.ipynb
.
The project uses a multi-stage pipeline architecture:
- Query Agent: Processes user questions and coordinates the workflow
Generated from services/sql_agent/agent.py
- SQL Writer: Transforms natural language questions into SQL queries
Generated from services/sql_agent/agent.py
- Query Executor: Runs SQL against the hotel database
- Answer Generator: Formats results into natural language responses
- LangGraph: AI agent workflow management
- LLMs: Natural language processing and understanding (Gemeni Flash 2.0)
- SQLite: Database for hotel booking data
The dataset contains hotel booking information including:
- Booking details (dates, lengths of stay, guest information)
- Hotel information (resort or city hotels)
- Booking status (check-out, canceled, no-show)
- Financial data (ADR, revenue)
- Customer demographics
Key columns include:
hotel
: Hotel type (Resort Hotel or City Hotel)is_canceled
: Booking cancellation statusarrival_date_*
: Booking date informationstays_in_weekend_nights
/stays_in_week_nights
: Duration of stayadults
,children
,babies
: Guest informationreservation_status
: Current booking statusadr
: Average Daily Rate
# Clone the repository
git clone https://github.com/yourusername/hotel-booking-chatbot.git
cd hotel-booking-chatbot
# Install dependencies
pip install -r requirements.txt
uvicorn main:app
GEMENI_API_KEY=
# Generate and load the hotel dataset
python models/database.py
# Create the chat table
python models/chat.py
from services.sql_agent.agent import query_agent
# Ask a question in natural language
question = "What percent of customers have cancelled in the past year?"
result = query_agent(question)
# Access the components of the response
print(f"Question: {question}")
print(f"SQL Query: {result['query']}")
print(f"Result: {result['result']}")
print(f"Answer: {result['answer']}")
print(f"Time taken: {result['time_taken']}")
- "What percent of customers have cancelled in the past year?"
- "What places can I visit nearby the hotel?"
- "Does the hotel have WiFi?"
- "Which month had the highest booking revenue?"
- "What is the average length of stay for guests with children?"
- "Show me the top 5 countries with the most bookings"