A calendar webhook service that checks appointment availability using Google Calendar API.
- Checks calendar availability for requested time slots
- Ensures 2-hour setup time between appointments
- Provides friendly responses for booking inquiries
- Integrates with Google Calendar API
- Install dependencies:
npm install-
Set up Google Service Account:
- Create a service account in Google Cloud Console
- Download the service account key file
- Rename it to
service-account.jsonand place it in the root directory
-
Configure Calendar ID:
- Update the
calendarIdvariable inapi/webhook.jswith your Google Calendar ID
- Update the
For production deployment (especially on platforms like Vercel), set these environment variables:
GOOGLE_CLIENT_EMAIL=your-service-account-email@your-project.iam.gserviceaccount.com
GOOGLE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nYOUR_PRIVATE_KEY_HERE\n-----END PRIVATE KEY-----"Note: When setting GOOGLE_PRIVATE_KEY, make sure to wrap it in quotes and replace actual newlines with \n.
- Push your code to GitHub
- Connect your repository to Vercel
- Set the environment variables in Vercel dashboard:
GOOGLE_CLIENT_EMAILGOOGLE_PRIVATE_KEY
- Deploy
npm startThe server will start on port 3000 (or the PORT environment variable).
Checks availability for the specified time (or current time if not specified).
Request:
{
"queryResult": {
"parameters": {
"date-time": "2025-07-12T12:00:00+09:00"
}
}
}Response:
{
"fulfillmentText": "요청하신 시간은 예약 가능합니다! 변경 원하시면 말씀해주세요 😊"
}The webhook now includes comprehensive error handling:
- Authentication errors
- Invalid request format
- Calendar API errors
- Network connectivity issues
- Authentication Error: Make sure your service account has calendar read permissions
- Calendar Not Found: Verify the calendar ID is correct
- Private Key Error: Ensure newlines in the private key are properly formatted as
\n
The webhook logs detailed information in development mode:
- Request parameters
- Calendar events found
- Processing steps
- Final response
- Express.js: Web framework
- Google APIs: Calendar API integration
- Body Parser: JSON request parsing