pyst2/examples/agi_script.py

22 lines
439 B
Python
Executable File

#!/usr/bin/python
"""
Example to get and set variables via AGI.
You can call directly this script with AGI() in Asterisk dialplan.
"""
from asterisk.agi import *
agi = AGI()
agi.verbose("python agi started")
# Get variable environment
extension = agi.env['agi_extension']
# Get variable in dialplan
phone_exten = agi.get_variable('PHONE_EXTEN')
# Set variable, it will be available in dialplan
agi.set_variable('EXT_CALLERID', '1')