๐ฌ Confirm restaurant orders by phone with Supabase, Claude and Twilio
โก 46 views ยท ๐ฌ Lead Nurturing & AI Sales Agents
Description
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
notificationsororderstable and extracts theorderId. - Skips processing if the payload is not a new order (or has no order id), and otherwise inserts a row into Supabase
order_call_logsto 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_logsrow 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 authxi-api-key), and Twilio (basic auth using Account SID and Auth Token). - In Supabase, create the
order_call_logstable with a unique constraint onorder_id, and ensure the workflow can readnotifications,orders,order_items,restaurants, andcustomers. - 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(ororders) for the Insert event to POST tohttps://YOUR_N8N_TUNNEL_URL/webhook/order-confirmation-call, and ensure the Twilio<Play>andStatusCallbackURLs are publicly reachable.
๐ Nodes Used
HTTP Request, Webhook
๐ฅ Import
Download workflow.json and import into n8n:
Workflow menu โ Import from File