Template for deploying an AI voice assistant with Twilio, OpenAI Realtime API, and Cloudflare Workers
View the Project on GitHub jmoore2333/twilio-openai-voice-assistant-cloudflare-template
Use this path if you want Postgres. Everybody likes Postgres, and Neon is great - but just having everything handy in Cloudflare at the edge is also nice.
The turnkey ./scripts/setup.sh flow is D1-first. For Neon, keep using the manual setup below.
Create a new Neon project and copy its connection string.
Run the SQL in schema-neon.sql using the Neon SQL editor or your normal migration workflow.
Set these values for your Worker:
wrangler secret put OPENAI_API_KEY
wrangler secret put TWILIO_AUTH_TOKEN
wrangler secret put DATABASE_URL
wrangler secret put RESEND_API_KEY
RESEND_API_KEY is optional. If you skip it, email delivery will be disabled.
Copy .dev.vars.example to .dev.vars and set:
DATABASE_URLOPENAI_API_KEYTWILIO_AUTH_TOKENnpm run deploy
After deploy:
POST https://<your-domain>/voice/incomingintake_calls has a populated caller_name, reason_summary, and transcript contentDATABASE_URL and a D1 binding are configured, set STORAGE_BACKEND=neon to be explicit.