[HELP] Dialplan multiple AGI lines

Hello, i am running Asterisk 1.4.22.2

In dialplan i have custom contexts in format:

[CustomContext01-custom]
exten => s,1,NoOp()
exten => _./7778,n,AGI(rotator.php,7778)
exten => _./40016,n,AGI(rotator.php,40016)
exten => _./40007,n,AGI(rotator.php,40007)
exten => _./40005,n,AGI(rotator.php,40005)
exten => _./40004,n,AGI(rotator.php,40004)

Unfortunately i can’t make lines 4,5 and 6 work.
For example if i dial a number from phone 7778 it executes AGI script, if i dial from 40016 it executes it too.
But when i dial from 40007 it does not exec AGI.

I did a test and swapped line 4 with line 3 and AGI was working from 40007 but not working from 40016. So it always works for first 2 lines and never works for next few lines.

Is this a bug or am i doing something wrong?

Use s, rather than n, on all but the first.

Do you mean

[CustomContext01-custom] exten => s,1,NoOp() exten => _./7778,s,AGI(rotator.php,7778) exten => _./40016,s,AGI(rotator.php,40016) exten => _./40007,s,AGI(rotator.php,40007) exten => _./40005,s,AGI(rotator.php,40005) exten => _./40004,s,AGI(rotator.php,40004)

?

Do you dial from SIP,IAX or FXS end points? Show us your CLI output for success and failed calls.

–Satish Barot
Ahmedabad, India
+919978599700

Not working:

[quote]-- Executing [3235404870@CollectionContext03:1] Macro(“SIP/40004-d405ee50”, “user-callerid|SKIPTTL|”) in new stack

-- Executing [s@macro-user-callerid:1] Set("SIP/40004-d405ee50", "AMPUSER=40004") in new stack

-- Executing [s@macro-user-callerid:2] GotoIf("SIP/40004-d405ee50", "0?report") in new stack

-- Executing [s@macro-user-callerid:3] ExecIf("SIP/40004-d405ee50", "1|Set|REALCALLERIDNUM=40004") in new stack

-- Executing [s@macro-user-callerid:4] Set("SIP/40004-d405ee50", "AMPUSER=40004") in new stack

-- Executing [s@macro-user-callerid:5] Set("SIP/40004-d405ee50", "AMPUSERCIDNAME=Carlos Silva") in new stack

-- Executing [s@macro-user-callerid:6] GotoIf("SIP/40004-d405ee50", "0?report") in new stack

-- Executing [s@macro-user-callerid:7] Set("SIP/40004-d405ee50", "AMPUSERCID=40004") in new stack

-- Executing [s@macro-user-callerid:8] Set("SIP/40004-d405ee50", "CALLERID(all)="Carlos Silva" <40004>") in new stack

-- Executing [s@macro-user-callerid:9] ExecIf("SIP/40004-d405ee50", "0|Set|CHANNEL(language)=") in new stack

-- Executing [s@macro-user-callerid:10] GotoIf("SIP/40004-d405ee50", "1?continue") in new stack

-- Goto (macro-user-callerid,s,19)

-- Executing [s@macro-user-callerid:19] Set("SIP/40004-d405ee50", "CALLERID(number)=40004") in new stack

-- Executing [s@macro-user-callerid:20] Set("SIP/40004-d405ee50", "CALLERID(name)=Carlos Silva") in new stack

-- Executing [s@macro-user-callerid:21] NoOp("SIP/40004-d405ee50", "Using CallerID "Carlos Silva" <40004>") in new stack

-- Executing [3235404870@CollectionContext03:2] Set("SIP/40004-d405ee50", "_NODEST=") in new stack

-- Executing [3235404870@CollectionContext03:3] Macro("SIP/40004-d405ee50", "record-enable|40004|OUT|") in new stack

-- Executing [s@macro-record-enable:1] GotoIf("SIP/40004-d405ee50", "1?check") in new stack

-- Goto (macro-record-enable,s,4)

-- Executing [s@macro-record-enable:4] AGI("SIP/40004-d405ee50", "recordingcheck|20130914-075541|1379170541.24689") in new stack

-- Launched AGI Script /var/lib/asterisk/agi-bin/recordingcheck

recordingcheck|20130914-075541|1379170541.24689: Outbound recording not enabled

-- AGI Script recordingcheck completed, returning 0

-- Executing [s@macro-record-enable:5] MacroExit("SIP/40004-d405ee50", "") in new stack

-- Executing [3235404870@CollectionContext03:4] Macro("SIP/40004-d405ee50", "dialout-trunk|28|3235404870||") in new stack

-- Executing [s@macro-dialout-trunk:1] Set("SIP/40004-d405ee50", "DIAL_TRUNK=28") in new stack

-- Executing [s@macro-dialout-trunk:2] GosubIf("SIP/40004-d405ee50", "0?sub-pincheck|s|1") in new stack

-- Executing [s@macro-dialout-trunk:3] GotoIf("SIP/40004-d405ee50", "0?disabletrunk|1") in new stack

-- Executing [s@macro-dialout-trunk:4] Set("SIP/40004-d405ee50", "DIAL_NUMBER=3235404870") in new stack

-- Executing [s@macro-dialout-trunk:5] Set("SIP/40004-d405ee50", "DIAL_TRUNK_OPTIONS=trwW") in new stack

-- Executing [s@macro-dialout-trunk:6] Set("SIP/40004-d405ee50", "OUTBOUND_GROUP=OUT_28") in new stack

-- Executing [s@macro-dialout-trunk:7] GotoIf("SIP/40004-d405ee50", "1?nomax") in new stack

-- Goto (macro-dialout-trunk,s,9)

-- Executing [s@macro-dialout-trunk:9] GotoIf("SIP/40004-d405ee50", "0?skipoutcid") in new stack

-- Executing [s@macro-dialout-trunk:10] Set("SIP/40004-d405ee50", "DIAL_TRUNK_OPTIONS=twW") in new stack

-- Executing [s@macro-dialout-trunk:11] Macro("SIP/40004-d405ee50", "outbound-callerid|28") in new stack

-- Executing [s@macro-outbound-callerid:1] ExecIf("SIP/40004-d405ee50", "0|SetCallerPres|") in new stack

-- Executing [s@macro-outbound-callerid:2] ExecIf("SIP/40004-d405ee50", "0|Set|REALCALLERIDNUM=40004") in new stack

-- Executing [s@macro-outbound-callerid:3] NoOp("SIP/40004-d405ee50", "CIDROTATE IS ") in new stack

-- Executing [s@macro-outbound-callerid:4] GotoIf("SIP/40004-d405ee50", "1?isrotator") in new stack

-- Goto (macro-outbound-callerid,s,5)

-- Executing [s@macro-outbound-callerid:5] GotoIf("SIP/40004-d405ee50", "1?normcid") in new stack

-- Goto (macro-outbound-callerid,s,8)

-- Executing [s@macro-outbound-callerid:8] Set("SIP/40004-d405ee50", "USEROUTCID=") in new stack

-- Executing [s@macro-outbound-callerid:9] Set("SIP/40004-d405ee50", "EMERGENCYCID=") in new stack

-- Executing [s@macro-outbound-callerid:10] Set("SIP/40004-d405ee50", "TRUNKOUTCID=3234437163") in new stack

-- Executing [s@macro-outbound-callerid:11] GotoIf("SIP/40004-d405ee50", "1?trunkcid") in new stack

-- Goto (macro-outbound-callerid,s,14)

-- Executing [s@macro-outbound-callerid:14] ExecIf("SIP/40004-d405ee50", "1|Set|CALLERID(all)=3234437163") in new stack

-- Executing [s@macro-outbound-callerid:15] ExecIf("SIP/40004-d405ee50", "0|Set|CALLERID(all)=") in new stack

-- Executing [s@macro-outbound-callerid:16] ExecIf("SIP/40004-d405ee50", "0|SetCallerPres|prohib_passed_screen") in new stack

-- Executing [s@macro-dialout-trunk:12] ExecIf("SIP/40004-d405ee50", "0|AGI|fixlocalprefix") in new stack

-- Executing [s@macro-dialout-trunk:13] Set("SIP/40004-d405ee50", "OUTNUM=3235404870") in new stack

-- Executing [s@macro-dialout-trunk:14] Set("SIP/40004-d405ee50", "custom=SIP/A3234437163") in new stack

-- Executing [s@macro-dialout-trunk:15] ExecIf("SIP/40004-d405ee50", "0|Set|DIAL_TRUNK_OPTIONS=M(setmusic^)twW") in new stack

-- Executing [s@macro-dialout-trunk:16] Macro("SIP/40004-d405ee50", "dialout-trunk-predial-hook|") in new stack

-- Executing [s@macro-dialout-trunk-predial-hook:1] MacroExit("SIP/40004-d405ee50", "") in new stack

-- Executing [s@macro-dialout-trunk:17] GotoIf("SIP/40004-d405ee50", "0?bypass|1") in new stack

-- Executing [s@macro-dialout-trunk:18] GotoIf("SIP/40004-d405ee50", "0?customtrunk") in new stack

-- Executing [s@macro-dialout-trunk:19] Dial("SIP/40004-d405ee50", "SIP/A3234437163/3235404870|300|twW") in new stack

-- Called A3234437163/3235404870

-- SIP/A3234437163-dc089bf0 is making progress passing it to SIP/40004-d405ee50

-- SIP/A3234437163-dc089bf0 answered SIP/40004-d405ee50[/quote]

Working:

[quote]-- Executing [3233530718@CollectionContext05:1] Macro(“SIP/40016-d40008c0”, “user-callerid|SKIPTTL|”) in new stack

-- Executing [s@macro-user-callerid:1] Set("SIP/40016-d40008c0", "AMPUSER=40016") in new stack

-- Executing [s@macro-user-callerid:2] GotoIf("SIP/40016-d40008c0", "0?report") in new stack

-- Executing [s@macro-user-callerid:3] ExecIf("SIP/40016-d40008c0", "1|Set|REALCALLERIDNUM=40016") in new stack

-- Executing [s@macro-user-callerid:4] Set("SIP/40016-d40008c0", "AMPUSER=40016") in new stack

-- Executing [s@macro-user-callerid:5] Set("SIP/40016-d40008c0", "AMPUSERCIDNAME=Karen Montoya") in new stack

-- Executing [s@macro-user-callerid:6] GotoIf("SIP/40016-d40008c0", "0?report") in new stack

-- Executing [s@macro-user-callerid:7] Set("SIP/40016-d40008c0", "AMPUSERCID=40016") in new stack

-- Executing [s@macro-user-callerid:8] Set("SIP/40016-d40008c0", "CALLERID(all)="Karen Montoya" <40016>") in new stack

-- Executing [s@macro-user-callerid:9] ExecIf("SIP/40016-d40008c0", "0|Set|CHANNEL(language)=") in new stack

-- Executing [s@macro-user-callerid:10] GotoIf("SIP/40016-d40008c0", "1?continue") in new stack

-- Goto (macro-user-callerid,s,19)

-- Executing [s@macro-user-callerid:19] Set("SIP/40016-d40008c0", "CALLERID(number)=40016") in new stack

-- Executing [s@macro-user-callerid:20] Set("SIP/40016-d40008c0", "CALLERID(name)=Karen Montoya") in new stack

-- Executing [s@macro-user-callerid:21] NoOp("SIP/40016-d40008c0", "Using CallerID "Karen Montoya" <40016>") in new stack

-- Executing [3233530718@CollectionContext05:2] Set("SIP/40016-d40008c0", "_NODEST=") in new stack

-- Executing [3233530718@CollectionContext05:3] AGI("SIP/40016-d40008c0", "rotator.php|40016") in new stack

-- Launched AGI Script /var/lib/asterisk/agi-bin/rotator.php

rotator.php|40016: CIDROTATE = ON, extension = 40016 New CID = 2138161773

-- AGI Script rotator.php completed, returning 0

-- Executing [3233530718@CollectionContext05:4] Macro("SIP/40016-d40008c0", "dialout-trunk|22|3233530718||") in new stack

-- Executing [s@macro-dialout-trunk:1] Set("SIP/40016-d40008c0", "DIAL_TRUNK=22") in new stack

-- Executing [s@macro-dialout-trunk:2] GosubIf("SIP/40016-d40008c0", "0?sub-pincheck|s|1") in new stack

-- Executing [s@macro-dialout-trunk:3] GotoIf("SIP/40016-d40008c0", "0?disabletrunk|1") in new stack

-- Executing [s@macro-dialout-trunk:4] Set("SIP/40016-d40008c0", "DIAL_NUMBER=3233530718") in new stack

-- Executing [s@macro-dialout-trunk:5] Set("SIP/40016-d40008c0", "DIAL_TRUNK_OPTIONS=trwW") in new stack

-- Executing [s@macro-dialout-trunk:6] Set("SIP/40016-d40008c0", "OUTBOUND_GROUP=OUT_22") in new stack

-- Executing [s@macro-dialout-trunk:7] GotoIf("SIP/40016-d40008c0", "1?nomax") in new stack

-- Goto (macro-dialout-trunk,s,9)

-- Executing [s@macro-dialout-trunk:9] GotoIf("SIP/40016-d40008c0", "0?skipoutcid") in new stack

-- Executing [s@macro-dialout-trunk:10] Set("SIP/40016-d40008c0", "DIAL_TRUNK_OPTIONS=twW") in new stack

-- Executing [s@macro-dialout-trunk:11] Macro("SIP/40016-d40008c0", "outbound-callerid|22") in new stack

-- Executing [s@macro-outbound-callerid:1] ExecIf("SIP/40016-d40008c0", "0|SetCallerPres|") in new stack

-- Executing [s@macro-outbound-callerid:2] ExecIf("SIP/40016-d40008c0", "1|Set|REALCALLERIDNUM=2138161773") in new stack

-- Executing [s@macro-outbound-callerid:3] NoOp("SIP/40016-d40008c0", "CIDROTATE IS ON") in new stack

-- Executing [s@macro-outbound-callerid:4] GotoIf("SIP/40016-d40008c0", "1?isrotator") in new stack

-- Goto (macro-outbound-callerid,s,5)

-- Executing [s@macro-outbound-callerid:5] GotoIf("SIP/40016-d40008c0", "0?normcid") in new stack

-- Executing [s@macro-outbound-callerid:6] Set("SIP/40016-d40008c0", "USEROUTCID=2138161773") in new stack

-- Executing [s@macro-outbound-callerid:7] GotoIf("SIP/40016-d40008c0", "1?bypass") in new stack

-- Goto (macro-outbound-callerid,s,9)

-- Executing [s@macro-outbound-callerid:9] Set("SIP/40016-d40008c0", "EMERGENCYCID=") in new stack

-- Executing [s@macro-outbound-callerid:10] Set("SIP/40016-d40008c0", "TRUNKOUTCID=3234171497") in new stack

-- Executing [s@macro-outbound-callerid:11] GotoIf("SIP/40016-d40008c0", "1?trunkcid") in new stack

-- Goto (macro-outbound-callerid,s,14)

-- Executing [s@macro-outbound-callerid:14] ExecIf("SIP/40016-d40008c0", "1|Set|CALLERID(all)=3234171497") in new stack

-- Executing [s@macro-outbound-callerid:15] ExecIf("SIP/40016-d40008c0", "1|Set|CALLERID(all)=2138161773") in new stack

-- Executing [s@macro-outbound-callerid:16] ExecIf("SIP/40016-d40008c0", "0|SetCallerPres|prohib_passed_screen") in new stack

-- Executing [s@macro-dialout-trunk:12] ExecIf("SIP/40016-d40008c0", "1|AGI|fixlocalprefix") in new stack

-- Launched AGI Script /var/lib/asterisk/agi-bin/fixlocalprefix

== fixlocalprefix: Dialpattern NXXNXXXXXX matched. 3233530718 -> 3233530718

-- AGI Script fixlocalprefix completed, returning 0

-- Executing [s@macro-dialout-trunk:13] Set("SIP/40016-d40008c0", "OUTNUM=3233530718") in new stack

-- Executing [s@macro-dialout-trunk:14] Set("SIP/40016-d40008c0", "custom=SIP/A3234171497") in new stack

-- Executing [s@macro-dialout-trunk:15] ExecIf("SIP/40016-d40008c0", "0|Set|DIAL_TRUNK_OPTIONS=M(setmusic^)twW") in new stack

-- Executing [s@macro-dialout-trunk:16] Macro("SIP/40016-d40008c0", "dialout-trunk-predial-hook|") in new stack

-- Executing [s@macro-dialout-trunk-predial-hook:1] MacroExit("SIP/40016-d40008c0", "") in new stack

-- Executing [s@macro-dialout-trunk:17] GotoIf("SIP/40016-d40008c0", "0?bypass|1") in new stack

-- Executing [s@macro-dialout-trunk:18] GotoIf("SIP/40016-d40008c0", "0?customtrunk") in new stack

-- Executing [s@macro-dialout-trunk:19] Dial("SIP/40016-d40008c0", "SIP/A3234171497/3233530718|300|twW") in new stack

-- Called A3234171497/3233530718

-- SIP/A3234171497-08a1e480 is making progress passing it to SIP/40016-d40008c0

-- SIP/A3234171497-08a1e480 is making progress passing it to SIP/40016-d40008c0

-- SIP/A3234171497-08a1e480 is making progress passing it to SIP/40016-d40008c0

-- SIP/A3234171497-08a1e480 is making progress passing it to SIP/40016-d40008c0

-- SIP/A3234171497-08a1e480 answered SIP/40016-d40008c0[/quote]

In working example, AGI script is called: AGI(“SIP/40016-d40008c0”, “rotator.php|40016”)

Any of the calls doesn’t come into ‘CustomContext01-custom’ context. Do you manage Asterisk system through any web UI?
If no then, Change the value of ‘contexts’ parameter to ‘CustomContext01-custom’ for 7778,40016,40007,40005 and 40004 in sip.conf and update CustomContext01-custom as below. I assume you want to execute only relevant AGI for each SIP extension.

[CustomContext01-custom]
exten => _./7778,1,AGI(rotator.php,7778)
exten => _./40016,1,AGI(rotator.php,40016)
exten => _./40007,1,AGI(rotator.php,40007)
exten => _./40005,1,AGI(rotator.php,40005)
exten => _./40004,1,AGI(rotator.php,40004)

–Satish Barot
Ahmedabad, India
+919978599700

[quote=“mde_miro”]Do you mean

[CustomContext01-custom] exten => s,1,NoOp() exten => _./7778,s,AGI(rotator.php,7778) exten => _./40016,s,AGI(rotator.php,40016) exten => _./40007,s,AGI(rotator.php,40007) exten => _./40005,s,AGI(rotator.php,40005) exten => _./40004,s,AGI(rotator.php,40004)

?[/quote]

Yes. You want all the variants to have the same priority number.