Voice AI demos often stop at conversation. A caller asks a question, an assistant replies, and nothing visible changes.
This example shows a more concrete workflow: call a phone number, say a facility command, and watch simulated IoT device state update in real time.
The app is a Python Flask service powered by Telnyx Voice AI and Call Control. It answers an inbound call, captures a spoken command, maps that command to a known device/action pair, updates in-memory device state, and speaks back a short confirmation.
What You Build
The demo behaves like a lightweight facility control line.
A caller can say:
unlock the loading dock gate
turn on the warehouse lights
check the freezer alarm
start the backup generator
turn off the irrigation pump
The app updates simulated devices like:
loading_dock_gatewarehouse_lightsfreezer_alarmbackup_generatorirrigation_pump
Each command is logged with the caller input, device, action, confidence, status, and response.
Why This Demo Works
The best voice ai demos make the output visible.
This example is easy to understand because the call changes state you can inspect through simple HTTP endpoints:
curl http://localhost:5000/devices
curl http://localhost:5000/commands
That makes the phone call feel connected to a real system instead of a standalone voice conversation.
Architecture
inbound phone call
-> telnyx call control webhook
-> flask app answers
-> telnyx ai gather captures speech
-> local parser maps device and action
-> simulated iot state updates
-> telnyx speaks confirmation
-> command appears in audit log
The local API path can also use Telnyx AI Inference for command parsing, which is useful for showing how natural-language parsing can generalize beyond the deterministic demo phrases.
For the live phone demo, the app uses a fast local parser after AI gather captures the caller's speech. That keeps the call responsive and avoids an extra model round trip before speaking the result.
Run The Example
git clone https://github.com/team-telnyx/telnyx-code-examples.git
cd telnyx-code-examples/voice-activated-iot-command-python
cp .env.example .env
pip install -r requirements.txt
python app.py
Expose your local app:
ngrok http 5000
Set the Call Control webhook URL to:
https://<ngrok-domain>/webhooks/voice
Assign a Telnyx number to the Call Control application and call it.
Demo Script
Open the device state:
curl http://localhost:5000/devices
Then call the number and say:
unlock the loading dock gate
Refresh /devices and show that the gate is now unlocked.
Then say:
turn on the warehouse lights
Refresh /devices again and show the lights are on.
Finally, open:
curl http://localhost:5000/commands
That endpoint shows the command log, which is the beginning of a production audit trail.
Production Considerations
Before connecting this to real equipment, add:
- Caller authentication and allowlists
- Confirmation steps for risky actions
- Persistent command storage
- Real IoT device integrations
- Webhook signature verification
- Monitoring for failed call commands
- Rate limits and audit exports