Backend implementation of the AI ChatBot that won the "24 Heures du Code" hackathon.
The primary goal of the hackathon was to develop a chatbot to automate the reception process at Hotel California. Instead of clients having to ask hotel managers for information and make requests manually, they could interact with an AI-powered chatbot that handles basic management tasks seamlessly.
The hackathon organizers provided a pre-developed REST API for the Hotel California system. The chatbot's objective was to interpret user requests in natural language and translate them into appropriate API calls.
The chatbot interacts with users via a frontend UI, which communicates with the backend using WebSockets. The backend processes user messages using the LangGraph
framework, directing them to an AI agent that utilizes predefined tools to execute tasks efficiently.
- User Input Processing: Messages are sent to the AI agent.
- Tool Invocation: The AI agent determines the required tools based on the user’s intent.
- Parameter Handling: With the help of
pydantic
, the agent extracts relevant details and fills in missing parameters if possible. - Clarification Requests: If user input is incomplete or unclear, the agent prompts for missing details.
- API Interaction: The necessary tool sends a request to the Hotel California REST API.
- Response Handling: The chatbot displays the API response to the user in the chat.
- Client Management
- Restaurant Reservations
- Hotel Accommodation Information
- Weather Updates
- Local Events Lookup
✅ Conversational Memory: The AI agent retains message history, allowing it to provide context-aware responses.
✅ Speech Recognition: Users can interact with the chatbot via voice input.
✅ Multilingual Support: The chatbot understands and responds in multiple languages.
-
Clone the repository:
git clone https://github.com/24h-du-code-2025/backend.git <directory>
-
Navigate to the repository directory:
cd <directory>
-
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Create a
.env
file using the.env.dist
template and fill it with environment variables:ATLAS_URI=mongodb://127.0.0.1/?retryWrites=true&w=majority DB_NAME=hotel-california LLM_MODEL=CHATGPT HOTEL_API_URL=https://app-584240518682.europe-west9.run.app/ HOTEL_API_KEY= OPEN_WEATHER_API_KEY= OPENAI_API_KEY= LANGSMITH_TRACING=true LANGSMITH_ENDPOINT="https://api.smith.langchain.com" LANGSMITH_API_KEY= LANGSMITH_PROJECT="hackaton"
-
Launch the server:
flask --app server run --debug
🔹 Note: Ensure you have a MongoDB instance running on port 27017 before starting the application.
Folder / File | Description |
---|---|
assets/ |
Application diagrams |
model/ |
Model classes for interacting with the hotel REST API |
prompts/ |
Prompt templates sent to the LLM |
tools/ |
Function tools used by the AI agent |
utils/ |
Utility functions |
config.py |
Configuration class storing environment variables |
server.py |
Main Flask application |
- 🐍 Python – Core programming language
- 🌶️ Flask – Web framework
- 🍃 PyMongo – MongoDB integration
- 🔗 LangChain – LLM orchestration
- 🕸️ LangGraph – LLM graph-based reasoning + creation of AI agents
- 📂 LangSmith – LLM debugging & tracing
- 🤖 OpenAI – AI model integration
- 🗣️ Whisper – Speech-to-text processing