Hi everyone,
I’m working on a Python application that needs to make outbound calls through a GSM gateway using ARI, and I’m looking for some guidance on best practices. I am a complete beginner to asterisk so any help would be appreciated
What I’m trying to achieve:
- Make outbound mobile calls through a GSM gateway using Python + ARI
- Monitor call state in real-time (dialing, ringing, answered, etc.)
- Record the audio from both sides of the call
- Check SIM card availability - my GSM gateway has 4 SIM slots and I need to know which ones are busy
Current Setup:
- Asterisk with ARI enabled
- GSM gateway with 4 SIM card slots
- Python application using requests library for ARI calls
Specific Questions:
- Call Origination: What’s the proper way to originate calls to mobile numbers through a GSM gateway using ARI? Should I be using specific endpoint formats or routing patterns?
- Call State Monitoring: How can I reliably track call progression (dialing → ringing → answered) through ARI WebSocket events in Python?
- Audio Recording: What’s the best approach to record both sides of a GSM call using ARI? Should I use MixMonitor or handle recording differently for GSM calls?
- SIM Slot Management: How can I check which SIM cards in my 4-slot GSM gateway are currently in use? Is this something I can monitor through Asterisk/ARI or do I need to query the GSM gateway directly?
Code Structure I’m Working With:
python
# Basic ARI call structure
data = {
'endpoint': f'SIP/{number}@GSM1',
'app': 'my-app',
'callerId': 'My App <1234>'
}
response = requests.post(f"{ari_url}/channels", json=data)
# WebSocket for events
async def handle_events():
async with websockets.connect(ws_url) as websocket:
async for message in websocket:
event = json.loads(message)
# Handle call state changes here
Any examples, documentation links, or advice would be greatly appreciated! Particularly interested in hearing from anyone who has worked with GSM gateways through ARI.
Thanks in advance!