[asterisk-users] IF else
Atis Lezdins
atis at iq-labs.net
Wed Nov 19 11:04:02 CST 2008
On Wed, Nov 19, 2008 at 6:51 PM, Steve Edwards
<asterisk.org at sedwards.com> wrote:
> On Wed, 19 Nov 2008, Atis Lezdins wrote:
>
>> 1) Start using AEL (remove this context from extensions.conf and add
>> to extensions.ael):
>>
>> context a2billing {
>> _X. => {
>> if("${EXTEN}"="111") {
>> Playback(AR_GetGiveToID);
>> Wait(2);
>> Record(/tmp/asterisk-recording:ulaw,,5);
>> Wait(2);
>> Playback(/tmp/asterisk-recording);
>> Wait(2);
>> Hangup();
>> } else if("${EXTEN}"="112") {
>> Playback(AR_GetGiveToID);
>> Wait(2);
>> Record(/tmp/asterisk-recording:ulaw,,5);
>> Wait(2);
>> Playback(/tmp/asterisk-recording);
>> Wait(2);
>> Hangup();
>> } else {
>> DeadAGI(a2billing.php);
>> Wait(2)
>> Hangup();
>> }
>> }
>
> You're missing a couple of "semi-colons."
Sorry, that was untested "proof of options" :)
>
>> 2) Start using extension masks (also works with AEL):
>>
>> [a2billing]
>> exten => _111,1,Noop(Dialled 111)
>> exten => _111,n,Playback(AR_GetGiveToID)
>> exten => _111,n,Wait(2)
>> exten => _111,n,Record(/tmp/asterisk-recording:ulaw,,5)
>> exten => _111,n,Wait(2)
>> exten => _111,n,Playback(/tmp/asterisk-recording)
>> exten => _111,n,Wait(2)
>> exten => _111,n,Hangup
>>
>> exten => _112,1,Noop(Dialed 112)
>> exten => _112,n,Playback(AR_GetGiveToID)
>> exten => _112,n,Wait(2)
>> exten => _112,n,Record(/tmp/asterisk-recording:ulaw,,5)
>> exten => _112,n,Wait(2)
>> exten => _112,n,Playback(/tmp/asterisk-recording)
>> exten => _112,n,Wait(2)
>> exten => _112,n,Hangup
>>
>> exten => _X.,1,Noop(Didn't dial 111 or 112)
>> exten => _X.,n,DeadAGI,a2billing.php
>> exten => _X.,n,Wait,2
>> exten => _X.,n,Hangup
>
> And, just in case the 2 extensions really are supposed to do the exact
> same thing, use extension pattern matching:
>
> context a2billing
> {
> _11[12] =
> {
> playback(AR_GetGiveToID);
> wait(2);
> record(/tmp/asterisk-recording:ulaw,,5);
> wait(2);
> playback(/tmp/asterisk-recording);
> wait(2);
> hangup();
> };
> _x. =
> {
> deadagi(a2billing.php);
> wait(2);
> hangup();
> };
> };
>
> (The above is my first attempt at AEL. It parses, but it hasn't actually
> been tested.)
>
> I would question the use of deadagi() in a "non-h" extension. Are signals
> not being trapped correctly in a2billing.php?
>
AFAIK that's how a2billing is built, it's intentionally DeadAGI on
live channel. Ugly hack that gives warnings all the time in logs, but
it works and seems to provide correct billing info :)
Regards,
Atis
--
Atis Lezdins,
VoIP Project Manager / Developer,
IQ Labs Inc,
atis at iq-labs.net
Skype: atis.lezdins
Cell Phone: +371 28806004
Cell Phone: +1 800 7300689
Work phone: +1 800 7502835
More information about the asterisk-users
mailing list