Restaurants lose bookings when callers hit voicemail, wait on hold, or call outside staffed hours. A voice ai reservation agent gives developers a practical way to answer inbound calls, collect booking details, and send a confirmation without building a full contact center.
The canonical code example is in the Telnyx code examples repo:
https://github.com/team-telnyx/telnyx-code-examples/tree/main/ai-restaurant-reservation-voice-agent-python
What This Example Builds
This Python example creates an inbound restaurant reservation agent using Telnyx Voice AI, AI Inference, and SMS/MMS.
The call flow is straightforward:
- A caller dials a Telnyx phone number.
- Telnyx sends call events to a Flask webhook.
- The app answers the call and plays a greeting.
- The app gathers caller speech.
- Telnyx AI Inference decides the next assistant response.
- The app repeats the loop until it has the reservation details.
- The app saves the reservation and sends an SMS confirmation.
Why This Is A Useful Voice AI Example
This example is small enough to understand in one sitting, but it still shows the core pieces developers need for a real voice ai workflow:
- Voice API webhooks for call lifecycle events
- Call Control commands for answer, speak, and gather
- AI Inference for conversational logic
- SMS confirmation after the voice interaction
- A simple
/reservationsendpoint for demo visibility
That makes it a good first project for developers who want to understand how voice, ai, and messaging fit together in one application.
Products Used
The example metadata lists:
telnyx_products: [Voice AI, SMS/MMS, AI Inference]
Voice AI handles the phone-call experience. AI Inference interprets what the caller says and generates the host response. SMS/MMS sends the reservation confirmation after the booking is complete.
Architecture
inbound phone call
-> telnyx voice api webhook
-> flask app
-> speak greeting
-> gather speech
-> telnyx ai inference
-> speak response
-> save reservation
-> send sms confirmation
The application stores demo reservations in memory. For a production deployment, replace that with a database and add authentication, observability, signature verification, rate limits, and retention controls.
Run The Example
git clone https://github.com/team-telnyx/telnyx-code-examples.git
cd telnyx-code-examples/ai-restaurant-reservation-voice-agent-python
cp .env.example .env
pip install -r requirements.txt
python app.py
Fill in the environment variables:
TELNYX_API_KEY=KEY...
RESTAURANT_NUMBER=+1...
AI_MODEL=moonshotai/Kimi-K2.6
PORT=5000
Expose the local webhook:
ngrok http 5000
Then configure your Telnyx Voice API application webhook URL:
https://<ngrok-id>.ngrok-free.app/webhooks/voice
Assign your Telnyx phone number to that Voice API application and call the number.
Demo Script
Say:
hi, i would like to book a table for two tomorrow at 7 pm.
If the agent asks follow-up questions, provide:
my name is anusha.
my phone number is +1...
yes, that is correct.
After the booking completes, check:
curl http://localhost:5000/reservations
You should see the saved reservation and receive an SMS confirmation.
Production Considerations
Before using this pattern in production, add:
- Persistent reservation storage
- Webhook signature verification
- Input validation for dates, times, and party size
- Duplicate booking protection
- Host escalation or transfer
- Monitoring for webhook and SMS failures
- Data retention and privacy controls