Confirm restaurant orders by phone with Supabase, Claude and Twilio
Go to WorkflowDescription
Quick Overview
This workflow triggers from a Supabase Database Webhook when a new order is inserted, generates a short order-confirmation script with Anthropic Claude, calls the customer via Twilio, and streams live voice audio generated by ElevenLabs back to Twilio without storing an audio file.
How it works
Receives a webhook request from Supabase for a new row inserted in the notifications or orders table and extracts the orderId.
Skips processing if the payload is not a new order (or has no order id), and otherwise inserts a row into Supabase order_call_logs to claim the order and prevent duplicate calls.
Fetches the order, restaurant, items, and customer language from Supabase and prepares a call context including a normalized E.164 phone number.
Sends the call context to Anthropic Claude to generate a short confirmation script and saves the script plus call metadata back to order_call_logs.
Places an outbound call with Twilio that instructs Twilio to play audio from an n8n webhook URL and returns a JSON response indicating the call was initiated.
When Twilio requests the audio URL, the workflow loads the saved script from Supabase, generates an MP3 on the fly with ElevenLabs Text-to-Speech, and streams the binary audio response directly back to Twilio.
When Twilio posts the final call status callback, the workflow maps the outcome and updates the matching order_call_logs row in Supabase with the final status, pickup flag, and Call SID.
Setup
Create n8n credentials for Supabase API (project URL as host and a service role key), Anthropic API (header auth x-api-key), ElevenLabs (header auth xi-api-key), and Twilio (basic auth using Account SID and Auth Token).
In Supabase, create the order_call_logs table with a unique constraint on order_id, and ensure the workflow can read notifications, orders, order_items, restaurants, and customers.
Replace YOUR_PROJECT.supabase.co, YOUR_TWILIO_ACCOUNT_SID, YOUR_TWILIO_PHONE_NUMBER, YOUR_N8N_TUNNEL_URL, and the ElevenLabs voice ID in the ElevenLabs Text-to-Speech request URL.
Configure a Supabase Database Webhook on notifications (or orders) for the Insert event to POST to https://YOUR_N8N_TUNNEL_URL/webhook/order-confirmation-call, and ensure the Twilio ` and StatusCallback` URLs are publicly reachable.