Note: This project is based on a product engineer take-home assignment.
An intelligent AI agent that integrates with Cal.com to manage your calendar and bookings. This agent can help you book meetings, list upcoming events, and cancel bookings using natural language.
Check out the demo video to see the agent in action!
This project demonstrates an AI-powered assistant that leverages the Cal.com API to provide conversational calendar management. The agent understands user requests and takes appropriate actions like scheduling meetings, checking availability, and managing existing bookings.
.
├── README.md
├── .gitignore
├── docker-compose.yml
├── demo.mov # demo video that shows all the functionalities required
├── backend
│ ├── .dockerignore
│ ├── API.md
│ ├── Dockerfile
│ ├── cal.py
│ ├── experiments
│ ├── main.py
│ ├── requirements.txt
│ ├── system_prompt.txt
│ ├── tools
│ └── utils
├── frontend
│ ├── .dockerignore
│ ├── .gitignore
│ ├── Dockerfile
│ ├── README.md
│ ├── eslint.config.mjs
│ ├── next.config.ts
│ ├── package-lock.json
│ ├── package.json
│ ├── postcss.config.mjs
│ ├── public
│ ├── src
│ └── tsconfig.json- Natural Language Scheduling: Request meetings in plain English
- Real-time Availability: Check event type availability and book at specific times
- Booking Management: List all upcoming bookings and cancel meetings as needed
- Multi-timezone Support: Handle bookings across different timezones
- AI-Powered: Uses OpenAI GPT to understand and process user requests intelligently
Create a .env file in the backend/ directory with the following variables:
OPENAI_API_KEY_LIVEXAI=your_openai_api_key_here
CALCOM_API_KEY=your_calcom_api_key_here# Build and start both services
docker compose up --build
# Run in detached mode
docker compose up -d --build
# Stop all services
docker compose down
# Monitor the log
docker compose logs --tail=10- Frontend is reachable via
http://localhost:3021 - Backend is reachable via
http://localhost:3020
For development, you can still use the original commands:
# Backend
cd backend && python -m pip install -r requirements.txt && python main.py
# Frontend
cd front && npm install && npm run devThis agent is built with a modular architecture:
- Backend: Python-based service that handles Cal.com API integration and AI agent logic
- Frontend: Next.js web interface for interacting with the agent
- AI Layer: OpenAI GPT integration with function calling to execute calendar actions
- User enters a request (e.g., "Book a 30-minute meeting tomorrow at 2 PM")
- The AI agent parses the request and identifies required actions
- The backend makes API calls to Cal.com to check availability and create bookings
- Results are returned to the frontend and displayed to the user
- Event types: refers to the templates for the meetings user offers. Each event type defines its own duration, availability, and booking rules.
- Calendars: refers to the external (outside) calendars.
- Bookings: refers to individual appointments/meetings based on an event type and is saved to a calendar
The agent supports three main calendar operations:
- Create Booking: Schedule new meetings using available event types
- List Bookings: Retrieve all upcoming valid bookings for a user
- Cancel Booking: Cancel specific meetings
All interactions are handled through the Cal.com API with intelligent function calling powered by OpenAI.
Disclaimer: the following API docs is generated using Claude Sonnet.
cal_tool = CalComTool(api_key="your_cal_api_key")Constructor Parameters:
api_key(required): Your Cal.com API key for authentication
The class automatically validates the API key on instantiation and sets up default configurations including:
- API endpoint prefix:
https://api.cal.com/v2/ - Default API version:
2024-06-14 - User configuration for demo purposes
Event Type Management:
get_all_event_types()- Retrieve all event types for the usercreate_an_event_type(length_in_minutes, title, slug)- Create a new event typeget_an_event_type(event_type_id)- Get details of a specific event type
Booking Management:
get_available_time_slots(event_type_id, start, end)- Get available time slots for an event typecreate_a_booking(start_datetime, event_type_id, name, email, time_zone, notes)- Create a new bookingget_all_bookings(attendee_email, status)- Retrieve all bookings for a usercancel_a_booking(booking_uid)- Cancel a specific booking
Profile Management:
get_my_profile()- Get the authenticated user's profile information
The class provides three main function calling methods designed for AI agent integration:
1. Create Booking
create_a_cal_booking(event_name, datetime_start, timezone, reason, user_email, user_name)- Finds event types by fuzzy name matching
- Checks availability for the requested time slot
- Creates booking if exact time match is found
- Returns structured response with success/error codes
2. List Bookings
list_all_cal_bookings(user_email)- Retrieves all upcoming bookings for a user
- Returns formatted booking information including UID, title, times, and attendees
- Handles empty results gracefully
3. Cancel Booking
cancel_user_booking(user_email, booking_name, datetime_start)- Finds booking by exact name and datetime matching
- Cancels the booking using the Cal.com API
- Provides detailed success/failure feedback
All function calling methods return a standardized response format:
{
"status": "success" | "error",
"result": {
"code": "specific_result_code",
"message": "human_readable_message",
"data": {...} # relevant data
}
}The class implements comprehensive error handling including:
- API request failures with retry logic
- Rate limiting protection with delays
- Validation of response formats
- Detailed error reporting with specific error codes
- Graceful handling of edge cases (no matches, empty results, etc.)
# Initialize the tool
cal_tool = CalComTool(api_key="your_api_key")
# Create a booking
result = cal_tool.create_a_cal_booking(
event_name="30 Minute Meeting",
datetime_start="2025-08-03T10:00:00.000-07:00",
timezone="America/Los_Angeles",
reason="Project discussion",
user_email="user@example.com",
user_name="John Doe"
)
# List user's bookings
bookings = cal_tool.list_all_cal_bookings("user@example.com")
# Cancel a booking
cancellation = cal_tool.cancel_user_booking(
user_email="user@example.com",
booking_name="30 Minute Meeting",
datetime_start="2025-08-03T10:00:00.000-07:00"
)
