Overview
The calendar integration enables users to schedule, view, reschedule, and cancel appointments directly through WhatsApp. It connects to Google Calendar API and uses AI-powered intent detection to understand natural language requests.Features
Schedule Appointments
Book appointments with date/time validation and conflict detection
Check Availability
Query available time slots within business hours
List Appointments
View upcoming scheduled appointments
Reschedule & Cancel
Modify or cancel existing appointments
Google Calendar Service
The system integrates with Google Calendar API v3:Authentication
src/Services/GoogleCalendarService.php
Token Refresh
Automatically refreshes expired access tokens:src/Services/GoogleCalendarService.php
Intent Detection
Uses OpenAI function calling to detect calendar intents:Supported Intents
- Schedule
- Check Availability
- List Appointments
- Reschedule
- Cancel
Detect appointment scheduling requests:Example triggers:
- “quiero una cita”
- “puedo ir el martes”
- “necesito un turno”
- “están disponibles el viernes”
Intent Processing
webhook.php
Scheduling Flow
The appointment scheduling process:Intent Detection
System detects scheduling intent and extracts date/time preferences from user message.
Date Validation
Validates date format and ensures it’s not in the past:
src/Services/GoogleCalendarService.php
Business Hours Check
Validates time is within configured business hours:
src/Services/GoogleCalendarService.php
Minimum Advance Check
Ensures appointment is scheduled with minimum notice:
src/Services/GoogleCalendarService.php
Conflict Detection
Checks for existing appointments in the requested time slot:
src/Services/GoogleCalendarService.php
Date Parsing
The system supports multiple date formats:src/Services/GoogleCalendarService.php
Supported date formats:
- Numeric:
15/03/2026,15-03-2026 - Spanish:
15 de marzo,15 de marzo de 2026 - Relative:
hoy,mañana,pasado mañana
Event Management
List Appointments
src/Services/GoogleCalendarService.php
Reschedule Appointment
src/Services/GoogleCalendarService.php
Cancel Appointment
src/Services/GoogleCalendarService.php
Reminders
Configure email and popup reminders:src/Services/GoogleCalendarService.php
Configuration
Calendar settings are stored in the database:WhatsApp Formatting
Format events for WhatsApp display:src/Services/GoogleCalendarService.php
Next Steps
Setup Calendar
Configure Google Calendar OAuth and credentials
Flow Builder
Create custom conversation flows