[asterisk-users] IF else
Atis Lezdins
atis at iq-labs.net
Wed Nov 19 09:12:51 CST 2008
On Wed, Nov 19, 2008 at 4:05 PM, Gordon Henderson
<gordon+asterisk at drogon.net> wrote:
> On Wed, 19 Nov 2008, michel freiha wrote:
>
>> Hi all,
>>
>> I have the following context in extensions.conf:
>>
>> [a2billing]
>> exten => _X.,1,Gotoif($[${EXTEN} = 111] ? 21)
>> exten => _X.,2,DeadAGI,a2billing.php
>> exten => _X.,3,Wait,2
>> exten => _X.,4,Hangup
>> exten => _X.,21,Playback(AR_GetGiveToID)
>> exten => _X.,22,Wait(2)
>> exten => _X.,23,Record(/tmp/asterisk-recording:ulaw,,5)
>> exten => _X.,24,Wait(2)
>> exten => _X.,25,Playback(/tmp/asterisk-recording)
>> exten => _X.,26,Wait(2)
>> exten => _X.,27,Hangup
>>
>> If the customer dial 111, it'll be router to the entry with priority 21,
>> else it'll go to priority 2...I would like to add a third condition that if
>> the user dial let's say 112 it'll go to the priority 28 let's say
>
> 1. Stop using numbers.
> 2. Start using labels.
> 3. Add comments.
>
> exten => _X.,1,Gotoif($[${EXTEN} = 111]?exten111)
> exten => _X.,n,Gotoif($[${EXTEN} = 112]?exten112)
>
> exten => _X.,n,Noop(Didn't dial 111 or 112)
> exten => _X.,n,DeadAGI,a2billing.php
> exten => _X.,n,Wait,2
> exten => _X.,n,Hangup
>
> exten => _X.,n(exten111),Noop(Dialled 111)
> exten => _X.,n,Playback(AR_GetGiveToID)
> exten => _X.,n,Wait(2)
> exten => _X.,n,Record(/tmp/asterisk-recording:ulaw,,5)
> exten => _X.,n,Wait(2)
> exten => _X.,n,Playback(/tmp/asterisk-recording)
> exten => _X.,n,Wait(2)
> exten => _X.,n,Hangup
>
> exten => _X.,n(exten112),Noop(Dialed 112)
> exten => _X.,n,Playback(AR_GetGiveToID)
> exten => _X.,n,Wait(2)
> exten => _X.,n,Record(/tmp/asterisk-recording:ulaw,,5)
> exten => _X.,n,Wait(2)
> exten => _X.,n,Playback(/tmp/asterisk-recording)
> exten => _X.,n,Wait(2)
> exten => _X.,n,Hangup
>
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();
}
}
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
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