Introduction
Managing bookings and appointments manually is inefficient and prone to errors. Automating this process with Python, MongoDB, and Pandas ensures real-time availability updates, seamless scheduling, and automated notifications.
Lillqvist Strata provides custom automation solutions to optimize your booking system and increase operational efficiency.
1. Booking System Needs
A fully automated booking system should:
- Allow customers to book appointments online.
- Store booking details securely in MongoDB.
- Prevent double bookings by checking availability.
- Send automated reminders to customers.
2. MongoDB Booking Schema
We use MongoDB to store booking data, ensuring real-time updates and availability tracking.
Setting Up the Database
from pymongo import MongoClient
client = MongoClient("mongodb://localhost:27017/")
db = client["booking_system"]
bookings_collection = db["bookings"]
Defining the Booking Schema
booking = {
"customer_name": "Alice Johnson",
"email": "alice@example.com",
"service": "Haircut",
"date": "2025-03-01",
"time": "14:00",
"status": "Confirmed"
}
bookings_collection.insert_one(booking)
3. Python Booking Logic
To prevent double bookings, we check availability before confirming an appointment.
def check_availability(date, time):
existing_booking = bookings_collection.find_one({"date": date, "time": time})
return existing_booking is None
def add_booking(customer_name, email, service, date, time):
if check_availability(date, time):
booking = {
"customer_name": customer_name,
"email": email,
"service": service,
"date": date,
"time": time,
"status": "Confirmed"
}
bookings_collection.insert_one(booking)
print(f"Booking confirmed for {customer_name} on {date} at {time}.")
else:
print("Time slot not available. Please choose another time.")
add_booking("John Doe", "john@example.com", "Consultation", "2025-03-01", "14:00")
4. Pandas Availability Analysis
To analyze booking patterns and peak hours, we use Pandas:
import pandas as pd
# Load bookings into a DataFrame
bookings = list(bookings_collection.find({}, {"_id": 0}))
df = pd.DataFrame(bookings)
# Count bookings per time slot
time_analysis = df["time"].value_counts()
print(time_analysis)
# Save report
df.to_excel("booking_report.xlsx", index=False)
5. Customer Notifications
To automate email reminders, we use smtplib:
import smtplib
from email.message import EmailMessage
def send_email(to_email, name, date, time):
msg = EmailMessage()
msg.set_content(f"Dear {name},\n\nThis is a reminder for your appointment on {date} at {time}.\n\nBest regards,\nYour Booking Team")
msg["Subject"] = "Appointment Reminder"
msg["From"] = "noreply@yourcompany.com"
msg["To"] = to_email
with smtplib.SMTP("smtp.yourmailserver.com", 587) as server:
server.starttls()
server.login("your_email", "your_password")
server.send_message(msg)
send_email("alice@example.com", "Alice Johnson", "2025-03-01", "14:00")
Conclusion
With Python, MongoDB, and Pandas, businesses can eliminate scheduling errors, optimize resource allocation, and improve customer satisfaction.
Lillqvist Strata helps companies implement custom automation solutions that streamline booking management and increase efficiency. Let’s build your automated booking system today!

Lillqvist Strat consults on business developement, software projects, automation, SOPs, analytical tools and more.
Contact me today to get started on our journey to higher profits, more revenue and happier employees!
Go to Contact now