AI-powered voice assistant with Python, PJSIP and VoIPstudio (Part 1)
- Tim Meredith
Table of contents
A VoIPstudio customer needed their SCADA system to automatically call engineers when critical alarms were triggered.
Using an open-source Python SIP client built on PJSIP (PJSUA2), they connected their infrastructure directly to a VoIPstudio SIP trunk and began placing automated voice calls triggered by system events.
They then extended the solution by integrating a local AI conversational engine, transforming one-way alarm calls into dynamic, two-way voice interactions.
The full client implementation is open source.
This case demonstrates how VoIPstudio provides a standards-based, developer-friendly SIP foundation for programmable and AI-powered voice applications.
The evolution of voice: From people to systems
Voice is no longer just human-to-human communication.
Modern operational environments increasingly require system-to-human escalation:
- Industrial control alarms
- IT infrastructure failures
- IoT-triggered events
- Monitoring thresholds
- Safety alerts
Email and SMS are often insufficient for high-priority incidents. Voice remains the most reliable real-time escalation channel.
The initial use case: SCADA alarm escalation
The customer operates a SCADA (Supervisory Control and Data Acquisition) system monitoring critical infrastructure.
Requirement:
When a priority alarm is triggered, the system must immediately call the responsible engineer and deliver a clear warning, with the following business requirements:
- No human intervention.
- No manual dialing.
- No hardware PBX.
Architecture Overview
The solution was intentionally minimal and standards-based:
- Python application
- PJSIP (PJSUA2 bindings)
- VoIPstudio SIP trunk
- Local machine deployment
When an alarm condition is met:
- The Python script registers to VoIPstudio using SIP credentials.
- It initiates an outbound SIP call.
- Upon answer, it plays a pre-recorded .wav alert file.
- The call terminates once playback completes.
This required no proprietary SDKs and no telephony middleware, just SIP.
The open-source foundation: voip-client-python
At the core of this implementation is an open-source project developed by Luis Miguel.
Repository:
https://github.com/luismiguelbp/voip-client-python
Project: voip-client-python
This is a functional Python SIP client built using PJSIP / PJSUA2, demonstrating:
- SIP registration
- Call initiation and teardown
- RTP media handling
- Audio playback injection
- Event-driven call lifecycle management
Rather than being a theoretical example, this is working, inspectable code that developers can fork and adapt.
Example (Simplified Call Placement Logic)
Below is a simplified conceptual example based on how PJSUA2 is used in Python:
call = MyCall(account, pj.CallOpParam(True))
call.makeCall("sip:+441234567890@sip.voipstudio.com", pj.CallOpParam(True))
From there, media callbacks allow injection of audio files or real-time generated audio streams.
From static alerts to AI conversations
The customer did not stop at playing a static .wav file.
They extended the architecture by integrating a local AI conversational engine running on the same machine as the SIP client.
The upgraded flow:
- SCADA triggers alarm.
- Python client initiates call via VoIPstudio.
- AI generates dynamic spoken alert.
- Human responds verbally.
- AI processes speech input.
- System continues conversational logic.
The result is a two-way voice interaction over a standard SIP trunk.
Instead of:
“Critical temperature alarm.”
The system can now say:
“A temperature alarm has triggered at Site B. Do you acknowledge responsibility? Please say ‘confirmed’ to accept.”
And then process the response in real time.
There is no cloud AI telephony lock-in, or proprietary voice bot platform. Just SIP + Python + AI. VoIPstudio just provides the telephony transport layer.
Architecture Overview
Below is a simplified representation of the production architecture used in this deployment:
+--------------------+ SIP +----------------------+
| Python App | <----------------> | VoIPstudio SIP |
| (voip-client) | | Infrastructure |
| | | - Authentication |
| - Alarm Logic | | - Call Routing |
| - Call Control | | - PSTN Termination |
| - AI Integration | | - Number Provision |
+---------+----------+ +----------+-----------+
| |
| RTP Media |
v v
+--------------------+ +----------------------+
| Local AI Engine | | Public Telephone |
| | | Network |
| - STT | | |
| - Conversational | | Engineer / Operator |
| - Response Gen | | Receives Call |
+--------------------+ +----------------------+
Call Flow
- SCADA system triggers alarm.
- Python application initiates SIP INVITE via VoIPstudio.
- Call is routed to destination number.
- AI engine generates spoken alert.
- RTP audio is streamed in real time.
- Human response is captured and processed.
- Call logic continues based on AI decision tree.
Because the solution is based on standard SIP:
- It can be deployed on-premise or in the cloud.
- AI engines can be swapped without changing telephony infrastructure.
- Call logic remains fully programmable.
This separation between intelligence and telephony transport is what makes the architecture scalable.
Beyond SCADA: Where this architecture applies
The same VoIPstudio + Python + AI pattern supports:
- IT Infrastructure Monitoring: Escalation calls reporting precise error codes to on-call engineers.
- Intelligent Safety Systems: Automated outbound calls to emergency contacts when monitored activities fail to check in.
- Appointment Confirmation Systems: Two-way voice confirmation and rescheduling without human operators.
- AI-Driven IVR Systems: Replacing predestined DTMF trees with conversational agents.
- IoT Event Escalation: Voice alerts triggered by environmental sensors or threshold breaches.
NOTE: Here, in each case, VoIPstudio can act as the reliable SIP backbone.
Explore the code
If you are building automation systems, AI assistants, monitoring platforms or intelligent escalation workflows, start here:
Repository:
https://github.com/luismiguelbp/voip-client-python
Project: voip-client-python
Review, fork, extend, then connect it to a VoIPstudio SIP trunk and begin experimenting.
Ready to voice-enable your applications?
VoIPstudio provides:
- Global SIP connectivity
- Flexible trunking
- Developer-friendly configuration
- Reliable PSTN termination
Start a free trial and begin building your own programmable voice solutions.
The intelligence is yours. We provide the voice layer.
More from the blog
Want to improve your business communication?
Unlock enterprise-class call center power at affordable prices – no hardware, no delays, no surprises!