Vous êtes sur la page 1sur 11

Asterisk AGI

Th.S L H MINH

Interactive Voice Response - IVR

A technology that allows a computer to interact with humans through the use of voice and DTMF tones input via keypad (Wikipedia)
Cm n qu khch gi n trung tm d bo thi tit. nghe thng tin thi tit H Ni bm phm 1, Tp. HCM bm phm 2, Tp. Nng bm phm 3 Press <2>

Thi tit ti Tp. HCM tri nhiu my, khng ma, nhit l 39 C

Dialplan

Finite State Machines

CLI core show applications core show application NoOp

Syntax

exten => some_extension, priority(alias),application(arg1, arg2, arg3)


The serial priority of the directive; the first directive is always set to "1"; the following ones are set to "n"; the "alias" may be used as a label to the specific directive location The application to be executed, with its related arguments

The name or dialled number or dialled pattern of the extension

Automatic Call Distribution - ACD

Asterisk Gateway Interface - AGI

How does AGI work?

Language Family
Binary Compiled Virtual Machine Interpreted

Member Languages
C, C++, Pascal Java, C#, Mono PERL, PHP, Python, Ruby

AGI

exten => _X.,1,AGI(some_script_name.agi,param1,param2,param3)


exten => h,1,DeadAGI(some_script_name.agi,param1,param2,param3) exten => _X.,1,AGI(agi://IP_NUMBER:PORT/some_script_name.agi)

DeadAGI
FastAGI

The AGI execution flow

CLI agi show commands


stream file wait for digit Sends audio file on channel Waits for a digit to be pressed

say digits
say number

Says a given digit string


Says a given number

exten => _X.,1,Answer exten => _X.,n,Set(DID=${EXTEN})

exten => _X.,n,Set(CLID=${CALLERID(num)})


exten => _X.,n,AGI(SomeScript.php)

AGI Scripting with PHP

AGI script permissions


/var/lib/asterisk/agi-bin chmod 755 /var/lib/asterisk/agi-bin/*.php

agi_hellowold.php

Dialplan
exten => 999,1,Answer exten => 999,n,Wait(0.5) exten => 999,n,AGI(helloworld.php) exten => 999,n,Hangup() CLI agi set debug on

agi set debug off

PHPAGI: An AGI Class Library in PHP

http://phpagi.sourceforge.net/

Connect to WebServices

PHP Soap Client


yum install php


yum install php-soap

$ini = ini_set("soap.wsdl_cache_enabled","0"); $client = new SoapClient(" http://www.webservicex.com/currencyconvertor.asmx?WSDL"); $param = array('arrBytes' => $data); $result = $client->HelloWorldWebMethod($param)-> HelloWorldWebMethodResult;

References

http://www.asterisk.org http://www.asterisk.org/downloads/asterisknow

http://www.voip-info.org/wiki/view/Asterisk
http://www.asteriskguru.com https://wiki.asterisk.org/wiki/display/AST/Asterisk+1.8+Docum entation

Vous aimerez peut-être aussi