DEV Community

Hashim khan
Hashim khan

Posted on

Publish technical n8n tutorial with full code examples and screenshots

Appointment booking is one of those business processes that looks simple until a company starts receiving dozens or hundreds of enquiries every day.

A customer asks:

“Do you have any appointments available tomorrow afternoon?”

Someone from the team has to read the message, understand the requested date and time, check the calendar, find an available slot, create the appointment, and send a confirmation.

This process can be automated.

In this tutorial, we'll build an AI-powered appointment booking workflow using n8n, OpenAI, and Google Calendar.

The workflow will receive a customer message, use AI to understand the request, check calendar availability, create an appointment, and return a confirmation message.


What We Are Building

Our workflow will follow this basic architecture:

Customer Message
       ↓
WhatsApp / Webhook
       ↓
       n8n
       ↓
   OpenAI Agent
       ↓
Understand Intent
       ↓
Extract Date & Time
       ↓
Google Calendar
       ↓
Check Availability
       ↓
 ┌───────────────┐
 │ Slot Available│
 └───────┬───────┘
         ↓
Create Event
         ↓
Confirmation
         ↓
Customer
Enter fullscreen mode Exit fullscreen mode

The same architecture can be adapted for dental clinics, salons, consultants, real estate agencies, veterinary clinics, repair businesses, and many other appointment-based businesses.


Tools We Need

For this project, we'll use:

  • n8n — workflow automation
  • OpenAI — understanding customer messages
  • Google Calendar — checking availability and creating appointments
  • Webhook — receiving incoming requests
  • Google Sheets or Airtable — optional customer/booking storage
  • WhatsApp Business API — optional communication channel

You can replace WhatsApp with a website chatbot, Instagram messaging system, or another communication channel.


Step 1 — Create the n8n Workflow

Create a new workflow in n8n.

The first node will be a Webhook node.

Set the webhook method to:

POST
Enter fullscreen mode Exit fullscreen mode

The webhook will receive information such as:

{
  "name": "John Smith",
  "phone": "+441234567890",
  "message": "I want to book an appointment tomorrow at 3 PM"
}
Enter fullscreen mode Exit fullscreen mode

Once the webhook receives the request, n8n can process the information automatically.


Step 2 — Add an Edit Fields Node

After the webhook, add an Edit Fields node.

The purpose of this node is to create a clean structure for the information we need.

For example:

customer_name
customer_phone
customer_message
Enter fullscreen mode Exit fullscreen mode

You can map the incoming webhook values:

customer_name → {{$json.name}}

customer_phone → {{$json.phone}}

customer_message → {{$json.message}}
Enter fullscreen mode Exit fullscreen mode

Keeping the data organized makes the rest of the workflow easier to maintain.


Step 3 — Send the Message to OpenAI

Now add an OpenAI node.

The AI needs to understand what the customer wants.

For example:

I want to book an appointment tomorrow at 3 PM.
Enter fullscreen mode Exit fullscreen mode

The AI should identify:

  • Intent
  • Date
  • Time
  • Customer request
  • Missing information

A useful structured output could look like this:

{
  "intent": "book_appointment",
  "date": "2026-09-24",
  "time": "15:00",
  "duration_minutes": 30,
  "needs_more_information": false
}
Enter fullscreen mode Exit fullscreen mode

The exact date should be calculated based on the current date supplied to the workflow rather than hard-coded.


Step 4 — Create a Structured AI Prompt

Instead of asking the model for a normal conversational response, ask it to return structured information.

Example prompt:

You are an appointment scheduling assistant.

Analyze the customer's message and extract the following:

1. Intent
2. Requested date
3. Requested time
4. Appointment duration
5. Whether more information is required

Return valid JSON only.

Possible intents:
- book_appointment
- ask_availability
- cancel_appointment
- reschedule_appointment
- general_question

If the customer has not provided enough information, set
needs_more_information to true.

Customer message:
{{$json.customer_message}}
Enter fullscreen mode Exit fullscreen mode

Structured outputs make the workflow easier to route.


Step 5 — Handle Missing Information

Customers don't always provide everything in one message.

For example:

Can I book an appointment tomorrow?
Enter fullscreen mode Exit fullscreen mode

The customer has provided a date but not necessarily a time.

We can use an IF node to check:

needs_more_information == true
Enter fullscreen mode Exit fullscreen mode

If true, send a message such as:

Sure! What time would you prefer for your appointment tomorrow?
Enter fullscreen mode Exit fullscreen mode

The workflow can then wait for the customer's response and continue the conversation.


Step 6 — Check Google Calendar Availability

If all required information is available, the workflow moves to Google Calendar.

Use the Google Calendar integration to search for events around the requested time.

For example:

Requested date: September 24
Requested time: 15:00
Duration: 30 minutes
Enter fullscreen mode Exit fullscreen mode

The workflow checks whether another event already occupies that period.

Conceptually:

15:00 ───────── 15:30
        Available?
Enter fullscreen mode Exit fullscreen mode

If another appointment exists during that period, the requested slot cannot be booked.


Step 7 — Handle an Unavailable Slot

Add an IF or Switch node after the calendar availability check.

Example logic:

IF slot_available == true
        ↓
Create appointment

IF slot_available == false
        ↓
Find alternative slots
        ↓
Send options to customer
Enter fullscreen mode Exit fullscreen mode

For example, the customer could receive:

The 3:00 PM slot is already booked.

We have these alternatives available:

• 2:00 PM
• 4:00 PM
• 5:30 PM

Which one would you prefer?
Enter fullscreen mode Exit fullscreen mode

This prevents the automation from simply rejecting the booking.


Step 8 — Create the Google Calendar Event

Once the customer selects an available time, use the Google Calendar node to create the event.

Example event information:

Title:
Appointment - John Smith

Start:
2026-09-24 15:00

End:
2026-09-24 15:30

Description:
Customer: John Smith
Phone: +441234567890
Booked through AI appointment assistant
Enter fullscreen mode Exit fullscreen mode

The calendar event can also contain additional customer information if appropriate.


Step 9 — Store the Booking

You can optionally save the booking in Google Sheets or Airtable.

Example fields:

Field Example
Customer John Smith
Phone +441234567890
Date 2026-09-24
Time 15:00
Status Confirmed
Source WhatsApp
Calendar Event ID abc123

This creates a simple booking database and can also be connected to a CRM.


Step 10 — Send the Confirmation

After Google Calendar successfully creates the appointment, send a confirmation to the customer.

Example:

Your appointment is confirmed! ✅

Date: September 24
Time: 3:00 PM
Duration: 30 minutes

We'll see you then.

If you need to reschedule, just send us a message.
Enter fullscreen mode Exit fullscreen mode

If WhatsApp is being used, the confirmation can be sent through the WhatsApp Business API.


Example Complete Workflow

The final n8n workflow can look like this:

Webhook
   ↓
Edit Fields
   ↓
OpenAI
   ↓
IF — Missing Information?
   ↓
 ┌─────────────────────┐
 │                     │
Yes                   No
 │                     │
 ↓                     ↓
Ask Customer      Google Calendar
for Information         ↓
                  Check Availability
                         ↓
                     IF Available?
                      /        \
                    Yes         No
                    ↓            ↓
             Create Event    Find Alternatives
                    ↓            ↓
               Confirmation   Send Options
Enter fullscreen mode Exit fullscreen mode

This structure keeps the workflow easy to understand and maintain.


Example Customer Conversation

Customer

Hi, I'd like to book an appointment tomorrow at 4 PM.
Enter fullscreen mode Exit fullscreen mode

AI

The AI extracts:

{
  "intent": "book_appointment",
  "date": "2026-09-24",
  "time": "16:00",
  "duration_minutes": 30,
  "needs_more_information": false
}
Enter fullscreen mode Exit fullscreen mode

Calendar

The workflow checks:

16:00 → Available
Enter fullscreen mode Exit fullscreen mode

Calendar Event

n8n creates the appointment.

Customer

Your appointment has been confirmed for tomorrow at 4:00 PM. ✅
Enter fullscreen mode Exit fullscreen mode

The entire process can happen automatically.


Handling Rescheduling

The same workflow can support rescheduling.

For example:

Can I move my appointment from 3 PM to 5 PM?
Enter fullscreen mode Exit fullscreen mode

The AI can identify:

{
  "intent": "reschedule_appointment",
  "old_time": "15:00",
  "new_time": "17:00"
}
Enter fullscreen mode Exit fullscreen mode

The workflow can then:

  1. Find the existing appointment
  2. Check the new slot
  3. Update the Google Calendar event
  4. Send a new confirmation

Handling Cancellations

The same system can also handle cancellation requests.

Example:

I need to cancel my appointment tomorrow.
Enter fullscreen mode Exit fullscreen mode

The workflow can identify the cancellation intent, locate the relevant calendar event, cancel it, and notify the customer.

A production system should verify enough customer information before modifying or cancelling an appointment.


Error Handling

Automation should never assume that every API request will succeed.

Common problems include:

  • Google Calendar API failure
  • OpenAI API timeout
  • Missing customer information
  • Invalid date
  • Invalid time
  • No available slots
  • Duplicate booking
  • WhatsApp delivery failure

Create an error workflow in n8n to capture failures.

For example:

Main Workflow
      ↓
Error
      ↓
Error Workflow
      ↓
Log Error
      ↓
Notify Team
Enter fullscreen mode Exit fullscreen mode

The internal team can receive an alert through Slack, email, or another notification system.


Preventing Double Bookings

One important production consideration is race conditions.

Imagine two customers request the same appointment at almost exactly the same time.

Both workflows might initially see the slot as available.

To reduce this risk:

  1. Check availability immediately before creating the event.
  2. Keep appointment creation as close as possible to the availability check.
  3. Use a unique booking/reference ID.
  4. Add duplicate checks where appropriate.
  5. Consider a database or booking system for higher-volume implementations.

The exact strategy depends on the booking volume and architecture.


Security Considerations

Never expose API credentials directly in webhook responses or frontend JavaScript.

Use n8n's credential system for:

  • OpenAI credentials
  • Google Calendar credentials
  • WhatsApp credentials
  • Database credentials

Also consider:

  • Webhook authentication
  • Input validation
  • Rate limiting
  • Logging
  • Access controls
  • Sensitive-data handling
  • Secure environment variables

Customer data should only be stored and processed where appropriate for the business and its legal requirements.


Testing the Workflow

Before deploying the automation, test different scenarios.

Test 1 — Available Slot

I'd like an appointment tomorrow at 2 PM.
Enter fullscreen mode Exit fullscreen mode

Expected result:

Appointment booked.
Enter fullscreen mode Exit fullscreen mode

Test 2 — Unavailable Slot

Book me at 3 PM tomorrow.
Enter fullscreen mode Exit fullscreen mode

Expected result:

3 PM unavailable.
Alternative slots returned.
Enter fullscreen mode Exit fullscreen mode

Test 3 — Missing Time

Can I book tomorrow?
Enter fullscreen mode Exit fullscreen mode

Expected result:

AI asks for preferred time.
Enter fullscreen mode Exit fullscreen mode

Test 4 — Cancellation

Please cancel my appointment.
Enter fullscreen mode Exit fullscreen mode

Expected result:

Existing appointment identified and cancellation processed.
Enter fullscreen mode Exit fullscreen mode

Test 5 — Invalid Request

Book me sometime.
Enter fullscreen mode Exit fullscreen mode

Expected result:

AI asks for the missing information.
Enter fullscreen mode Exit fullscreen mode

Testing these scenarios before going live helps identify workflow problems.


Where This Automation Can Be Used

This architecture can work for many appointment-based businesses.

Dental Clinics

Patients can request consultations and appointments without waiting for staff.

Salons

Customers can check availability and book services.

Veterinary Clinics

Pet owners can request appointments and receive confirmations.

Real Estate

Prospects can request property viewing appointments.

Consultants

Potential clients can book discovery calls automatically.

Service Businesses

Customers can schedule inspections, estimates, repairs, and consultations.


Why Use n8n?

n8n is useful for this type of workflow because it can connect different systems together.

Instead of building every integration from scratch, you can create a visual workflow connecting:

Communication
      ↓
AI
      ↓
Business Logic
      ↓
Calendar
      ↓
CRM
      ↓
Notifications
Enter fullscreen mode Exit fullscreen mode

This makes it easier to modify the workflow as business requirements change.


Production Improvements

Once the basic workflow works, you can extend it with:

  • CRM integration
  • WhatsApp conversation history
  • AI-powered FAQ responses
  • Automated reminders
  • Email confirmations
  • SMS notifications
  • Customer segmentation
  • Follow-up workflows
  • No-show reminders
  • Analytics dashboards
  • Human-agent handoff
  • Multiple calendars
  • Multiple locations

For example:

Booking Confirmed
       ↓
24-Hour Reminder
       ↓
2-Hour Reminder
       ↓
Appointment
       ↓
Post-Appointment Follow-Up
Enter fullscreen mode Exit fullscreen mode

This turns a simple booking workflow into a complete customer communication system.


Final Thoughts

An AI appointment booking system doesn't need to be complicated.

The basic process is straightforward:

Receive Message
      ↓
Understand Request
      ↓
Check Availability
      ↓
Book Appointment
      ↓
Confirm Booking
Enter fullscreen mode Exit fullscreen mode

n8n provides the automation layer, OpenAI handles natural-language understanding, and Google Calendar manages the appointments.

The real value comes from connecting these systems into one reliable workflow rather than forcing employees to manually move information between different tools.

For businesses receiving a high volume of appointment requests, this type of automation can reduce repetitive work while giving customers a faster way to book.


Building AI Automation for Your Business

At Aiotagen, we build AI automation systems for businesses, including AI chatbots, AI calling agents, WhatsApp automation, n8n workflows, lead qualification, appointment booking, and CRM integrations.

If your business still handles repetitive customer enquiries and appointment requests manually, an automated workflow can help streamline the process.

Learn more about AI automation solutions at Aiotagen.

https://aiotagen.com/


Conclusion

The combination of n8n + OpenAI + Google Calendar provides a flexible foundation for building AI-powered appointment systems.

You can start with a simple booking workflow and gradually add reminders, CRM integration, WhatsApp, analytics, and human handoff.

The important part is to begin with one clear business problem and build the automation around it.

Top comments (0)