See llms.txt for all machine-readable content.

Back to Templates

Triage appointment requests with OpenAI, Supabase, Gmail, and webhooks

Quick Overview

This workflow accepts customer requests via a webhook or email, logs them in Supabase, uses OpenAI to classify intent, and then either checks/cancels bookings via an HTTP API or answers general questions from a Supabase knowledge base before replying via Gmail.

How it works

  1. Receives a POST webhook request containing customer, message, and bookingId, validates that the message is not empty, and returns HTTP 400 for invalid submissions.
  2. Stores valid requests in a Supabase table and uses OpenAI to classify the message as reschedule, cancellation, general_enquiry, or unclear.
  3. For reschedule requests, updates the Supabase record as classified, looks up the booking via an HTTP API, and returns HTTP 200 if found or HTTP 404 if not found.
  4. For cancellation requests, retrieves the booking via an HTTP API and emails a Gmail “send and wait” approval request if the booking exists.
  5. If cancellation is approved, sends an HTTP API request to cancel the booking and emails a confirmation or failure message via Gmail based on the API response.
  6. For general enquiries, searches a Supabase vector-store knowledge base with OpenAI embeddings, uses OpenAI to draft a reply based only on the retrieved documents, and emails the response via Gmail.
  7. For unclear requests, uses OpenAI to generate a clarification question, emails it via Gmail, and saves the Gmail thread ID back to the Supabase request record.
  8. Separately, a Gmail trigger polls for incoming replies, retrieves the email, finds the original request in Supabase by Gmail thread ID, extracts the customer’s reply text, and re-runs intent classification for follow-up handling.

Setup

  1. Create and connect credentials for OpenAI, Supabase, and Gmail (OAuth2) used for classification, knowledge-base search, request logging, and email sending.
  2. In Supabase, create a client_requests table with fields used by the workflow (for example customer_name, message, booking_id, intent, status, and gmail_thread_id).
  3. In Supabase, set up a documents vector table/collection compatible with the Supabase vector store node and ensure embeddings are generated with OpenAI.
  4. Replace the booking API base URL (currently http://host.docker.internal:3000/api/bookings/...) with your own booking system endpoints and ensure they return the expected status codes.
  5. Update the Gmail recipient addresses, subjects, and any business-specific wording (for example “Northstar Wellness”) to match your environment.
  6. Copy the production webhook URL for the Incoming Request trigger and configure your website/chat widget/CRM to POST customer, message, and bookingId to it.