Systems Library / Customer Service / How to Create an AI Appointment Booking Chatbot
Customer Service chatbots

How to Create an AI Appointment Booking Chatbot

Build a chatbot that books appointments directly from conversations.

Jay Banlasan

Jay Banlasan

The AI Systems Guy

An ai appointment booking chatbot automated through conversations replaces the back-and-forth of scheduling. I build these for service businesses where bookings drive revenue. Dental offices, consultants, salons, contractors. The bot checks availability, collects info, and confirms the booking in under 2 minutes.

The trick is connecting the AI to your real calendar so it never double-books or offers slots that do not exist.

What You Need Before Starting

Step 1: Connect to Your Calendar

Set up Google Calendar API access to check availability:

from google.oauth2 import service_account
from googleapiclient.discovery import build
from datetime import datetime, timedelta

SCOPES = ["https://www.googleapis.com/auth/calendar"]
creds = service_account.Credentials.from_service_account_file(
    "credentials.json", scopes=SCOPES
)
calendar = build("calendar", "v3", credentials=creds)

def get_available_slots(date, duration_minutes=30):
    start = datetime.strptime(date, "%Y-%m-%d").replace(hour=9)
    end = start.replace(hour=17)

    events = calendar.events().list(
        calendarId="primary",
        timeMin=start.isoformat() + "Z",
        timeMax=end.isoformat() + "Z",
        singleEvents=True
    ).execute().get("items", [])

    busy = [(e["start"]["dateTime"], e["end"]["dateTime"]) for e in events]
    slots = generate_slots(start, end, duration_minutes, busy)
    return slots

Step 2: Define Booking Tools for the AI

Let Claude check availability and create bookings:

tools = [
    {
        "name": "check_availability",
        "description": "Check available appointment slots for a given date.",
        "input_schema": {
            "type": "object",
            "properties": {
                "date": {"type": "string", "description": "Date in YYYY-MM-DD format"},
                "service_type": {"type": "string", "description": "Type of appointment"}
            },
            "required": ["date"]
        }
    },
    {
        "name": "book_appointment",
        "description": "Book an appointment at a specific date and time.",
        "input_schema": {
            "type": "object",
            "properties": {
                "date": {"type": "string"},
                "time": {"type": "string", "description": "Time in HH:MM format"},
                "name": {"type": "string"},
                "email": {"type": "string"},
                "phone": {"type": "string"},
                "service_type": {"type": "string"}
            },
            "required": ["date", "time", "name", "email"]
        }
    }
]

Step 3: Build the Booking Function

Create the actual calendar event when the AI confirms a booking:

def book_appointment(date, time, name, email, phone="", service_type="General"):
    start_dt = datetime.strptime(f"{date} {time}", "%Y-%m-%d %H:%M")
    end_dt = start_dt + timedelta(minutes=30)

    event = {
        "summary": f"{service_type} - {name}",
        "description": f"Email: {email}\nPhone: {phone}",
        "start": {"dateTime": start_dt.isoformat(), "timeZone": "America/New_York"},
        "end": {"dateTime": end_dt.isoformat(), "timeZone": "America/New_York"},
    }

    created = calendar.events().insert(calendarId="primary", body=event).execute()
    send_confirmation_email(email, name, start_dt, service_type)
    return {"status": "booked", "event_id": created["id"]}

Step 4: Handle the Conversation Flow

The AI guides the conversation naturally:

SYSTEM_PROMPT = """You are a booking assistant for [Your Business].
Help customers book appointments by:
1. Asking what service they need
2. Asking their preferred date
3. Showing available times using the check_availability tool
4. Collecting their name and email
5. Booking with the book_appointment tool

Be friendly and efficient. Suggest the next available date if their preferred date is full.
Never book without confirming all details with the customer first."""

Step 5: Send Confirmation and Reminders

After booking, confirm immediately and schedule a reminder:

import smtplib
from email.mime.text import MIMEText

def send_confirmation_email(email, name, appointment_time, service):
    msg = MIMEText(f"""Hi {name},

Your {service} appointment is confirmed for {appointment_time.strftime('%B %d at %I:%M %p')}.

If you need to reschedule, reply to this email or chat with us on our website.
""")
    msg["Subject"] = f"Appointment Confirmed - {appointment_time.strftime('%B %d')}"
    msg["From"] = "[email protected]"
    msg["To"] = email

    with smtplib.SMTP("smtp.gmail.com", 587) as server:
        server.starttls()
        server.login("[email protected]", os.getenv("EMAIL_PASSWORD"))
        server.send_message(msg)

What to Build Next

Add rescheduling and cancellation through the same chatbot. Let customers say "I need to move my appointment" and the bot handles it without any human intervention.

Related Reading

Want this system built for your business?

Get a free assessment. We will map every system your business needs and show you the ROI.

Get Your Free Assessment

Related Systems