From 82cf4d022f236bfe1a853882846ee7f59c05b49f Mon Sep 17 00:00:00 2001 From: Ludovic Gasc Date: Tue, 3 Dec 2013 11:40:03 +0100 Subject: [PATCH] Add AGI script example. --- examples/agi_script.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 examples/agi_script.py diff --git a/examples/agi_script.py b/examples/agi_script.py new file mode 100755 index 0000000..13035db --- /dev/null +++ b/examples/agi_script.py @@ -0,0 +1,22 @@ +#!/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') \ No newline at end of file