Cant call out using TDM400. Frustrated.

castrox
Posts: 13
Member Since:
2008-04-23

I'm fairly new to this all, but have gotten plenty far on my own. Now I'm trying to hook up some analog lines and seem to just keep running into problems. Ive got a TDM400 card with one FXO module. I'm trying to hook one line up to it and make calls in and out. I can so far make calls in, but not out; it rings briefly on the trixbox side, then says "All circuits busy" and hangs up. Ive tried everything I can think of and nothing has helped. I'm running version 2.6.18-53.

I'm a bit confused how the trunks work - apparently i don't need one for inbound calls if I assign the channel a DID? Thats how I've gotten to call out, but I'm not sure how/if I can apply that to outbound calls.



KodaK
Posts: 1885
Member Since:
2006-06-14
Please see the dentists

Please see the dentists thread in the help forum. It contains instructions that will help you collect information that will help us help you.

And to call out you do need a trunk for outbound calls, plus you need an outbound route that uses that trunk.

I hardly ever use analog trunks, so I'm probably the wrong guy to ask for detail, but if you supply more information, specifically logs, we can probably play "spot the clue".

--

WARNING: I no longer actively participate in these forums. My thoughts on trixbox in a nutshell: http://www.youtube.com/watch?v=q4xBMkWu1pE Use AsteriskNOW instead.



castrox
Posts: 13
Member Since:
2008-04-23
dentists

2) any relevant logs.
-Not even sure whats relevant, as i do not know where to start. I could just give you everything, but if you could point me in the right direction, this would move a bit smoother.

3) relevant configuration files and/or configurations in FreePBX
extensions.conf? zap files? all of the above? again, i dont know where to start.

4) your system stats (server hardware)
Compaq desktop, 2.8GHz, 1GB of RAM, 80GB HDD. I can get you model numbers and such if you need them, but i'm not near the hardware right now.

5) end point type (software phone, hardware phone, make, model, etc)
Im using a mix of Cisco 7970, 7960, 7940 and 7912 phones, along with spectralink i640 phones.

6) VoIP codecs in use
g711a

7) VoIP protocols in use
SIP

8) network topology
I am doing this on an isolated network for the time being, mostly as a result of uncooperative IT people. It goes something like this: pot>proxy>switch>[spectralink proxy>wirelessphones][cisco phones]

9) a more detailed explanation of the problem, with examples if possible
I think i've descibed it as well I can.

10) if there are error messages, please post the exact message.
Just the "all circuits are busy" message.

11) a list of things you have already tried, and the results
Ive tried creating trunks and routes and everytihng LOOKS like it should work - the trunk says its in use by the route in freePBX and everything. Ive reconfigured the zaptel drivers many times, and nothing changes. I've tried adding dial rules and deleting them, looked at every option and made sure it didn't affect the call somehow. Like I said, i can call in, just not out. I must be missing something somewhere, i just dont know where to look.

I will try to get a copy of what happens in the CLI when i call out and in, but I cant get there from here.



castrox
Posts: 13
Member Since:
2008-04-23
Ive looked at what it says

Ive looked at what it says when i try to call out, and its giving CHANUNAVAIL errors. Does that help?



KodaK
Posts: 1885
Member Since:
2006-06-14
Have you created an outbound

Have you created an outbound route that points to your Zap trunk?

Also, post (preferably at pastebin.com) a complete call log from the cli when you try to make an outbound call.

--

WARNING: I no longer actively participate in these forums. My thoughts on trixbox in a nutshell: http://www.youtube.com/watch?v=q4xBMkWu1pE Use AsteriskNOW instead.



Stereo
Posts: 35
Member Since:
2006-07-28
Seems to be a bug

I've got this exact same problem, and have seen a few other posts about it on the forum, but so far no resolutions. Some people seem to think it is a problem with the current version of Zaptel.

I've got a brand new 2.6.0.7 install with a Digium TDM400P card (2 fxo, 1 fxs). This card works perfectly on the production Trixbox 1.2.3 system.

Equipment is a Celeron D 2.8Ghz, 1 GB ram, 40GB HD, etc... plenty of horsepower to run my small phone system. I've even pulled off the shelf an HP DL380 and a DL360 to make sure I was using 'approved' hardware, and the problem still exists.

Inbound calls work perfect. Extension to extension works perfect. Outbound calls fail everytime with an "All Circuits Are Busy" response. I would paste log files, but honestly, I had to revert back to Trixbox 1.2.3 (hd swap) to get the system functional again and I didn't save my putty logs.

Any help would be greatly appreciated.
Chris



rrust
Posts: 36
Member Since:
2007-11-19
I have the same problem,

I have the same problem, I've added trunks, removed them till I was blue in the face. Ended up installing elastix on one of our installations, and had the same problem -lol

I ended up only being able to use one outgoing analog line, I did this by adding zap channel 1 and 2 and then using those as the outgoing. for some reason it only lets you use one though. i left the g0 in as well.

also, I *think* I had to change the context someplace to zaptel, at this point I am not sure..has anyone checked the bug tracker for the zap drivers?

only good thing to come out of this is experiencing elastix, i think it has some real potential..



castrox
Posts: 13
Member Since:
2008-04-23
Everything we've done is the

Everything we've done is the same - its configured properly but will not work. Can i install an older version of trixbox to get this working? i need six lines, and i cant settle for half assing it.



castrox
Posts: 13
Member Since:
2008-04-23
Yes, i have created one.

Yes, i have created one. Repeatedly. Read the long post in response to your dentists bit.



KodaK
Posts: 1885
Member Since:
2006-06-14
I've asked more than once to

I've asked more than once to see your logs, without the logs (which is the first place I'd go to troubleshoot) all I can do is make guesses.

I don't ask for them to make busy work for you, I ask for them because it's the only source of information available to me that's not colored by your own prejudices. I can't rely on you to give me correct information, but I can probably rely on you to send me unmolested logs. I certainly can't guarantee that by seeing your logs that I can help you, but I can state definitively that without seeing them I can't.

But, beyond that, I'm helping here because I want to, and I shouldn't have to beg someone who's asking for help to provide basic information, so I'm just going to step out now.

--

WARNING: I no longer actively participate in these forums. My thoughts on trixbox in a nutshell: http://www.youtube.com/watch?v=q4xBMkWu1pE Use AsteriskNOW instead.



castrox
Posts: 13
Member Since:
2008-04-23
2) any relevant logs. -Not

2) any relevant logs.
-Not even sure whats relevant, as i do not know where to start. I could just give you everything, but if you could point me in the right direction, this would move a bit smoother.

I will get the output from the CLI as soon as i am able, but as of right now, i don't have any way of doing that. If you could please re read my post and respond to my questions, i may be able to just give you the information you need. As i have said once already, you can see where it breaks in the CLI, and at that point it starts saying CHANUNAVAIL. The server is on a physically different network and i dont have an easy way of getting between the two. I will go read it again and describe it better, but that is the best i can do for now. Please lose the righteousness.



Peter847
Posts: 41
Member Since:
2007-09-14
"All circuits are busy"

I have exactly the same problem & it has the CHANUNAVAIL error. I did a clean install of trixbox 2.4, setup a single trunk & extension & it worked fine. Exactly the same procedure for trixbox 2.6 gives the error message. I posted a few times but got zero responses so I've gone back to the 2.4 version.

KodaK - I have seen many of your posts helping fix problems before, thank you . . . could you contribute here as well? Unfortunately I can't take my system down to relaod 2.6 for a few days but I'm willing to help then - as long as I get idiot proof instructions!

Peter



pblythswood
Posts: 38
Member Since:
2006-06-01
I'm running 2.6.0.7 without

I'm running 2.6.0.7 without any problems with tdm400. My zapata.conf file may be different though as I set up individual channels/groups, so I can test each channel individually as I only have 1 test line, but for production I route out via the individual groups, ie, g1, g2,g3, g4.

All work currently on 2.6.0.7.

Hope this helps.

Paul



KodaK
Posts: 1885
Member Since:
2006-06-14
I can't help in a vacuum. I

I can't help in a vacuum. I can provide idiot proof instructions for capturing logs, but I'd just be repeating what I typed out in the dentist's thread, which is why I created it in the first place: I got tired of saying "please post logs" every time someone posts a request for help.

Again, I can't guarantee anything at all. I have exactly one analog card sitting in a system in Kansas City that's currently unused, and a spare that if I have time I can put in my demo box (that's currently running 2.6.0.something.) But, if given some logs to work with I might be able to spot something. Maybe.

--

WARNING: I no longer actively participate in these forums. My thoughts on trixbox in a nutshell: http://www.youtube.com/watch?v=q4xBMkWu1pE Use AsteriskNOW instead.



KodaK
Posts: 1885
Member Since:
2006-06-14
Because I'm way nicer than I

Because I'm way nicer than I should be:

I went ahead and plugged in my spare TDM412E to my demo box, and these are the steps I followed:

1) booted with card installed.

2) logged in as root.

3) typed "setup-pstn"

4) checked /etc/zaptel.conf, was not configured

5) ran genzaptelconf

6) checked /etc/zaptel.conf, and it was configured correctly, as far as I can tell.

# Span 1: WCTDM/0 "Wildcard TDM410P Board 1" (MASTER)
fxoks=1
fxsks=2
fxsks=3
# channel 4, WCTDM, no module.

# Global data

loadzone        = us
defaultzone     = us

7) ran ztcfg -vvvv

Zaptel Version: 1.4.9.2
Echo Canceller: OSLEC
Configuration
======================


Channel map:

Channel 01: FXO Kewlstart (Default) (Slaves: 01)
Channel 02: FXS Kewlstart (Default) (Slaves: 02)
Channel 03: FXS Kewlstart (Default) (Slaves: 03)

3 channels to configure.

8) restarted asterisk: "amportal restart"

9) configured freepbx: the only change was to the single outbound route I had configured, I replaced the existing SIP trunk with the Zap trunk.

10) placed outbound call with no problem.

11) tested inbound call, got a failure because I didn't have a catchall DID set

12) created catchall DID

13) made inbound test call, connected.

14) made two inbound test calls, both FXO ports work on inbound.

15) made two outbound test calls, both FXO ports work on outbound.

I'm pretty sure I didn't leave anything out.

The trixbox sysinfo page says:

Quote:
trixbox CE current release is 2.6.0.7
--

WARNING: I no longer actively participate in these forums. My thoughts on trixbox in a nutshell: http://www.youtube.com/watch?v=q4xBMkWu1pE Use AsteriskNOW instead.



Peter847
Posts: 41
Member Since:
2007-09-14
TDM400P

Kodak

Many thanks for your help. It will be the weekend before I can take down my 2.4 system and install 2.6 but I will post the logs when I can. Being somewhat of a newbie I've usually followed the "trixbox without tears" guide for my setup but I do not remember seeing the "setup-pstn" command - am I missing something here?

Peter



KodaK
Posts: 1885
Member Since:
2006-06-14
I don't remember when they

I don't remember when they introduced it, but it's pretty recent. I'm pretty sure it was in 2.4. Not entirely, though.

I checked the script and it's dated December of 2007, so it's almost 5 months old. Also, it's a pretty simple script, and it's supposed to call genzaptelconf from within it, so I'm not sure why it failed to actually generate the config files. Regardless, calling genzaptelconf directly did, so I'm cool with that.

--

WARNING: I no longer actively participate in these forums. My thoughts on trixbox in a nutshell: http://www.youtube.com/watch?v=q4xBMkWu1pE Use AsteriskNOW instead.



castrox
Posts: 13
Member Since:
2008-04-23
I've followed it exactly and

I've followed it exactly and still nothing. I reinstalled on a fresh system and tried there with no luck. I will have the requested logs up today, as well as the zap conf files.

Thanks
Cullen



KodaK
Posts: 1885
Member Since:
2006-06-14
While you're at it, post

While you're at it, post your zaptel.conf and zapata*.conf files (all of them, unless they're empty or all comments.)

Please remember to use code tags.

--

WARNING: I no longer actively participate in these forums. My thoughts on trixbox in a nutshell: http://www.youtube.com/watch?v=q4xBMkWu1pE Use AsteriskNOW instead.



castrox
Posts: 13
Member Since:
2008-04-23
The logs and conf files

Here are the logs and conf files

putty output CHANUNAVAIL ERROR

-- Executing [s@macro-record-enable:5] NoOp("SIP/10-0847f9a8", "No recording needed") in new stack
-- Executing [6122266694@from-internal:4] Macro("SIP/10-0847f9a8", "dialout-trunk|2|6122266694||") in new stack
-- Executing [s@macro-dialout-trunk:1] Set("SIP/10-0847f9a8", "DIAL_TRUNK=2") in new stack
-- Executing [s@macro-dialout-trunk:2] ExecIf("SIP/10-0847f9a8", "0|Authenticate|") in new stack
-- Executing [s@macro-dialout-trunk:3] GotoIf("SIP/10-0847f9a8", "0?disabletrunk|1") in new stack
-- Executing [s@macro-dialout-trunk:4] Set("SIP/10-0847f9a8", "DIAL_NUMBER=6122266694") in new stack
-- Executing [s@macro-dialout-trunk:5] Set("SIP/10-0847f9a8", "DIAL_TRUNK_OPTIONS=tr") in new stack
-- Executing [s@macro-dialout-trunk:6] Set("SIP/10-0847f9a8", "GROUP()=OUT_2") in new stack
-- Executing [s@macro-dialout-trunk:7] GotoIf("SIP/10-0847f9a8", "0?nomax") in new stack
-- Executing [s@macro-dialout-trunk:8] GotoIf("SIP/10-0847f9a8", "0?chanfull") in new stack
-- Executing [s@macro-dialout-trunk:9] GotoIf("SIP/10-0847f9a8", "0?skipoutcid") in new stack
-- Executing [s@macro-dialout-trunk:10] Set("SIP/10-0847f9a8", "DIAL_TRUNK_OPTIONS=") in new stack
-- Executing [s@macro-dialout-trunk:11] Macro("SIP/10-0847f9a8", "outbound-callerid|2") in new stack
-- Executing [s@macro-outbound-callerid:1] GotoIf("SIP/10-0847f9a8", "1?start") in new stack
-- Goto (macro-outbound-callerid,s,3)
-- Executing [s@macro-outbound-callerid:3] NoOp("SIP/10-0847f9a8", "REALCALLERIDNUM is 10") in new stack
-- Executing [s@macro-outbound-callerid:4] GotoIf("SIP/10-0847f9a8", "1?normcid") in new stack
-- Goto (macro-outbound-callerid,s,9)
-- Executing [s@macro-outbound-callerid:9] Set("SIP/10-0847f9a8", "USEROUTCID="test cid" ") in new stack
-- Executing [s@macro-outbound-callerid:10] Set("SIP/10-0847f9a8", "EMERGENCYCID=") in new stack
-- Executing [s@macro-outbound-callerid:11] Set("SIP/10-0847f9a8", "TRUNKOUTCID="Asset Recovery Corp" ") in new stack
-- Executing [s@macro-outbound-callerid:12] GotoIf("SIP/10-0847f9a8", "1?trunkcid") in new stack
-- Goto (macro-outbound-callerid,s,16)
-- Executing [s@macro-outbound-callerid:16] GotoIf("SIP/10-0847f9a8", "0?usercid") in new stack
-- Executing [s@macro-outbound-callerid:17] Set("SIP/10-0847f9a8", "CALLERID(all)=Asset Recovery Corp ") in new stack
-- Executing [s@macro-outbound-callerid:18] GotoIf("SIP/10-0847f9a8", "0?report") in new stack
-- Executing [s@macro-outbound-callerid:19] Set("SIP/10-0847f9a8", "CALLERID(all)=test cid ") in new stack
-- Executing [s@macro-outbound-callerid:20] GotoIf("SIP/10-0847f9a8", "1?report:hidecid") in new stack
-- Goto (macro-outbound-callerid,s,22)
-- Executing [s@macro-outbound-callerid:22] NoOp("SIP/10-0847f9a8", "CallerID set to "test cid" ") in new stack
-- Executing [s@macro-dialout-trunk:12] AGI("SIP/10-0847f9a8", "fixlocalprefix") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/fixlocalprefix
-- AGI Script fixlocalprefix completed, returning 0
-- Executing [s@macro-dialout-trunk:13] Set("SIP/10-0847f9a8", "OUTNUM=6122266694") in new stack
-- Executing [s@macro-dialout-trunk:14] Set("SIP/10-0847f9a8", "custom=ZAP/4") in new stack
-- Executing [s@macro-dialout-trunk:15] GotoIf("SIP/10-0847f9a8", "1?gocall") in new stack
-- Goto (macro-dialout-trunk,s,17)
-- Executing [s@macro-dialout-trunk:17] Macro("SIP/10-0847f9a8", "dialout-trunk-predial-hook|") in new stack
-- Executing [s@macro-dialout-trunk:18] GotoIf("SIP/10-0847f9a8", "0?bypass|1") in new stack
-- Executing [s@macro-dialout-trunk:19] GotoIf("SIP/10-0847f9a8", "0?customtrunk") in new stack
-- Executing [s@macro-dialout-trunk:20] Dial("SIP/10-0847f9a8", "ZAP/4/6122266694|300|") in new stack
-- Called 4/6122266694
-- Hungup 'Zap/4-1'
== Everyone is busy/congested at this time (1:0/0/1)
-- Executing [s@macro-dialout-trunk:21] Goto("SIP/10-0847f9a8", "s-CHANUNAVAIL|1") in new stack
-- Goto (macro-dialout-trunk,s-CHANUNAVAIL,1)
-- Executing [s-CHANUNAVAIL@macro-dialout-trunk:1] GotoIf("SIP/10-0847f9a8", "1?noreport") in new stack
-- Goto (macro-dialout-trunk,s-CHANUNAVAIL,3)
-- Executing [s-CHANUNAVAIL@macro-dialout-trunk:3] NoOp("SIP/10-0847f9a8", "TRUNK Dial failed due to CHANUNAVAIL - failing through to other trunks") in new stack
-- Executing [6122266694@from-internal:5] Macro("SIP/10-0847f9a8", "outisbusy|") in new stack
-- Executing [s@macro-outisbusy:1] Playback("SIP/10-0847f9a8", "all-circuits-busy-now|noanswer") in new stack
-- Playing 'all-circuits-busy-now' (language 'en')
== Spawn extension (macro-outisbusy, s, 1) exited non-zero on 'SIP/10-0847f9a8' in macro 'outisbusy'
== Spawn extension (macro-outisbusy, s, 1) exited non-zero on 'SIP/10-0847f9a8'

WORKING SIP TO SIP CALL INTERNAL

-- Executing [10@from-internal:1] Macro("SIP/62-08466ca8", "exten-vm|novm|10") in new stack
-- Executing [s@macro-exten-vm:1] Macro("SIP/62-08466ca8", "user-callerid") in new stack
-- Executing [s@macro-user-callerid:1] NoOp("SIP/62-08466ca8", "user-callerid: device 62") in new stack
-- Executing [s@macro-user-callerid:2] Set("SIP/62-08466ca8", "AMPUSER=62") in new stack
-- Executing [s@macro-user-callerid:3] GotoIf("SIP/62-08466ca8", "0?report") in new stack
-- Executing [s@macro-user-callerid:4] ExecIf("SIP/62-08466ca8", "1|Set|REALCALLERIDNUM=62") in new stack
-- Executing [s@macro-user-callerid:5] NoOp("SIP/62-08466ca8", "REALCALLERIDNUM is 62") in new stack
-- Executing [s@macro-user-callerid:6] Set("SIP/62-08466ca8", "AMPUSER=62") in new stack
-- Executing [s@macro-user-callerid:7] Set("SIP/62-08466ca8", "AMPUSERCIDNAME=EbayTest") in new stack
-- Executing [s@macro-user-callerid:8] GotoIf("SIP/62-08466ca8", "0?report") in new stack
-- Executing [s@macro-user-callerid:9] Set("SIP/62-08466ca8", "AMPUSERCID=62") in new stack
-- Executing [s@macro-user-callerid:10] Set("SIP/62-08466ca8", "CALLERID(all)="EbayTest" ") in new stack
-- Executing [s@macro-user-callerid:11] Set("SIP/62-08466ca8", "REALCALLERIDNUM=62") in new stack
-- Executing [s@macro-user-callerid:12] ExecIf("SIP/62-08466ca8", "0|Set|CHANNEL(language)=") in new stack
-- Executing [s@macro-user-callerid:13] NoOp("SIP/62-08466ca8", "TTL: ARG1: novm") in new stack
-- Executing [s@macro-user-callerid:14] GotoIf("SIP/62-08466ca8", "0?continue") in new stack
-- Executing [s@macro-user-callerid:15] Set("SIP/62-08466ca8", "__TTL=64") in new stack
-- Executing [s@macro-user-callerid:16] GotoIf("SIP/62-08466ca8", "1?continue") in new stack
-- Goto (macro-user-callerid,s,23)
-- Executing [s@macro-user-callerid:23] NoOp("SIP/62-08466ca8", "Using CallerID "EbayTest" ") in new stack
-- Executing [s@macro-exten-vm:2] Set("SIP/62-08466ca8", "FROMCONTEXT=exten-vm") in new stack
-- Executing [s@macro-exten-vm:3] Set("SIP/62-08466ca8", "VMBOX=novm") in new stack
-- Executing [s@macro-exten-vm:4] Set("SIP/62-08466ca8", "EXTTOCALL=10") in new stack
-- Executing [s@macro-exten-vm:5] Set("SIP/62-08466ca8", "CFUEXT=") in new stack
-- Executing [s@macro-exten-vm:6] Set("SIP/62-08466ca8", "CFBEXT=") in new stack
-- Executing [s@macro-exten-vm:7] Set("SIP/62-08466ca8", "RT=""") in new stack
-- Executing [s@macro-exten-vm:8] Macro("SIP/62-08466ca8", "record-enable|10|IN") in new stack
-- Executing [s@macro-record-enable:1] GotoIf("SIP/62-08466ca8", "0?2:4") in new stack
-- Goto (macro-record-enable,s,4)
-- Executing [s@macro-record-enable:4] AGI("SIP/62-08466ca8", "recordingcheck|20080425-083220|1209130340.20") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/recordingcheck
recordingcheck|20080425-083220|1209130340.20: Inbound recording not enabled
-- AGI Script recordingcheck completed, returning 0
-- Executing [s@macro-record-enable:5] NoOp("SIP/62-08466ca8", "No recording needed") in new stack
-- Executing [s@macro-exten-vm:9] Macro("SIP/62-08466ca8", "dial||tr|10") in new stack
-- Executing [s@macro-dial:1] GotoIf("SIP/62-08466ca8", "1?dial") in new stack
-- Goto (macro-dial,s,3)
-- Executing [s@macro-dial:3] AGI("SIP/62-08466ca8", "dialparties.agi") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/dialparties.agi
dialparties.agi: Starting New Dialparties.agi
== Parsing '/etc/asterisk/manager.conf': Found
== Parsing '/etc/asterisk/manager_additional.conf': Found
== Parsing '/etc/asterisk/manager_custom.conf': Found
== Manager 'admin' logged on from 127.0.0.1
dialparties.agi: Caller ID name is 'EbayTest' number is '62'
dialparties.agi: USE_CONFIRMATION: 'FALSE'
dialparties.agi: RINGGROUP_INDEX: ''
dialparties.agi: Methodology of ring is 'none'
-- dialparties.agi: Added extension 10 to extension map
-- dialparties.agi: Extension 10 cf is disabled
-- dialparties.agi: Extension 10 do not disturb is disabled
> dialparties.agi: extnum 10 has: cw: 1; hascfb: 0 [] hascfu: 0 []
> dialparties.agi: ExtensionState: 0
-- dialparties.agi: dbset CALLTRACE/10 to 62
-- dialparties.agi: Filtered ARG3: 10
== Manager 'admin' logged off from 127.0.0.1
-- AGI Script dialparties.agi completed, returning 0
-- Executing [s@macro-dial:7] Dial("SIP/62-08466ca8", "SIP/10||tr") in new stack
-- Called 10
-- SIP/10-08485590 is ringing
-- SIP/10-08485590 answered SIP/62-08466ca8
== Spawn extension (macro-dial, s, 7) exited non-zero on 'SIP/62-08466ca8' in macro 'dial'
== Spawn extension (macro-dial, s, 7) exited non-zero on 'SIP/62-08466ca8' in macro 'exten-vm'
== Spawn extension (macro-dial, s, 7) exited non-zero on 'SIP/62-08466ca8'
-- Executing [h@macro-dial:1] Macro("SIP/62-08466ca8", "hangupcall") in new stack
-- Executing [s@macro-hangupcall:1] ResetCDR("SIP/62-08466ca8", "w") in new stack
-- Executing [s@macro-hangupcall:2] NoCDR("SIP/62-08466ca8", "") in new stack
-- Executing [s@macro-hangupcall:3] GotoIf("SIP/62-08466ca8", "1?skiprg") in new stack
-- Goto (macro-hangupcall,s,6)
-- Executing [s@macro-hangupcall:6] GotoIf("SIP/62-08466ca8", "1?skipblkvm") in new stack
-- Goto (macro-hangupcall,s,9)
-- Executing [s@macro-hangupcall:9] GotoIf("SIP/62-08466ca8", "1?theend") in new stack
-- Goto (macro-hangupcall,s,11)
-- Executing [s@macro-hangupcall:11] Hangup("SIP/62-08466ca8", "") in new stack
== Spawn extension (macro-hangupcall, s, 11) exited non-zero on 'SIP/62-08466ca8' in macro 'hangupcall'
== Spawn extension (macro-hangupcall, s, 11) exited non-zero on 'SIP/62-08466ca8'
trixbox1*CLI>

WORKING INCOMING CALL

-- Starting simple switch on 'Zap/4-1'
-- Executing [s@from-zaptel:1] NoOp("Zap/4-1", "Entering from-zaptel with DID == ") in new stack
-- Executing [s@from-zaptel:2] Ringing("Zap/4-1", "") in new stack
-- Executing [s@from-zaptel:3] Set("Zap/4-1", "DID=s") in new stack
-- Executing [s@from-zaptel:4] NoOp("Zap/4-1", "DID is now s") in new stack
-- Executing [s@from-zaptel:5] GotoIf("Zap/4-1", "1?zapok:notzap") in new stack
-- Goto (from-zaptel,s,8)
-- Executing [s@from-zaptel:8] NoOp("Zap/4-1", "Is a Zaptel Channel") in new stack
-- Executing [s@from-zaptel:9] Set("Zap/4-1", "CHAN=4-1") in new stack
-- Executing [s@from-zaptel:10] Set("Zap/4-1", "CHAN=4") in new stack
-- Executing [s@from-zaptel:11] Macro("Zap/4-1", "from-zaptel-4|s|1") in new stack
-- Executing [s@macro-from-zaptel-4:1] NoOp("Zap/4-1", "Entering macro-from-zaptel-4 with DID = s and setting to: 88") in new stack
-- Executing [s@macro-from-zaptel-4:2] Set("Zap/4-1", "__FROM_DID=88") in new stack
-- Executing [s@macro-from-zaptel-4:3] Goto("Zap/4-1", "from-trunk|88|1") in new stack
-- Goto (from-trunk,88,1)
== Channel 'Zap/4-1' jumping out of macro 'from-zaptel-4'
-- Executing [88@from-trunk:1] Set("Zap/4-1", "__FROM_DID=88") in new stack
-- Executing [88@from-trunk:2] Gosub("Zap/4-1", "app-blacklist-check|s|1") in new stack
-- Executing [s@app-blacklist-check:1] LookupBlacklist("Zap/4-1", "") in new stack
-- Executing [s@app-blacklist-check:2] GotoIf("Zap/4-1", "0?blacklisted") in new stack
-- Executing [s@app-blacklist-check:3] Return("Zap/4-1", "") in new stack
-- Executing [88@from-trunk:3] GotoIf("Zap/4-1", "1 ?cidok") in new stack
-- Goto (from-trunk,88,5)
-- Executing [88@from-trunk:5] NoOp("Zap/4-1", "CallerID is "device" ") in new stack
-- Executing [88@from-trunk:6] Set("Zap/4-1", "FAX_RX=disabled") in new stack
-- Executing [88@from-trunk:7] Goto("Zap/4-1", "ext-group|600|1") in new stack
-- Goto (ext-group,600,1)
-- Executing [600@ext-group:1] Macro("Zap/4-1", "user-callerid|") in new stack
-- Executing [s@macro-user-callerid:1] NoOp("Zap/4-1", "user-callerid: device 8") in new stack
-- Executing [s@macro-user-callerid:2] Set("Zap/4-1", "AMPUSER=8") in new stack
-- Executing [s@macro-user-callerid:3] GotoIf("Zap/4-1", "0?report") in new stack
-- Executing [s@macro-user-callerid:4] ExecIf("Zap/4-1", "1|Set|REALCALLERIDNUM=8") in new stack
-- Executing [s@macro-user-callerid:5] NoOp("Zap/4-1", "REALCALLERIDNUM is 8") in new stack
-- Executing [s@macro-user-callerid:6] Set("Zap/4-1", "AMPUSER=8") in new stack
-- Executing [s@macro-user-callerid:7] Set("Zap/4-1", "AMPUSERCIDNAME=cvvv") in new stack
-- Executing [s@macro-user-callerid:8] GotoIf("Zap/4-1", "0?report") in new stack
-- Executing [s@macro-user-callerid:9] Set("Zap/4-1", "AMPUSERCID=8") in new stack
-- Executing [s@macro-user-callerid:10] Set("Zap/4-1", "CALLERID(all)="cvvv" ") in new stack
-- Executing [s@macro-user-callerid:11] Set("Zap/4-1", "REALCALLERIDNUM=8") in new stack
-- Executing [s@macro-user-callerid:12] ExecIf("Zap/4-1", "0|Set|CHANNEL(language)=") in new stack
-- Executing [s@macro-user-callerid:13] NoOp("Zap/4-1", "TTL: ARG1: ") in new stack
-- Executing [s@macro-user-callerid:14] GotoIf("Zap/4-1", "0?continue") in new stack
-- Executing [s@macro-user-callerid:15] Set("Zap/4-1", "__TTL=64") in new stack
-- Executing [s@macro-user-callerid:16] GotoIf("Zap/4-1", "1?continue") in new stack
-- Goto (macro-user-callerid,s,23)
-- Executing [s@macro-user-callerid:23] NoOp("Zap/4-1", "Using CallerID "cvvv" ") in new stack
-- Executing [600@ext-group:2] GotoIf("Zap/4-1", "1?skipdb") in new stack
-- Goto (ext-group,600,4)
-- Executing [600@ext-group:4] Set("Zap/4-1", "__NODEST=") in new stack
-- Executing [600@ext-group:5] Set("Zap/4-1", "__BLKVM_OVERRIDE=BLKVM/600/Zap/4-1") in new stack
-- Executing [600@ext-group:6] Set("Zap/4-1", "__BLKVM_BASE=600") in new stack
-- Executing [600@ext-group:7] Set("Zap/4-1", "DB(BLKVM/600/Zap/4-1)=TRUE") in new stack
-- Executing [600@ext-group:8] Set("Zap/4-1", "RRNODEST=") in new stack
-- Executing [600@ext-group:9] Set("Zap/4-1", "__NODEST=600") in new stack
-- Executing [600@ext-group:10] Set("Zap/4-1", "RecordMethod=Group") in new stack
-- Executing [600@ext-group:11] Macro("Zap/4-1", "record-enable|32-66|Group") in new stack
-- Executing [s@macro-record-enable:1] GotoIf("Zap/4-1", "0?2:4") in new stack
-- Goto (macro-record-enable,s,4)
-- Executing [s@macro-record-enable:4] AGI("Zap/4-1", "recordingcheck|20080425-083415|1209130449.22") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/recordingcheck
-- AGI Script recordingcheck completed, returning 0
-- Executing [s@macro-record-enable:5] NoOp("Zap/4-1", "No recording needed") in new stack
-- Executing [600@ext-group:12] Set("Zap/4-1", "RingGroupMethod=memoryhunt") in new stack
-- Executing [600@ext-group:13] Macro("Zap/4-1", "dial|10|m(default)t|32-66") in new stack
-- Executing [s@macro-dial:1] GotoIf("Zap/4-1", "1?dial") in new stack
-- Goto (macro-dial,s,3)
-- Executing [s@macro-dial:3] AGI("Zap/4-1", "dialparties.agi") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/dialparties.agi
dialparties.agi: Starting New Dialparties.agi
== Parsing '/etc/asterisk/manager.conf': Found
== Parsing '/etc/asterisk/manager_additional.conf': Found
== Parsing '/etc/asterisk/manager_custom.conf': Found
== Manager 'admin' logged on from 127.0.0.1
dialparties.agi: Caller ID name is 'cvvv' number is '8'
dialparties.agi: USE_CONFIRMATION: 'FALSE'
dialparties.agi: RINGGROUP_INDEX: ''
dialparties.agi: Methodology of ring is 'memoryhunt'
-- dialparties.agi: Added extension 32 to extension map
-- dialparties.agi: Added extension 66 to extension map
-- dialparties.agi: Extension 32 cf is disabled
-- dialparties.agi: Extension 66 cf is disabled
-- dialparties.agi: Extension 32 do not disturb is disabled
-- dialparties.agi: Extension 66 do not disturb is disabled
> dialparties.agi: extnum 32 has: cw: 1; hascfb: 0 [] hascfu: 0 []
> dialparties.agi: extnum 66 has: cw: 1; hascfb: 0 [] hascfu: 0 []
-- dialparties.agi: Filtered ARG3: 32-66
> dialparties.agi: NODEST: 600 adding M(auto-blkvm) to dialopts: m(default)tM(auto-blkvm)
> dialparties.agi: NODEST: 600 blkvm enabled macro already in dialopts: m(default)tM(auto-blkvm)
== Manager 'admin' logged off from 127.0.0.1
-- AGI Script dialparties.agi completed, returning 0
-- Executing [s@macro-dial:20] NoOp("Zap/4-1", "Returned from dialparties with hunt groups to dial ") in new stack
-- Executing [s@macro-dial:21] Set("Zap/4-1", "HuntLoop=0") in new stack
-- Executing [s@macro-dial:22] GotoIf("Zap/4-1", "1?a30") in new stack
-- Goto (macro-dial,s,26)
-- Executing [s@macro-dial:26] Set("Zap/4-1", "HuntMember=HuntMember0") in new stack
-- Executing [s@macro-dial:27] GotoIf("Zap/4-1", "0?a32:a35") in new stack
-- Goto (macro-dial,s,31)
-- Executing [s@macro-dial:31] GotoIf("Zap/4-1", "1?a36:a50") in new stack
-- Goto (macro-dial,s,32)
-- Executing [s@macro-dial:32] Set("Zap/4-1", "CTLoop=0") in new stack
-- Executing [s@macro-dial:33] GotoIf("Zap/4-1", "0?a42") in new stack
-- Executing [s@macro-dial:34] Set("Zap/4-1", "CT_EXTEN=32") in new stack
-- Executing [s@macro-dial:35] Set("Zap/4-1", "DB(CALLTRACE/32)=8") in new stack
-- Executing [s@macro-dial:36] Set("Zap/4-1", "CTLoop=1") in new stack
-- Executing [s@macro-dial:37] Goto("Zap/4-1", "s|a37") in new stack
-- Goto (macro-dial,s,33)
-- Executing [s@macro-dial:33] GotoIf("Zap/4-1", "1?a42") in new stack
-- Goto (macro-dial,s,38)
-- Executing [s@macro-dial:38] Dial("Zap/4-1", "SIP/32|10|m(default)tM(auto-blkvm)") in new stack
-- Called 32
-- Started music on hold, class 'default', on Zap/4-1
-- SIP/32-084808b8 is ringing
-- Nobody picked up in 10000 ms
-- Stopped music on hold on Zap/4-1
-- Executing [s@macro-dial:39] Set("Zap/4-1", "HuntLoop=1") in new stack
-- Executing [s@macro-dial:40] GotoIf("Zap/4-1", "1?a46") in new stack
-- Goto (macro-dial,s,42)
-- Executing [s@macro-dial:42] Set("Zap/4-1", "HuntMembers=1") in new stack
-- Executing [s@macro-dial:43] Goto("Zap/4-1", "s|a22") in new stack
-- Goto (macro-dial,s,22)
-- Executing [s@macro-dial:22] GotoIf("Zap/4-1", "1?a30") in new stack
-- Goto (macro-dial,s,26)
-- Executing [s@macro-dial:26] Set("Zap/4-1", "HuntMember=HuntMember1") in new stack
-- Executing [s@macro-dial:27] GotoIf("Zap/4-1", "0?a32:a35") in new stack
-- Goto (macro-dial,s,31)
-- Executing [s@macro-dial:31] GotoIf("Zap/4-1", "1?a36:a50") in new stack
-- Goto (macro-dial,s,32)
-- Executing [s@macro-dial:32] Set("Zap/4-1", "CTLoop=0") in new stack
-- Executing [s@macro-dial:33] GotoIf("Zap/4-1", "0?a42") in new stack
-- Executing [s@macro-dial:34] Set("Zap/4-1", "CT_EXTEN=32") in new stack
-- Executing [s@macro-dial:35] Set("Zap/4-1", "DB(CALLTRACE/32)=8") in new stack
-- Executing [s@macro-dial:36] Set("Zap/4-1", "CTLoop=1") in new stack
-- Executing [s@macro-dial:37] Goto("Zap/4-1", "s|a37") in new stack
-- Goto (macro-dial,s,33)
-- Executing [s@macro-dial:33] GotoIf("Zap/4-1", "0?a42") in new stack
-- Executing [s@macro-dial:34] Set("Zap/4-1", "CT_EXTEN=66") in new stack
-- Executing [s@macro-dial:35] Set("Zap/4-1", "DB(CALLTRACE/66)=8") in new stack
-- Executing [s@macro-dial:36] Set("Zap/4-1", "CTLoop=2") in new stack
-- Executing [s@macro-dial:37] Goto("Zap/4-1", "s|a37") in new stack
-- Goto (macro-dial,s,33)
-- Executing [s@macro-dial:33] GotoIf("Zap/4-1", "1?a42") in new stack
-- Goto (macro-dial,s,38)
-- Executing [s@macro-dial:38] Dial("Zap/4-1", "SIP/32&SIP/66|10|m(default)tM(auto-blkvm)") in new stack
-- Called 32
-- Called 66
-- Started music on hold, class 'default', on Zap/4-1
-- SIP/66-0848a960 is ringing
-- SIP/32-08481e48 is ringing
-- SIP/32-08481e48 answered Zap/4-1
-- Executing [s@macro-auto-blkvm:1] Set("SIP/32-08481e48", "__MACRO_RESULT=") in new stack
-- Executing [s@macro-auto-blkvm:2] Set("SIP/32-08481e48", "__CWIGNORE=") in new stack
-- Executing [s@macro-auto-blkvm:3] DBdel("SIP/32-08481e48", "BLKVM/600/Zap/4-1") in new stack
-- DBdel: family=BLKVM, key=600/Zap/4-1
-- Stopped music on hold on Zap/4-1
== Spawn extension (macro-dial, s, 38) exited non-zero on 'Zap/4-1' in macro 'dial'
== Spawn extension (macro-dial, s, 38) exited non-zero on 'Zap/4-1'
-- Executing [h@macro-dial:1] Macro("Zap/4-1", "hangupcall") in new stack
-- Executing [s@macro-hangupcall:1] ResetCDR("Zap/4-1", "w") in new stack
-- Executing [s@macro-hangupcall:2] NoCDR("Zap/4-1", "") in new stack
-- Executing [s@macro-hangupcall:3] GotoIf("Zap/4-1", "1?skiprg") in new stack
-- Goto (macro-hangupcall,s,6)
-- Executing [s@macro-hangupcall:6] GotoIf("Zap/4-1", "0?skipblkvm") in new stack
-- Executing [s@macro-hangupcall:7] NoOp("Zap/4-1", "Cleaning Up Block VM Flag: BLKVM/600/Zap/4-1") in new stack
-- Executing [s@macro-hangupcall:8] DBdel("Zap/4-1", "BLKVM/600/Zap/4-1") in new stack
-- DBdel: family=BLKVM, key=600/Zap/4-1
-- DBdel: Error deleting key from database.
-- Executing [s@macro-hangupcall:9] GotoIf("Zap/4-1", "1?theend") in new stack
-- Goto (macro-hangupcall,s,11)
-- Executing [s@macro-hangupcall:11] Hangup("Zap/4-1", "") in new stack
== Spawn extension (macro-hangupcall, s, 11) exited non-zero on 'Zap/4-1' in macro 'hangupcall'
== Spawn extension (macro-hangupcall, s, 11) exited non-zero on 'Zap/4-1'
-- Hungup 'Zap/4-1'
trixbox1*CLI>

;
; Zapata telephony interface
;
; Configuration file

[trunkgroups]

[channels]

busydetect=no
busycount=8
rxgain=0.0
txgain=0.0
language=en
context=from-pstn
signalling=fxs_ks

rxwink=300 ; Atlas seems to use long (250ms) winks
channel=>4

;
; Whether or not to do distinctive ring detection on FXO lines
;
;usedistinctiveringdetection=yes
;pridialplan=local
usecallerid=yes
hidecallerid=no
callwaiting=yes
usecallingpres=yes
callwaitingcallerid=yes
threewaycalling=yes
transfer=yes
cancallforward=yes
callreturn=yes
echocancel=yes
echocancelwhenbridged=no
;echotraining=800
rxgain=0.0
txgain=0.0
group=0
callgroup=1
pickupgroup=1
immediate=no

;faxdetect=both
faxdetect=incoming
;faxdetect=outgoing
;faxdetect=no

;Include genzaptelconf configs
include zapata-auto.conf

group=1

;Include AMP configs

channel=>4

#include zapata_additional.conf

; Autogenerated by /usr/sbin/genzaptelconf -- do not hand edit
; Zaptel Channels Configurations (zapata.conf)
;
; This is not intended to be a complete zapata.conf. Rather, it is intended
; to be #include-d by /etc/zapata.conf that will include the global settings
;

; Span 1: WCTDM/0 "Wildcard TDM400P REV E/F Board 1" (MASTER)
;;; line="1 WCTDM/0/0 FXOKS"
signalling=fxo_ks
callerid="Channel 1"
mailbox=6001
group=5
context=from-internal
channel => 1
callerid=
mailbox=
group=
context=default

;;; line="3 WCTDM/0/2 FXOKS"
signalling=fxo_ks
callerid="Channel 3"
mailbox=6003
group=5
context=from-internal
channel => 3
callerid=
mailbox=
group=
context=default

;;; line="4 WCTDM/0/3 FXSKS (In use)"
signalling=fxs_ks
callerid=asreceived
group=0
context=from-pstn
channel => 4
context=default

; Autogenerated by /usr/sbin/genzaptelconf -- do not hand edit
; Zaptel Channels Configurations (zapata.conf)
;
; This is not intended to be a complete zapata.conf. Rather, it is intended
; to be #include-d by /etc/zapata.conf that will include the global settings
;

; Span 1: WCTDM/0 "Wildcard TDM400P REV E/F Board 1" (MASTER)
;;; line="1 WCTDM/0/0 FXOKS"
signalling=fxo_ks
callerid="Channel 1"
mailbox=6001
group=5
context=from-internal
channel => 1
callerid=
mailbox=
group=
context=default

;;; line="3 WCTDM/0/2 FXOKS"
signalling=fxo_ks
callerid="Channel 3"
mailbox=6003
group=5
context=from-internal
channel => 3
callerid=
mailbox=
group=
context=default

;;; line="4 WCTDM/0/3 FXSKS (In use)"
signalling=fxs_ks
callerid=asreceived
group=0
context=from-pstn
channel => 4
context=default

; do not edit this file, this is an auto-generated file by freepbx
; all modifications must be done from the web gui

; FreePBX
; Copyright (C) 2004 Coalescent Systems Inc (Canada)
; Copyright (C) 2006 Why Pay More 4 Less Pty Ltd (Australia)
; Copyright (C) 2007 Astrogen LLC (USA)
; Released under the GNU GPL Licence version 2.

; dialparties.agi (http://www.sprackett.com/asterisk/)
; Asterisk::AGI (http://asterisk.gnuinter.net/)
; gsm (http://www.ibiblio.org/pub/Linux/utils/compress/!INDEX.short.html)
; loligo sounds (http://www.loligo.com/asterisk/sounds/)
; mpg123 (http://voip-info.org/wiki-Asterisk+config+musiconhold.conf)

;************************** -WARNING- ****************************************
; *
; This include file is to be used with extreme caution. In almost all cases *
; any custom dialplan SHOULD be put in extensions_custom.conf which will *
; not hurt freepbx generated dialplan. In some very rare and custom situation *
; users have a need to override what freepbx generates. Anything in this file *
; will do such. *
; *
#include extensions_override_freepbx.conf
; *
;************************** -WARNING- ****************************************

; include extension contexts generated from AMP
#include extensions_additional.conf

; Customizations to this dialplan should be made in extensions_custom.conf
; See extensions_custom.conf.sample for an example
#include extensions_custom.conf

[from-trunk] ; just an alias since VoIP shouldn't be called PSTN
include => from-pstn
include => from-zaptel

[from-pstn]
include => from-pstn-custom ; create this context in extensions_custom.conf to include customizations
include => ext-did
include => from-did-direct ; MODIFICATOIN (PL) for findmefollow if enabled, should be bofore ext-local
include => ext-did-catchall ; THIS MUST COME AFTER ext-did
exten => fax,1,Goto(ext-fax,in_fax,1)

; MODIFICATION (PL)
;
; Required to assure that direct dids go to personal ring group before local extension.
; This could be auto-generated however I it is prefered to be put here and hard coded
; so that it can be modified if ext-local should take precedence in certain situations.
; will have to decide what to do later.
;
[from-did-direct]
include => ext-findmefollow
include => ext-local

; ############################################################################
; Macros [macro]
; ############################################################################

; Rings one or more extensions. Handles things like call forwarding and DND
; We don't call dial directly for anything internal anymore.
; ARGS: $TIMER, $OPTIONS, $EXT1, $EXT2, $EXT3, ...
; Use a Macro call such as the following:
; Macro(dial,$DIAL_TIMER,$DIAL_OPTIONS,$EXT1,$EXT2,$EXT3,...)
[macro-dial]
exten => s,1,GotoIf($["${MOHCLASS}" = ""]?dial)
exten => s,n,SetMusicOnHold(${MOHCLASS})
exten => s,n(dial),AGI(dialparties.agi)
exten => s,n,NoOp(Returned from dialparties with no extensions to call and DIALSTATUS: ${DIALSTATUS})

exten => s,n+2(normdial),Dial(${ds}) ; dialparties will set the priority to 10 if $ds is not null
exten => s,n,Set(DIALSTATUS=${IF($["${DIALSTATUS_CW}"!="" ]?${DIALSTATUS_CW}:${DIALSTATUS})})

exten => s,20(huntdial),NoOp(Returned from dialparties with hunt groups to dial )
exten => s,n,Set(HuntLoop=0)
exten => s,n(a22),GotoIf($[${HuntMembers} >= 1]?a30) ; if this is from rg-group, don't strip prefix
exten => s,n,NoOp(Returning there are no members left in the hunt group to ring)

; dialparties.agi has setup the dialstring for each hunt member in a variable labeled HuntMember0, HuntMember1 etc for each iteration
; and The total number in HuntMembers. So for each iteration, we will update the CALLTRACE Data.
;
exten => s,n+2(a30),Set(HuntMember=HuntMember${HuntLoop})
exten => s,n,GotoIf($[$["${CALLTRACE_HUNT}" != "" ] & $["${RingGroupMethod}" = "hunt" ]]?a32:a35)
exten => s,n(a32),Set(CT_EXTEN=${CUT(FILTERED_DIAL,,$[${HuntLoop} + 1])})
exten => s,n,Set(DB(CALLTRACE/${CT_EXTEN})=${CALLTRACE_HUNT})
exten => s,n,Goto(s,a42)

;Set Call Trace for each hunt member we are going to call "Memory groups have multiple members to set CALL TRACE For hence the loop
;
exten => s,n(a35),GotoIf($[$["${CALLTRACE_HUNT}" != "" ] & $["${RingGroupMethod}" = "memoryhunt" ]]?a36:a50)
exten => s,n(a36),Set(CTLoop=0)
exten => s,n(a37),GotoIf($[${CTLoop} > ${HuntLoop}]?a42) ; if this is from rg-group, don't strip prefix
exten => s,n,Set(CT_EXTEN=${CUT(FILTERED_DIAL,,$[${CTLoop} + 1])})
exten => s,n,Set(DB(CALLTRACE/${CT_EXTEN})=${CALLTRACE_HUNT})
exten => s,n,Set(CTLoop=$[1 + ${CTLoop}])
exten => s,n,Goto(s,a37)

exten => s,n(a42),Dial(${${HuntMember}}${ds})
exten => s,n,Set(HuntLoop=$[1 + ${HuntLoop}])
exten => s,n,GotoIf($[$[$["foo${RingGroupMethod}" != "foofirstavailable"] & $["foo${RingGroupMethod}" != "foofirstnotonphone"]] | $["foo${DialStatus}" = "fooBUSY"]]?a46)
exten => s,n,Set(HuntMembers=0)
exten => s,n(a46),Set(HuntMembers=$[${HuntMembers} - 1])
exten => s,n,Goto(s,a22)

exten => s,n(a50),DBdel(CALLTRACE/${CT_EXTEN})
exten => s,n,Goto(s,a42)

; make sure hungup calls go here so that proper cleanup occurs from call confirmed calls and the like
;
exten => h,1,Macro(hangupcall)

; Ring an extension, if the extension is busy or there is no answer send it
; to voicemail
; ARGS: $VMBOX, $EXT
[macro-exten-vm]
exten => s,1,Macro(user-callerid)

exten => s,n,Set(FROMCONTEXT=exten-vm)
exten => s,n,Set(VMBOX=${ARG1})
exten => s,n,Set(EXTTOCALL=${ARG2})
exten => s,n,Set(CFUEXT=${DB(CFU/${EXTTOCALL})})
exten => s,n,Set(CFBEXT=${DB(CFB/${EXTTOCALL})})
exten => s,n,Set(RT=${IF($[$["${VMBOX}"!="novm"] | $["foo${CFUEXT}"!="foo"]]?${RINGTIMER}:"")})
exten => s,n,Macro(record-enable,${EXTTOCALL},IN)

exten => s,n,Macro(dial,${RT},${DIAL_OPTIONS},${EXTTOCALL})
exten => s,n,Set(SV_DIALSTATUS=${DIALSTATUS})
exten => s,n,GosubIf($[$["${SV_DIALSTATUS}"="NOANSWER"] & $["foo${CFUEXT}"!="foo"]]?docfu,1) ; check for CFU in use on no answer
exten => s,n,GosubIf($[$["${SV_DIALSTATUS}"="BUSY"] & $["foo${CFBEXT}"!="foo"]]?docfb,1) ; check for CFB in use on busy
exten => s,n,Set(DIALSTATUS=${SV_DIALSTATUS})
exten => s,n,NoOp(Voicemail is '${VMBOX}')
exten => s,n,GotoIf($["${VMBOX}" = "novm"]?s-${DIALSTATUS},1) ; no voicemail in use for this extension
exten => s,n,NoOp(Sending to Voicemail box ${EXTTOCALL})
exten => s,n,Macro(vm,${VMBOX},${DIALSTATUS})

; Try the Call Forward on No Answer / Unavailable number
exten => docfu,1,Set(RTCFU=${IF($["${VMBOX}"!="novm"]?${RINGTIMER}:"")})
exten => docfu,n,Dial(Local/${CFUEXT}@from-internal/n,${RTCFU},${DIAL_OPTIONS})
exten => docfu,n,Return

; Try the Call Forward on Busy number
exten => docfb,1,Set(RTCFB=${IF($["${VMBOX}"!="novm"]?${RINGTIMER}:"")})
exten => docfb,n,Dial(Local/${CFBEXT}@from-internal/n,${RTCFB},${DIAL_OPTIONS})
exten => docfb,n,Return

; Extensions with no Voicemail box reporting BUSY come here
exten => s-BUSY,1,NoOp(Extension is reporting BUSY and not passing to Voicemail)
exten => s-BUSY,n,Playtones(busy)
exten => s-BUSY,n,Busy(20)

; Anything but BUSY comes here
exten => _s-.,1,Playtones(congestion)
exten => _s-.,n,Congestion(10)

;------------------------------------------------------------------------
; [macro-vm]
;------------------------------------------------------------------------
; CONTEXT: macro-vm
; PURPOSE: call voicemail system and extend with personal ivr
;
; Under normal use, this macro will call the voicemail system with the extension and
; desired greeting mode of busy, unavailable or as specified with direct voicemail
; calls (usually unavailable) when entered from destinations.
;
; The voicemail system's two greetings have been 'hijacked' as follows to extend the
; system by giving the option of a private 'ivr' for each voicemail user. The following
; applies to both the busy and unavailable modes of voicemail and can be applied to one
; or both, and differently.
;
; Global Defaults:
;
; The following are default values, used in both busy and unavail modes if no specific
; values are specified.
;
; VMX_REPEAT
; The number of times to repeat the users message if no option is pressed.
; VMX_TIMEOUT
; The timeout to wait after playing message before repeating or giving up.
; VMX_LOOPS
; The number of times it should replay the message and check for an option when
; an invalid option is pressed.
;
; VMX_OPTS_DOVM
; Default voicemail option to use if vm is chosen as an option. No options will
; cause Allison's generic message, 's' will go straight to beep.
; VMX_OPTS_TIMEOUT
; Default voicemail option to use if it times out with no options. No options will
; cause Allison's generic message, 's' will go straight to beep.
; IF THE USER PRESSES # - it will look like a timeout as well since no option will
; be presented. If the user wishes to enable a mode where a caller can press #
; during their message and it goes straight to voicemail with only a 'beep' then
; this should be set to 's'.
; VMX_OPTS_LOOPS
; Default voicemail option to use if to many wrong options occur. No options will
; cause Allison's generic message, 's' will go straight to beep.
;
; VMX_CONTEXT
; Default context for user destinations if not supplied in the user's settings
; VMX_PRI
; Default priority for user destinations if not supplied in the user's settings
;
; VMX_TIMEDEST_CONTEXT
; Default context for timeout destination if not supplied in the user's settings
; VMX_TIMEDEST_EXT
; Default extension for timeout destination if not supplied in the user's settings
; VMX_TIMEDEST_PRI
; Default priority for timeout destination if not supplied in the user's settings
;
; VMX_LOOPDEST_CONTEXT
; Default context for loops destination if not supplied in the user's settings
; VMX_LOOPDEST_EXT
; Default extension for loops destination if not supplied in the user's settings
; VMX_LOOPDEST_PRI
; Default priority for loops destination if not supplied in the user's settings
;
;
; The AMPUSER database variable has been extended with a 'vmx' tree (vm-extension). A
; duplicate set is included for both unavail and busy. You could choose for to have an
; ivr when unavail is taken, but not with busy - or a different once with busy.
; The full list is below, each specific entry is futher described:
;
; state: Whether teh current mode is enabled or disabled. Anything but 'enabled' is
; treated as disabled.
; repeat: This is the number of times that the users message should be played after the
; timeout if the user has not entered anything. It is just a variable to the
; Read() function which will do the repeating.
; timeout: This is how long to wait after the message has been read for a response from
; the user. A caller can enter a digit any time during the playback.
; loops: This is the number of loops that the system will allow a caller to retry if
; they enter a bad menu choice, before going to the loop failover destination
; vmxopts: This is the vm options to send to the voicemail command used when a specific
; voicemail destination is chosen (inidcated by 'dovm' in the ext field). This is
; typically either set to 's' or left blank. When set to 's' there will be no
; message played when entering the voicemail, just a beep. When blank, you will
; have Allison's generic message played. It is not typical to play the greetings
; since they have been 'hijacked' for these IVR's and from a caller's perspecitive
; this system appears interconnected with the voicemail so instructions can be
; left there.
; timedest: The three variables: ext, context and pri are the goto destination if the caller
; enters no options and it timesout. None have to be set and a system default
; will be used. If just ext is set, then defaults will be used for context and
; pri, etc.
; loopdest: This is identical to timedest but used if the caller exceeds the maximum invalid
; menu choices.
; [0-9*]: The user can specify up to 11 ivr options, all as single digits from 0-9 or *. The
; # key can not be used since it is used as a terminator key for the Read command
; and will never be returned. A minimum of the ext must be specified for each valid
; option and as above, the context and priority can also be specified if the default
; is not to be used.
; Option '0' takes on a special meaning. Since a user is able to break out of the
; voicemail command once entering it with a 0, if specified, the 0 destination will
; be used.
; Option '*' can also be used to breakout. It is undecided at this point whether
; providing that option will be used as well. (probably should).
;
;
; /AMPUSER//vmx/[busy|unavail]/state: enabled|disabled
; /AMPUSER//vmx/[busy|unavail]/repeat: n (times to repeat message)
; /AMPUSER//vmx/[busy|unavail]/timeout: n (timeout to wait for digit)
; /AMPUSER//vmx/[busy|unavail]/loops: n (loop returies for invalid entries)
; /AMPUSER//vmx/[busy|unavail]/vmxopts/dovm: vmoptions (if ext is dovm)
; /AMPUSER//vmx/[busy|unavail]/vmxopts/timeout: vmoptions (if timeout)
; /AMPUSER//vmx/[busy|unavail]/vmxopts/loops: vmoptions (if loops)
; /AMPUSER//vmx/[busy|unavail]/timedest/ext: extension (if timeout)
; /AMPUSER//vmx/[busy|unavail]/timedest/context: context (if timeout)
; /AMPUSER//vmx/[busy|unavail]/timedest/pri: priority (if timeout)
; /AMPUSER//vmx/[busy|unavail]/loopdest/ext: extension (if too many failures)
; /AMPUSER//vmx/[busy|unavail]/loopdest/context: context (if too many failures)
; /AMPUSER//vmx/[busy|unavail]/loopdest/pri: priority (if too many failures)
; /AMPUSER//vmx/[busy|unavail]/[0-9*]/ext: extension (dovm for vm access)
; /AMPUSER//vmx/[busy|unavail]/[0-9*]/context: context
; /AMPUSER//vmx/[busy|unavail]/[0-9*]/pri: priority
;------------------------------------------------------------------------
[macro-vm]
; ARG1 - extension
; ARG2 - DIRECTDIAL/BUSY
; ARG3 - RETURN makes macro return, otherwise hangup
exten => s,1,Macro(user-callerid,SKIPTTL)
exten => s,n,Set(VMGAIN=${IF($["foo${VM_GAIN}"!="foo"]?"g(${VM_GAIN})":"")})
;
; If BLKVM_OVERRIDE is set, then someone told us to block calls from going to
; voicemail. This variable is reset by the answering channel so subsequent
; transfers will properly function.
;
exten => s,n,GotoIf($["foo${DB(${BLKVM_OVERRIDE})}" != "fooTRUE"]?vmx,1)
;
; we didn't branch so block this from voicemail
;
exten => s,n,Noop(CAME FROM: ${NODEST} - Blocking VM cause of key: ${DB(BLKVM_OVERRIDE)})

; If vmx not enabled for the current mode,then jump to normal voicemail behavior
; also - if not message (no-msg) is requested, straight to voicemail
;
exten => vmx,1,GotoIf($["${ARG2}"="NOMESSAGE"]?s-${ARG2},1)
exten => vmx,n,Set(MODE=${IF($["${ARG2}"="BUSY"]?busy:unavail)})
exten => vmx,n,GotoIf($["${ARG2}" != "DIRECTDIAL"]?notdirect)
exten => vmx,n,Set(MODE=${IF($["${REGEX("[b]" ${VM_DDTYPE})}" = "1"]?busy:${MODE})})
exten => vmx,n(notdirect),Noop(Checking if ext ${ARG1} is enabled: ${DB(AMPUSER/${ARG1}/vmx/${MODE}/state)})
exten => vmx,n,GotoIf($["${DB(AMPUSER/${ARG1}/vmx/${MODE}/state)}" != "enabled"]?s-${ARG2},1)

; If the required voicemail file does not exist, then abort and go to normal voicemail behavior
;
; TODO: there have been errors using System() with jump to 101 where asterisk works fine at the begining and
; then starts to jump to 101 even on success. This new mode is being tried with the SYSTEM Status which
; returns SUCCESS when the command returned succcessfully with a 0 app return code.
;
exten => vmx,n,Macro(get-vmcontext,${ARG1})
;exten => vmx,n,TrySystem(/bin/ls ${ASTSPOOLDIR}/voicemail/${VMCONTEXT}/${ARG1}/${MODE}.[wW][aA][vV])
exten => vmx,n,AGI(checksound.agi,${ASTSPOOLDIR}/voicemail/${VMCONTEXT}/${ARG1}/${MODE})
exten => vmx,n,GotoIf($["${SYSTEMSTATUS}" != "SUCCESS"]?nofile)

; Get the repeat, timeout and loop times to use if they are overriden form the global settings
;
exten => vmx,n,Set(LOOPCOUNT=0)
exten => vmx,n,GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/repeat)}" = "0"]?vmxtime)
exten => vmx,n,Set(VMX_REPEAT=${DB_RESULT})
exten => vmx,n(vmxtime),GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/timeout)}" = "0"]?vmxloops)
exten => vmx,n,Set(VMX_TIMEOUT=${DB_RESULT})
exten => vmx,n(vmxloops),GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/loops)}" = "0"]?vmxanswer)
exten => vmx,n,Set(VMX_LOOPS=${DB_RESULT})
exten => vmx,n(vmxanswer),Answer()

; Now play the users voicemail recording as the basis for their ivr, the Read command will repeat as needed and if it timesout
; then we go to the timeout. Otherwise handle invalid options by looping until the limit until a valid option is played.
;
exten => vmx,n(loopstart),Read(ACTION,${ASTSPOOLDIR}/voicemail/${VMCONTEXT}/${ARG1}/${MODE},1,skip,${VMX_REPEAT},${VMX_TIMEOUT})
exten => vmx,n,GotoIf($["${EXISTS(${ACTION})}" = "1"]?checkopt)

; If we are here we timed out, go to the required destination
;
exten => vmx,n(noopt),Noop(Timeout: going to timeout dest)
exten => vmx,n,Set(VMX_OPTS=${VMX_OPTS_TIMEOUT})
exten => vmx,n,GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/vmxopts/timeout)}" = "0"]?chktime)
exten => vmx,n,Set(VMX_OPTS=${DB_RESULT})
exten => vmx,n(chktime),GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/timedest/ext)}" = "0"]?dotime)
exten => vmx,n,Set(VMX_TIMEDEST_EXT=${DB_RESULT})
exten => vmx,n,GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/timedest/context)}" = "0"]?timepri)
exten => vmx,n,Set(VMX_TIMEDEST_CONTEXT=${DB_RESULT})
exten => vmx,n(timepri),GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/timedest/pri)}" = "0"]?dotime)
exten => vmx,n,Set(VMX_TIMEDEST_PRI=${DB_RESULT})
exten => vmx,n(dotime),Goto(${VMX_TIMEDEST_CONTEXT},${VMX_TIMEDEST_EXT},${VMX_TIMEDEST_PRI})

; We got an option, check if the option is defined, or one of the system defaults
;
exten => vmx,n(checkopt),GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/${ACTION}/ext)}" = "1"]?doopt)
exten => vmx,n,GotoIf($["${ACTION}" = "0"]?o,1)
exten => vmx,n,GotoIf($["${ACTION}" = "*"]?adef,1)

; Got invalid option loop until the max
;
exten => vmx,n,Set(LOOPCOUNT=$[${LOOPCOUNT} + 1])
exten => vmx,n,GotoIf($[${LOOPCOUNT} > ${VMX_LOOPS}]?toomany)
exten => vmx,n,Playback(pm-invalid-option&please-try-again)
exten => vmx,n,Goto(loopstart)

; tomany: to many invalid options, go to the specified destination
;
exten => vmx,n(toomany),Noop(Too Many invalid entries, got to invalid dest)
exten => vmx,n,Set(VMX_OPTS=${VMX_OPTS_LOOPS})
exten => vmx,n,GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/vmxopts/loops)}" = "0"]?chkloop)
exten => vmx,n,Set(VMX_OPTS=${DB_RESULT})
exten => vmx,n(chkloop),GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/loopdest/ext)}" = "0"]?doloop)
exten => vmx,n,Set(VMX_LOOPDEST_EXT=${DB_RESULT})
exten => vmx,n,GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/loopdest/context)}" = "0"]?looppri)
exten => vmx,n,Set(VMX_LOOPDEST_CONTEXT=${DB_RESULT}) ;TODO make configurable per above
exten => vmx,n(looppri),GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/loopdest/pri)}" = "0"]?doloop)
exten => vmx,n,Set(VMX_LOOPDEST_PRI=${DB_RESULT}) ;TODO make configurable per above
exten => vmx,n(doloop),Goto(${VMX_LOOPDEST_CONTEXT},${VMX_LOOPDEST_EXT},${VMX_LOOPDEST_PRI})

; doopt: execute the valid option that was chosen
;
exten => vmx,n(doopt),Noop(Got a valid option: ${DB_RESULT})
exten => vmx,n,Set(VMX_EXT=${DB_RESULT})
;
; Special case, if this option was to go to voicemail, set options and go
;
exten => vmx,n,GotoIf($["${VMX_EXT}" != "dovm"]?getdest)
exten => vmx,n(vmxopts),Set(VMX_OPTS=${VMX_OPTS_DOVM})
exten => vmx,n,GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/vmxopts/dovm)}" = "0"]?vmxdovm)
exten => vmx,n(vmxopts),Set(VMX_OPTS=${DB_RESULT})
exten => vmx,n(vmxdovm),goto(dovm,1)
;
; General case, setup the goto destination and go there (no error checking, its up to the GUI's to assure
; reasonable values
;
exten => vmx,n(getdest),GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/${ACTION}/context)}" = "0"]?vmxpri)
exten => vmx,n,Set(VMX_CONTEXT=${DB_RESULT})
exten => vmx,n(vmxpri),GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/${ACTION}/pri)}" = "0"]?vmxgoto)
exten => vmx,n,Set(VMX_PRI=${DB_RESULT})
exten => vmx,n(vmxgoto),Goto(${VMX_CONTEXT},${VMX_EXT},${VMX_PRI})

; If the required voicemail file is not present, then revert to normal voicemail
; behavior treating as if it was not set
;
exten => vmx,n(nofile),Noop(File for mode: ${MODE} does not exist, SYSTEMSTATUS: ${SYSTEMSTATUS}, going to normal voicemail)
exten => vmx,n,Goto(s-${ARG2},1)

; Drop into voicemail either as a direct destination (in which case VMX_OPTS might be set to something) or
; if the user timed out or broke out of the loop then VMX_OPTS is always cleared such that an Allison
; message is played and the caller know's what is going on.
;
exten => dovm,1,Noop(VMX Timeout - go to voicemail)
exten => dovm,n,Voicemail(${ARG1}@${VMCONTEXT},${VMX_OPTS}${VMGAIN}) ; no flags, so allison plays please leave ...
exten => dovm,n,Goto(exit-${VMSTATUS},1)

exten => s-BUSY,1,NoOp(BUSY voicemail)
exten => s-BUSY,n,Macro(get-vmcontext,${ARG1})
exten => s-BUSY,n,Voicemail(${ARG1}@${VMCONTEXT},${VM_OPTS}b${VMGAIN}) ; Voicemail Busy message
exten => s-BUSY,n,Goto(exit-${VMSTATUS},1)

exten => s-NOMESSAGE,1,NoOp(NOMESSAGE (beeb only) voicemail)
exten => s-NOMESSAGE,n,Macro(get-vmcontext,${ARG1})
exten => s-NOMESSAGE,n,Voicemail(${ARG1}@${VMCONTEXT},${VM_OPTS}${VMGAIN}) ; Voicemail Busy message
exten => s-NOMESSAGE,n,Goto(exit-${VMSTATUS},1)

exten => s-DIRECTDIAL,1,NoOp(DIRECTDIAL voicemail)
exten => s-DIRECTDIAL,n,Macro(get-vmcontext,${ARG1})
exten => s-DIRECTDIAL,n,Voicemail(${ARG1}@${VMCONTEXT},${VM_OPTS}${VM_DDTYPE}${VMGAIN})
exten => s-DIRECTDIAL,n,Goto(exit-${VMSTATUS},1)

exten => _s-.,1,Macro(get-vmcontext,${ARG1})
exten => _s-.,n,Voicemail(${ARG1}@${VMCONTEXT},${VM_OPTS}u${VMGAIN}) ; Voicemail Unavailable message
exten => _s-.,n,Goto(exit-${VMSTATUS},1)

; If the user has a 0 option defined, use that for operator zero-out from within voicemail
; as well to keep it consistant with the menu structure
;
exten => o,1,Background(one-moment-please) ; 0 during vm message will hangup
exten => o,n,GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/0/ext)}" = "0"]?doopdef)

exten => o,n,Set(VMX_OPDEST_EXT=${DB_RESULT})
exten => o,n,GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/0/context)}" = "1"]?opcontext)
exten => o,n,Set(DB_RESULT=${VMX_CONTEXT})
exten => o,n(opcontext),Set(VMX_OPDEST_CONTEXT=${DB_RESULT})
exten => o,n,GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/0/pri)}" = "1"]?oppri)
exten => o,n,Set(DB_RESULT=${VMX_PRI})
exten => o,n(oppri),Set(VMX_OPDEST_PRI=${DB_RESULT})

exten => o,n,Goto(${VMX_OPDEST_CONTEXT},${VMX_OPDEST_EXT},${VMX_OPDEST_PRI})
exten => o,n(doopdef),GotoIf($["x${OPERATOR_XTN}"="x"]?nooper:from-internal,${OPERATOR_XTN},1)
exten => o,n(nooper),GotoIf($["x${FROM_DID}"="x"]?nodid)
exten => o,n,Dial(Local/${FROM_DID)@from-pstn)
exten => o,n,Macro(hangup)
exten => o,n(nodid),Dial(Local/s@from-pstn)
exten => o,n,Macro(hangup)

; If the user has a * option defined, use that for the * out from within voicemail
; as well to keep it consistant with the menu structure
;
exten => a,1,Macro(get-vmcontext,${ARG1})
exten => a,n,GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/*/ext)}" = "0"]?adef,1)

exten => a,n,Set(VMX_ADEST_EXT=${DB_RESULT})
exten => a,n,GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/*/context)}" = "1"]?acontext)
exten => a,n,Set(DB_RESULT=${VMX_CONTEXT})
exten => a,n(acontext),Set(VMX_ADEST_CONTEXT=${DB_RESULT})
exten => a,n,GotoIf($["${DB_EXISTS(AMPUSER/${ARG1}/vmx/${MODE}/*/pri)}" = "1"]?apri)
exten => a,n,Set(DB_RESULT=${VMX_PRI})
exten => a,n(apri),Set(VMX_ADEST_PRI=${DB_RESULT})
exten => a,n,Goto(${VMX_ADEST_CONTEXT},${VMX_ADEST_EXT},${VMX_ADEST_PRI})

exten => adef,1,VoiceMailMain(${ARG1}@${VMCONTEXT})
exten => adef,n,Hangup

exten => exit-FAILED,1,Playback(im-sorry&an-error-has-occured)
exten => exit-FAILED,n,GotoIf($["${ARG3}" = "RETURN"]?exit-RETURN,1)
exten => exit-FAILED,n,Hangup()

exten => exit-SUCCESS,1,GotoIf($["${ARG3}" = "RETURN"]?exit-RETURN,1)
exten => exit-SUCCESS,n,Playback(goodbye)
exten => exit-SUCCESS,n,Hangup()

exten => exit-USEREXIT,1,GotoIf($["${ARG3}" = "RETURN"]?exit-RETURN,1)
exten => exit-USEREXIT,n,Playback(goodbye)
exten => exit-USEREXIT,n,Hangup()

exten => exit-RETURN,1,Noop(Returning From Voicemail because macro)

exten => t,1,Hangup()
;------------------------------------------------------------------------

;------------------------------------------------------------------------
; [macro-simple-dial]
;------------------------------------------------------------------------
; This macro was derived from macro-exten-vm, which is what is normally used to
; ring an extension. It has been simplified and designed to never go to voicemail
; and always return regardless of the DIALSTATUS for any incomplete call.
;
; It's current primary purpose is to allow findmefollow ring an extension prior
; to trying the follow-me ringgroup that is provided.
;
; Ring an extension, if the extension is busy or there is no answer, return
; ARGS: $EXTENSION, $RINGTIME
;------------------------------------------------------------------------
[macro-simple-dial]
exten => s,1,Macro(user-callerid,SKIPTTL) ; already called from follow-me

; FROMCONTEXT was in the original macro-exten-vm where this macro was derived from. A
; search through all the modules does not come up with any place using this
; variable, but it is left here as a reminder in case there is functionality
; that eventually behaves in a certain way as a result of this variable being set
; and this macro has to masquerade as exten-vm.
;
exten => s,n,Set(EXTTOCALL=${ARG1})
exten => s,n,Set(RT=${ARG2})
exten => s,n,Set(CFUEXT=${DB(CFU/${EXTTOCALL})})
exten => s,n,Set(CFBEXT=${DB(CFB/${EXTTOCALL})})
exten => s,n,Macro(record-enable,${EXTTOCALL},IN)

exten => s,n,Macro(dial,${RT},${DIAL_OPTIONS},${EXTTOCALL})

exten => s,n,Set(PR_DIALSTATUS=${DIALSTATUS})

; if we return, thus no answer, and they have a CFU setting, then we try that next
;
exten => s,n,GosubIf($[$["${PR_DIALSTATUS}"="NOANSWER"] & $["foo${CFUEXT}"!="foo"]]?docfu,1) ; check for CFU in use on no answer
exten => s,n,GosubIf($[$["${PR_DIALSTATUS}"="BUSY"] & $["foo${CFBEXT}"!="foo"]]?docfb,1) ; check for CFB in use on busy
exten => s,n,Set(DIALSTATUS=${PR_DIALSTATUS})

; Nothing yet, then go to the end (which will just return, but in case we decide to do something with certain
; return situations, this is left in.
;
exten => s,n,Goto(s-${DIALSTATUS},1)

; Try the Call Forward on No Answer / Unavailable number.
; We want to try CFU if set, but we want the same ring timer as was set to our call (or do we want the
; system ringtimer? - probably not). Then if no answer there (assuming it doesn't drop into their vm or
; something we return, which will have the net effect of returning to the followme setup.)
;
; want to avoid going to other follow-me settings here. So check if the CFUEXT is a user and if it is
; then direct it straight to ext-local (to avoid getting intercepted by findmefollow) otherwise send it
; to from-internal since it may be an outside line.
;
exten => docfu,1,GotoIf( $[ "foo${DB(AMPUSER/${CFUEXT}/device)}" = "foo" ]?chlocal)
exten => docfu,n,Dial(Local/${CFUEXT}@ext-local,${RT},${DIAL_OPTIONS})
exten => docfu,n,Return
exten => docfu,n(chlocal),Dial(Local/${CFUEXT}@from-internal/n,${RT},${DIAL_OPTIONS})
exten => docfu,n,Return

; Try the Call Forward on Busy number
exten => docfb,1,GotoIf( $[ "foo${DB(AMPUSER/${CFBEXT}/device)}" = "foo" ]?chlocal)
exten => docfb,n,Dial(Local/${CFBEXT}@ext-local,${RT},${DIAL_OPTIONS})
exten => docfb,n,Return
exten => docfb,n(chlocal),Dial(Local/${CFBEXT}@from-internal/n,${RT},${DIAL_OPTIONS})
exten => docfb,n,Return

; In all cases of no connection, come here and simply return, since the calling dialplan will
; decide what to do next
exten => _s-.,1,NoOp(Extension is reporting ${EXTEN})
;------------------------------------------------------------------------

; get the voicemail context for the user in ARG1
[macro-get-vmcontext]
exten => s,1,Set(VMCONTEXT=${DB(AMPUSER/${ARG1}/voicemail)})
exten => s,2,GotoIf($["foo${VMCONTEXT}" = "foo"]?200:300)
exten => s,200,Set(VMCONTEXT=default)
exten => s,300,NoOp()

; For some reason, if I don't run setCIDname, CALLERID(name) will be blank in my AGI
; ARGS: none
[macro-fixcid]
exten => s,1,Set(CALLERID(name)=${CALLERID(name)})

; Ring groups of phones
; ARGS: comma separated extension list
; 1 - Ring Group Strategy
; 2 - ringtimer
; 3 - prefix
; 4 - extension list
[macro-rg-group]
exten => s,1,Macro(user-callerid,SKIPTTL) ; already called from ringgroup
exten => s,2,GotoIf($["${CALLERID(name):0:${LEN(${RGPREFIX})}}" != "${RGPREFIX}"]?4:3) ; check for old prefix
exten => s,3,Set(CALLERID(name)=${CALLERID(name):${LEN(${RGPREFIX})}}) ; strip off old prefix
exten => s,4,Set(RGPREFIX=${ARG3}) ; set new prefix
exten => s,5,Set(CALLERID(name)=${RGPREFIX}${CALLERID(name)}) ; add prefix to callerid name
exten => s,6,Set(RecordMethod=Group) ; set new prefix
exten => s,7,Macro(record-enable,${MACRO_EXTEN},${RecordMethod})
exten => s,8,Set(RingGroupMethod=${ARG1}) ;
exten => s,9,Macro(dial,${ARG2},${DIAL_OPTIONS},${ARG4})
exten => s,10,Set(RingGroupMethod='') ;

;
; Outgoing channel(s) are busy ... inform the client
; but use noanswer features like ringgroups don't break by being answered
; just to play the message.
;
[macro-outisbusy]
exten => s,1,Playback(all-circuits-busy-now,noanswer)
exten => s,n,Playback(pls-try-call-later,noanswer)
exten => s,n,Macro(hangupcall)

; What to do on hangup.
[macro-hangupcall]
exten => s,1,ResetCDR(w)
exten => s,n,NoCDR()

; Cleanup any remaining RG flag
;
exten => s,n,GotoIf($[ "x${USE_CONFIRMATION}" = "x" | "x${RINGGROUP_INDEX}" = "x" | "${CHANNEL}" != "${UNIQCHAN}"]?skiprg)
exten => s,n,Noop(Cleaning Up Confirmation Flag: RG/${RINGGROUP_INDEX}/${CHANNEL})
exten => s,n,DBDel(RG/${RINGGROUP_INDEX}/${CHANNEL})

; Cleanup any remaining BLKVM flag
;
exten => s,n(skiprg),GotoIf($[ "x${BLKVM_BASE}" = "x" | "BLKVM/${BLKVM_BASE}/${CHANNEL}" != "${BLKVM_OVERRIDE}" ]?skipblkvm)
exten => s,n,Noop(Cleaning Up Block VM Flag: ${BLKVM_OVERRIDE})
exten => s,n,DBDel(${BLKVM_OVERRIDE})

; Cleanup any remaining FollowMe DND flags
;
exten => s,n(skipblkvm),GotoIf($[ "x${FMGRP}" = "x" | "x${FMUNIQUE}" = "x" | "${CHANNEL}" != "${FMUNIQUE}" ]?theend)
exten => s,n,DBDel(FM/DND/${FMGRP}/${CHANNEL})

exten => s,n(theend),Hangup

[macro-faxreceive]
exten => s,1,Set(FAXFILE=${ASTSPOOLDIR}/fax/${UNIQUEID}.tif)
exten => s,2,Set(EMAILADDR=${FAX_RX_EMAIL})
exten => s,3,rxfax(${FAXFILE})
exten => s,103,Set(EMAILADDR=${FAX_RX_EMAIL})
exten => s,104,Goto(3)

; dialout and strip the prefix
[macro-dialout]
exten => s,1,Macro(user-callerid,SKIPTTL)
exten => s,2,GotoIf($["${ECID${CALLERID(number)}}" = ""]?5) ;check for CID override for exten
exten => s,3,Set(CALLERID(all)=${ECID${CALLERID(number)}})
exten => s,4,Goto(7)
exten => s,5,GotoIf($["${OUTCID_${ARG1}}" = ""]?7) ;check for CID override for trunk
exten => s,6,Set(CALLERID(all)=${OUTCID_${ARG1}})
exten => s,7,Set(length=${LEN(${DIAL_OUT_${ARG1}})})
exten => s,8,Dial(${OUT_${ARG1}}/${ARG2:${length}})
exten => s,9,Playtones(congestion)
exten => s,10,Congestion(5)
exten => s,109,Macro(outisbusy)

; dialout using default OUT trunk - no prefix
[macro-dialout-default]
exten => s,1,Macro(user-callerid,SKIPTTL)
exten => s,2,Macro(record-enable,${CALLERID(number)},OUT)
exten => s,3,Macro(outbound-callerid,${ARG1})
exten => s,4,Dial(${OUT}/${ARG1})
exten => s,5,Playtones(congestion)
exten => s,6,Congestion(5)
exten => s,105,Macro(outisbusy)

[macro-dialout-trunk-predial-hook]
; this macro intentially left blank so it may be safely overwritten for any custom
; requirements that an installatin may have.
;
; MACRO RETURN CODE: ${PREDIAL_HOOK_RET}
; if set to "BYPASS" then this trunk will be skipped
;

[macro-record-enable]
exten => s,1,GotoIf($[${LEN(${BLINDTRANSFER})} > 0]?2:4)
exten => s,2,ResetCDR(w)
exten => s,3,StopMonitor()
exten => s,4,AGI(recordingcheck,${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)},${UNIQUEID})
exten => s,5,Noop(No recording needed)
exten => s,999,MixMonitor(${CALLFILENAME}.wav)

;exten => s,3,BackGround(for-quality-purposes)
;exten => s,4,BackGround(this-call-may-be)
;exten => s,5,BackGround(recorded)

; This macro is for dev purposes and just dumps channel/app variables. Useful when designing new contexts.
[macro-dumpvars]
exten => s,1,Noop(ACCOUNTCODE=${ACCOUNTCODE})
exten => s,2,Noop(ANSWEREDTIME=${ANSWEREDTIME})
exten => s,3,Noop(BLINDTRANSFER=${BLINDTRANSFER})
exten => s,4,Noop(CALLERID=${CALLERID(all)})
exten => s,5,Noop(CALLERID(name)=${CALLERID(name)})
exten => s,6,Noop(CALLERID(number)=${CALLERID(number)})
exten => s,7,Noop(CALLINGPRES=${CALLINGPRES})
exten => s,8,Noop(CHANNEL=${CHANNEL})
exten => s,9,Noop(CONTEXT=${CONTEXT})
exten => s,10,Noop(DATETIME=${DATETIME})
exten => s,11,Noop(DIALEDPEERNAME=${DIALEDPEERNAME})
exten => s,12,Noop(DIALEDPEERNUMBER=${DIALEDPEERNUMBER})
exten => s,13,Noop(DIALEDTIME=${DIALEDTIME})
exten => s,14,Noop(DIALSTATUS=${DIALSTATUS})
exten => s,15,Noop(DNID=${DNID})
exten => s,16,Noop(EPOCH=${EPOCH})
exten => s,17,Noop(EXTEN=${EXTEN})
exten => s,18,Noop(HANGUPCAUSE=${HANGUPCAUSE})
exten => s,19,Noop(INVALID_EXTEN=${INVALID_EXTEN})
exten => s,20,Noop(LANGUAGE=${LANGUAGE})
exten => s,21,Noop(MEETMESECS=${MEETMESECS})
exten => s,22,Noop(PRIORITY=${PRIORITY})
exten => s,23,Noop(RDNIS=${RDNIS})
exten => s,24,Noop(SIPDOMAIN=${SIPDOMAIN})
exten => s,25,Noop(SIP_CODEC=${SIP_CODEC})
exten => s,26,Noop(SIPCALLID=${SIPCALLID})
exten => s,27,Noop(SIPUSERAGENT=${SIPUSERAGENT})
exten => s,29,Noop(TXTCIDNAME=${TXTCIDNAME})
exten => s,30,Noop(UNIQUEID=${UNIQUEID})
exten => s,31,Noop(TOUCH_MONITOR=${TOUCH_MONITOR})
exten => s,32,Noop(MACRO_CONTEXT=${MACRO_CONTEXT})
exten => s,33,Noop(MACRO_EXTEN=${MACRO_EXTEN})
exten => s,34,Noop(MACRO_PRIORITY=${MACRO_PRIORITY})

[macro-user-logon]
; check device type
;
exten => s,1,Set(DEVICETYPE=${DB(DEVICE/${CALLERID(number)}/type)})
exten => s,n,GotoIf($["${DEVICETYPE}" = "fixed"]?s-FIXED,1)
; get user's extension
;
exten => s,n,Set(AMPUSER=${ARG1})
exten => s,n,GotoIf($["${AMPUSER}" != ""]?gotpass)
exten => s,n,Playback(please-enter-your&extension)
exten => s,n,Read(AMPUSER,then-press-pound)
; get user's password and authenticate
;
exten => s,n(gotpass),Set(AMPUSERPASS=${DB(AMPUSER/${AMPUSER}/password)})
exten => s,n,GotoIf($[${LEN(${AMPUSERPASS})} = 0]?s-NOPASSWORD,1)
; do not continue if the user has already logged onto this device
;
exten => s,n,Set(DEVICEUSER=${DB(DEVICE/${CALLERID(number)}/user)})
exten => s,n,GotoIf($["${DEVICEUSER}" = "${AMPUSER}"]?s-ALREADYLOGGEDON,1)
exten => s,n,Authenticate(${AMPUSERPASS})
exten => s,n,DeadAGI(user_login_out.agi,login,${CALLERID(number)},${AMPUSER})
exten => s,n,Playback(vm-goodbye)

exten => s-FIXED,1,NoOp(Device is FIXED and cannot be logged into)
exten => s-FIXED,n,Playback(ha/phone)
exten => s-FIXED,n,SayDigits(${CALLERID(number)})
exten => s-FIXED,n,Playback(is-curntly-unavail&vm-goodbye)
exten => s-FIXED,n,Hangup ;TODO should play msg indicated device cannot be logged into

exten => s-ALREADYLOGGEDON,1,NoOp(This device has already been logged into by this user)
exten => s-ALREADYLOGGEDON,n,Playback(vm-goodbye)
exten => s-ALREADYLOGGEDON,n,Hangup ;TODO should play msg indicated device is already logged into

exten => s-NOPASSWORD,1,NoOp(This extension does not exist or no password is set)
exten => s-NOPASSWORD,n,Playback(an-error-has-occured&vm-goodbye)
exten => s-NOPASSWORD,n,Hangup ;TODO should play msg indicated device is already logged into

[macro-user-logoff]
; check device type
;
exten => s,1,Set(DEVICETYPE=${DB(DEVICE/${CALLERID(number)}/type)})
exten => s,n,GotoIf($["${DEVICETYPE}" = "fixed"]?s-FIXED,1)
exten => s,n,DeadAGI(user_login_out.agi,logout,${CALLERID(number)})
exten => s,n(done),Playback(vm-goodbye)

exten => s-FIXED,1,NoOp(Device is FIXED and cannot be logged out of)
exten => s-FIXED,n,Playback(an-error-has-occured&vm-goodbye)
exten => s-FIXED,n,Hangup ;TODO should play msg indicated device cannot be logged into

; Privacy Manager Macro makes sure that any calls that don't pass the privacy manager are presented
; with congestion since there have been observed cases of the call continuing if not stopped with a
; congestion, and this provides a slightly more friendly 'sorry' message in case the user is
; legitamately trying to be cooperative.
;
; Note: the following options are configurable in privacy.conf:
;
; maxretries = 3 ; default value, number of retries before failing
; minlength = 10 ; default value, number of digits to be accepted as valid CID
;
[macro-privacy-mgr]
exten => s,1,Set(KEEPCID=${CALLERID(num)})
exten => s,n,GotoIf($["foo${CALLERID(num):0:1}"="foo+"]?CIDTEST2:CIDTEST1)
exten => s,n(CIDTEST1),Set(TESTCID=${MATH(1+${CALLERID(num)})})
exten => s,n,Goto(TESTRESULT)
exten => s,n(CIDTEST2),Set(TESTCID=${MATH(1+${CALLERID(num):1})})
exten => s,n(TESTRESULT),GotoIf($["foo${TESTCID}"="foo"]?CLEARCID:PRIVMGR)
exten => s,n(CLEARCID),Set(CALLERID(num)=)
exten => s,n(PRIVMGR),PrivacyManager()
exten => s,n,GotoIf($["${PRIVACYMGRSTATUS}"="FAILED"]?fail)
exten => s,n,SetCallerPres(allowed_passed_screen); stop gap until app_privacy.c clears unavailble bit
exten => s,PRIVMGR+101(fail),Noop(STATUS: ${PRIVACYMGRSTATUS} CID: ${CALLERID(num)} ${CALLERID(name)} CALLPRES: ${CALLLINGPRES})
exten => s,n,Playback(sorry-youre-having-problems)
exten => s,n,Playback(goodbye)
exten => s,n,Playtones(congestion)
exten => s,n,Congestion(5)

; Text-To-Speech related macros
; These all follow common actions. First try to playback a file "tts/custom-md5"
; where "md5" is the md5() of whatever is going to be played. If that doesn't exist,
; try to playback using macro-tts-sayXXXXX (where XXXXX is text/digits/etc, same as
; the macro below). If that macro exits with MACRO_OFFSET=100, then it's done,
; therwise, fallback to the default asterisk method.
;
; say text is purely for text-to-speech, there is no fallback
[macro-saytext]
exten => s,1,Noop(Trying custom SayText playback for "${ARG1}")
exten => s,n,Playback(tts/custom-${MD5(${ARG1})})
exten => s,n,GotoIf($["${PLAYBACKSTATUS}"="SUCCESS"]?done)
; call tts-saytext. This should set MACRO_OFFSET=101 if it was successful
exten => s,n(tts),Macro(tts-saytext,${ARG1},${ARG2},${ARG3})
exten => s,n,Noop(No text-to-speech handler for SayText, cannot say "${ARG1}")
exten => s,n,Goto(done)
exten => s,tts+101,Noop(tts handled saytext)

; say name is for saying names typically, but fallsback to using SayAlpha
; (saying the word letter-by-letter)
[macro-sayname]
exten => s,1,Noop(Trying custom SayName playback for "${ARG1}")
exten => s,n,Playback(tts/custom-${MD5(${ARG1})})
exten => s,n,GotoIf($["${PLAYBACKSTATUS}"="SUCCESS"]?done)
; call tts-sayalpha. This should set MACRO_OFFSET=101 if it was successful
exten => s,n(tts),Macro(tts-sayalpha,${ARG1},${ARG2},${ARG3})
exten => s,n,SayAlpha(${ARG1})
exten => s,n,Goto(done)
exten => s,tts+101,Noop(tts handled sayname)

; Say number is for saying numbers (eg "one thousand forty six")
[macro-saynumber]
exten => s,1,Noop(Trying custom SayNumber playback for "${ARG1}")
exten => s,n,Playback(tts/custom-${MD5(${ARG1})})
exten => s,n,GotoIf($["${PLAYBACKSTATUS}"="SUCCESS"]?done)
; call tts-saynumber. This should set MACRO_OFFSET=101 if it was successful
exten => s,n(tts),Macro(tts-saynumber,${ARG1},${ARG2},${ARG3})
exten => s,n,SayNumber(${ARG1})
exten => s,n,Goto(done)
exten => s,tts+101,Noop(tts handled saynumber)

; Say digits is for saying digits one-by-one (eg, "one zero four six")
[macro-saydigits]
exten => s,1,Noop(Trying custom SayDigits playback for "${ARG1}")
exten => s,n,Playback(tts/custom-${MD5(${ARG1})})
exten => s,n,GotoIf($["${PLAYBACKSTATUS}"="SUCCESS"]?done)
; call tts-saydigits. This should set MACRO_OFFSET=101 if it was successful
exten => s,n(tts),Macro(tts-saydigits,${ARG1},${ARG2},${ARG3})
exten => s,n,SayDigits(${ARG1})
exten => s,n,Goto(done)

;
; ############################################################################
; Inbound Contexts [from]
; ############################################################################

[from-sip-external]
;give external sip users congestion and hangup
; Yes. This is _really_ meant to be _. - I know asterisk whinges about it, but
; I do know what I'm doing. This is correct.
exten => _.,1,NoOp(Received incoming SIP connection from unknown peer to ${EXTEN})
exten => _.,n,Set(DID=${IF($["${EXTEN:1:2}"=""]?s:${EXTEN})})
exten => _.,n,Goto(s,1)
exten => s,1,GotoIf($["${ALLOW_SIP_ANON}"="yes"]?from-trunk,${DID},1)
exten => s,n,Set(TIMEOUT(absolute)=15)
exten => s,n,Answer
exten => s,n,Wait(2)
exten => s,n,Playback(ss-noservice)
exten => s,n,Playtones(congestion)
exten => s,n,Congestion(5)
exten => h,1,NoOp(Hangup)
exten => i,1,NoOp(Invalid)
exten => t,1,NoOp(Timeout)

[from-internal-xfer]
; applications are now mostly all found in from-internal-additional in _custom.conf
include => parkedcalls
include => from-internal-custom
;allow phones to dial other extensions
include => ext-fax
;allow phones to access generated contexts
;
; MODIFIED (PL)
;
; Currently the include for findmefollow is being auto-generated before ext-local which is the desired behavior.
; However, I haven't been able to do anything that I know of to force this. We need to determine if it should
; be hardcoded into here to make sure it doesn't change with some configuration. For now I will leave it out
; until we can discuss this.
;
include => ext-local-confirm
include => findmefollow-ringallv2
include => from-internal-additional
; This causes grief with '#' transfers, commenting out for the moment.
; include => bad-number
exten => s,1,Macro(hangupcall)
exten => h,1,Macro(hangupcall)

[from-internal]
include => from-internal-xfer
include => bad-number

[from-zaptel]
exten => _X.,1,Set(DID=${EXTEN})
exten => _X.,n,Goto(s,1)
exten => s,1,NoOp(Entering from-zaptel with DID == ${DID})
; Some trunks _require_ a RINGING be sent before an Answer.
exten => s,n,Ringing()
; If ($did == "") { $did = "s"; }
exten => s,n,Set(DID=${IF($["${DID}"= ""]?s:${DID})})
exten => s,n,NoOp(DID is now ${DID})
exten => s,n,GotoIf($["${CHANNEL:0:3}"="Zap"]?zapok:notzap)
exten => s,n(notzap),Goto(from-internal,${DID},1)
; If there's no ext-did,s,1, that means there's not a no did/no cid route. Hangup.
exten => s,n,Macro(hangup)
exten => s,n(zapok),NoOp(Is a Zaptel Channel)
exten => s,n,Set(CHAN=${CHANNEL:4})
exten => s,n,Set(CHAN=${CUT(CHAN,-,1)})
exten => s,n,Macro(from-zaptel-${CHAN},${DID},1)
; If nothing there, then treat it as a DID
exten => s,n,NoOp(Returned from Macro from-zaptel-${CHAN})
exten => s,n,Goto(from-internal,${DID},1)
exten => fax,1,Goto(ext-fax,in_fax,1)

;------------------------------------------------------------------------
; [macro-setmusic]
;------------------------------------------------------------------------
; CONTEXT: macro-setmusic
; PURPOSE: to turn off moh on routes where it is not desired
;
;------------------------------------------------------------------------
[macro-setmusic]
exten => s,1,NoOp(Setting Outbound Route MoH To: ${ARG1})
exten => s,2,SetMusicOnHold(${ARG1})
;------------------------------------------------------------------------

; ##########################################
; ## Ring Groups with Confirmation macros ##
; ##########################################
; Used by followme and ringgroups

;------------------------------------------------------------------------
; [macro-dial-confirm]
;------------------------------------------------------------------------
; This has now been incorporated into dialparties. It still only works with ringall
; and ringall-prim strategies. Have not investigated why it doesn't work with
; hunt and memory hunt.
;
;------------------------------------------------------------------------
[macro-dial-confirm]
; This was written to make it easy to use macro-dial-confirm instead of macro-dial in generated dialplans.
; This takes the same paramaters, with an additional paramater of the ring group Number
; ARG1 is the timeout
; ARG2 is the DIAL_OPTIONS
; ARG3 is a list of xtns to call - 203-222-240-123123123#-211
; ARG4 is the ring group number

; This sets a unique value to indicate that the channel is ringing. This is used for warning slow
; users that the call has already been picked up.
;
exten => s,1,Set(DB(RG/${ARG4}/${CHANNEL})=RINGING)

; We need to keep that channel variable, because it'll change when we do this dial, so set it to
; fallthrough to every sibling.
;
exten => s,n,Set(__UNIQCHAN=${CHANNEL})

; The calling ringgroup should have set RingGroupMethod appropriately. We need to set two
; additional parameters:
;
; USE_CONFIRMATION, RINGGROUP_INDEX
;
; Thse are passed to inform dialparties to place external calls through the [grps] context
;
exten => s,n,Set(USE_CONFIRMATION=TRUE)
exten => s,n,Set(RINGGROUP_INDEX=${ARG4})
exten => s,n,Set(ARG4=) ; otherwise it gets passed to dialparties.agi which processes it (prob bug)

exten => s,n,Macro(dial,${ARG1},${ARG2},${ARG3})

; delete the variable, if we are here, we are done trying to dial and it may have been left around
;
exten => s,n,DBDel(RG/${RINGGROUP_INDEX}/${CHANNEL})
exten => s,n,Set(USE_CONFIRMATION=)
exten => s,n,Set(RINGGROUP_INDEX=)
;------------------------------------------------------------------------

;------------------------------------------------------------------------
; [macro-auto-confirm]
;------------------------------------------------------------------------
; This macro is called from ext-local-confirm to auto-confirm a call so that other extensions
; are aware that the call has been answered.
;
;------------------------------------------------------------------------
[macro-auto-confirm]
exten => s,1,Set(__MACRO_RESULT=)
exten => s,n,Set(__CWIGNORE=)
exten => s,n,DBDel(${BLKVM_OVERRIDE})
exten => s,n,DBDel(RG/${ARG1}/${UNIQCHAN})

;------------------------------------------------------------------------
; [macro-auto-blkvm]
;------------------------------------------------------------------------
; This macro is called for any extension dialed form a queue, ringgroup
; or followme, so that the answering extension can clear the voicemail block
; override allow subsequent transfers to properly operate.
;
;------------------------------------------------------------------------
[macro-auto-blkvm]
exten => s,1,Set(__MACRO_RESULT=)
exten => s,n,Set(__CWIGNORE=)
exten => s,n,DBDel(${BLKVM_OVERRIDE})

;------------------------------------------------------------------------
; [ext-local-confirm]
;------------------------------------------------------------------------
; If call confirm is being used in a ringgroup, then calls that do not require confirmation are sent
; to this extension instead of straight to the device.
;
; The sole purpose of sending them here is to make sure we run Macro(auto-confirm) if this
; extension answers the line. This takes care of clearing the database key that is used to inform
; other potential late comers that the extension has been answered by someone else.
;
; ALERT_INFO is deprecated in Asterisk 1.4 but still used throughout the FreePBX dialplan and
; usually set by dialparties.agi. This allows ineritance. Since no dialparties.agi here, set the
; header if it is set.
;
;------------------------------------------------------------------------
[ext-local-confirm]
exten => _LC-.,1,Noop(IN ext-local-confirm with - RT: ${RT}, RG_IDX: ${RG_IDX})
exten => _LC-.,n,GotoIf($["x${ALERT_INFO}"="x"]?godial)
exten => _LC-.,n,SIPAddHeader(Alert-Info: ${ALERT_INFO})
exten => _LC-.,n(godial),dial(${DB(DEVICE/${EXTEN:3}/dial)},${RT},M(auto-confirm^${RG_IDX})${DIAL_OPTIONS})

;------------------------------------------------------------------------
; [macro-confirm]
;------------------------------------------------------------------------
; CONTEXT: macro-confirm
; PURPOSE: added default message if none supplied
;
; Follom-Me and Ringgroups provide an option to supply a message to be
; played as part of the confirmation. These changes have added a default
; message if none is supplied.
;
;------------------------------------------------------------------------
[macro-confirm]
exten => s,1,Set(LOOPCOUNT=0)
exten => s,n,Noop(CALLCONFIRMCID: ${CALLCONFIRMCID})

; We set ABORT rather than CONTINUE, as we want the server to forget about this channel
; if it's declined, hung up, or timed out. We don't want it to continue on to the next
; step in the dialplan, which could be anything!
exten => s,n,Set(__MACRO_RESULT=ABORT)

; ARG1 is the announcement to play to tell the user that they've got a call they need
; to confirm. Something along the lines of 'You have an incoming call. Press 1 to accept, 9 to reject'
exten => s,n,Set(MSG1=${IF($["foo${ARG1}" != "foo"]?${ARG1}:"incoming-call-1-accept-2-decline")})
exten => s,n(start),Read(INPUT,${MSG1},1,,1,5)

; So. We've now read something, or nothing. We should check to make sure that the call hasn't
; already been answered by someone else. If it has, send this call to toolate
exten => s,n,GotoIf(${DB_EXISTS(RG/${ARG3}/${UNIQCHAN})}?check:toolate)

; We passed that test, so it means the call hasn't been answered. Has this user pushed 1? If so,
; then go to OK.
exten => s,n(check),GotoIf($["${INPUT}"="1"]?ok)

; If they've pushed 9, then they definately don't want the call. Just pretend there was no response
; and go to noanswer (or 2 since that will be default for asterisk)
exten => s,n,GotoIf($["${INPUT}"="9"]?noanswer)
exten => s,n,GotoIf($["${INPUT}"="2"]?noanswer)
exten => s,n,GotoIf($["${INPUT}"="3"]?playcid)

; Increment LOOPCOUNT, and check to make sure we haven't played it 5 times by now. We assume that
; the person is able to push '1' in a reasonably short time.
exten => s,n,Set(LOOPCOUNT=$[ ${LOOPCOUNT} + 1 ])
exten => s,n,GotoIf($[ ${LOOPCOUNT}

; If we're here, that means we've played it MORE than 5 times. Set __MACRO_RESULT=ABORT, well, just
; coz, and goto fin, which is the last line, meaning it returns to the previous Dial, and pretends as
; if nothing has happened.
exten => s,n(noanswer),Set(__MACRO_RESULT=ABORT)
exten => s,n,Goto(fin)

; Test play callerid
;
exten => s,n(playcid),Noop(Playing CID: ${CALLCONFIRMCID})
exten => s,n,SayDigits(${CALLCONFIRMCID})
exten => s,n,Goto(start)

; If we're here, it's because the call was already accepted by someone else.
exten => s,n(toolate),Set(MSG2=${IF($["foo${ARG2}" != "foo"]?${ARG2}:"incoming-call-no-longer-avail")})
exten => s,n,Playback(${MSG2})
exten => s,n,Goto(noanswer)

; If we made it here, it's because the call _WAS_ accepted, AND it's still ringing. We delete the
; database entry (so that the DB_EXISTS line above will trigger a 'toolate' jump), and set the
; MACRO_RESULT variable to NOTHING. This is the magic string that joins both legs of the call together
exten => s,n(ok),DBDel(RG/${ARG3}/${UNIQCHAN})
exten => s,n,DBDel(${BLKVM_OVERRIDE})
exten => s,n,Set(__MACRO_RESULT=)

; The end.
exten => s,n(fin),NoOp(Finished)
exten => h,1,Noop(Hangup Extension in macro-confirm)
exten => h,n,Macro(hangupcall)

;------------------------------------------------------------------------

;------------------------------------------------------------------------
; [findmefollow-ringallv2]
;------------------------------------------------------------------------
; This context, to be included in from-internal, implements the PreRing part of findmefollow
; as well as the GroupRing part. It also communicates between the two so that if DND is set
; on the primary extension, and mastermode is enabled, then the other extensions will not ring
;
;------------------------------------------------------------------------
[findmefollow-ringallv2]
exten => _FMPR-.,1,Noop(In FMPR ${FMGRP} with ${EXTEN:5})
exten => _FMPR-.,n,Set(RingGroupMethod=)
exten => _FMPR-.,n,Set(USE_CONFIRMATION=)
exten => _FMPR-.,n,Set(RINGGROUP_INDEX=)
exten => _FMPR-.,n,Macro(simple-dial,${EXTEN:5},${FMREALPRERING})
exten => _FMPR-.,n,GotoIf($["${DIALSTATUS}" != "BUSY"]?nodnd)
exten => _FMPR-.,n,Set(DB(FM/DND/${FMGRP}/${FMUNIQUE})=DND)
exten => _FMPR-.,n(nodnd),Noop(Ending FMPR ${FMGRP} with ${EXTEN:5} and dialstatus ${DIALSTATUS})
exten => _FMPR-.,n,Hangup()

exten => _FMGL-.,1,Noop(In FMGL ${FMGRP} with ${EXTEN:5})
exten => _FMGL-.,n,GotoIf($["${DB(FM/DND/${FMGRP}/${FMUNIQUE})}" = "DND"]?dodnd)
exten => _FMGL-.,n,Wait(1)
exten => _FMGL-.,n,GotoIf($["${DB(FM/DND/${FMGRP}/${FMUNIQUE})}" = "DND"]?dodnd)
exten => _FMGL-.,n,Wait(1)
exten => _FMGL-.,n,GotoIf($["${DB(FM/DND/${FMGRP}/${FMUNIQUE})}" = "DND"]?dodnd)
exten => _FMGL-.,n,Wait(${FMPRERING})
exten => _FMGL-.,n,GotoIf($["${DB(FM/DND/${FMGRP}/${FMUNIQUE})}" = "DND"]?dodnd)
exten => _FMGL-.,n,DBDel(FM/DND/${FMGRP}/${FMUNIQUE})
exten => _FMGL-.,n(dodial),Macro(dial,${FMGRPTIME},${DIAL_OPTIONS},${EXTEN:5})
exten => _FMGL-.,n,Noop(Ending FMGL ${FMGRP} with ${EXTEN:5} and dialstatus ${DIALSTATUS})
exten => _FMGL-.,n,Hangup()
exten => _FMGL-.,n+10(dodnd),DBDel(FM/DND/${FMGRP}/${FMUNIQUE})
exten => _FMGL-.,n,GotoIf($["${FMPRIME}" = "FALSE"]?dodial)
exten => _FMGL-.,n,Noop(Got DND in FMGL ${FMGRP} with ${EXTEN:5} in ${RingGroupMethod} mode, aborting)
exten => _FMGL-.,n,Hangup()

;------------------------------------------------------------------------

; ############################################################################
; Extension Contexts [ext]
; ############################################################################

[ext-fax]
exten => s,1,Answer
exten => s,2,Goto(in_fax,1)
exten => in_fax,1,StopPlayTones
exten => in_fax,2,GotoIf($["${FAX_RX}" = "system"]?3:analog_fax,1)
exten => in_fax,3,Macro(faxreceive)
exten => in_fax,4,Hangup
exten => analog_fax,1,GotoIf($["${FAX_RX}" = "disabled"]?4:2) ;if fax is disabled, just hang up
exten => analog_fax,2,Set(DIAL=${DB(DEVICE/${FAX_RX}/dial)});
exten => analog_fax,3,Dial(${DIAL},20,d)
exten => analog_fax,4,Hangup
;exten => out_fax,1,wait(7)
exten => out_fax,1,txfax(${TXFAX_NAME},caller)
exten => out_fax,2,Hangup
exten => h,1,system(/var/lib/asterisk/bin/fax-process.pl --to ${EMAILADDR} --from ${FAX_RX_FROM} --subject "Fax from ${URIENCODE(${CALLERID(number)})} ${URIENCODE(${CALLERID(name)})}" --attachment fax_${URIENCODE(${CALLERID(number)})}.pdf --type application/pdf --file ${FAXFILE});
exten => h,2,Hangup()

;this is where parked calls go if they time-out. Should probably re-ring
[default]
include => ext-local
exten => s,1,Playback(vm-goodbye)
exten => s,2,Macro(hangupcall)

; do not edit this file, this is an auto-generated file by freepbx
; all modifications must be done from the web gui

[globals]
#include globals_custom.conf
CALLFILENAME = ""
DIAL_OPTIONS = tr
TRUNK_OPTIONS =
DIAL_OUT = 9
FAX =
FAX_RX = system
FAX_RX_EMAIL = fax@mydomain.com
FAX_RX_FROM = freepbx@gmail.com
INCOMING = group-all
NULL = ""
OPERATOR =
OPERATOR_XTN = 10
PARKNOTIFY = SIP/200
RECORDEXTEN = ""
RINGTIMER = 20
DIRECTORY = last
AFTER_INCOMING =
IN_OVERRIDE = forcereghours
REGTIME = 7:55-17:05
REGDAYS = mon-fri
DIRECTORY_OPTS =
OUTDISABLE_2 = off
OUTFAIL_2 =
VM_PREFIX = *
VM_OPTS =
VM_GAIN =
VM_DDTYPE = u
TIMEFORMAT = IMp
TONEZONE = us
ALLOW_SIP_ANON = yes
VMX_CONTEXT = from-internal
VMX_PRI = 1
VMX_TIMEDEST_CONTEXT =
VMX_TIMEDEST_EXT = dovm
VMX_TIMEDEST_PRI = 1
VMX_LOOPDEST_CONTEXT =
VMX_LOOPDEST_EXT = dovm
VMX_LOOPDEST_PRI = 1
VMX_OPTS_TIMEOUT =
VMX_OPTS_LOOP =
VMX_OPTS_DOVM =
VMX_TIMEOUT = 2
VMX_REPEAT = 1
VMX_LOOPS = 1
TRANSFER_CONTEXT = from-internal-xfer
OUTKEEPCID_2 = off
OUTCID_2 = "Asset Recovery Corp"
OUTMAXCHANS_2 = 1
OUTPREFIX_2 =
OUT_2 = ZAP/4
DIALOUTIDS = 2/
ASTETCDIR = /etc/asterisk
ASTMODDIR = /usr/lib/asterisk/modules
ASTVARLIBDIR = /var/lib/asterisk
ASTAGIDIR = /var/lib/asterisk/agi-bin
ASTSPOOLDIR = /var/spool/asterisk
ASTRUNDIR = /var/run/asterisk
ASTLOGDIR = /var/log/asterisk
CWINUSEBUSY = true
AMPMGRUSER = admin
AMPMGRPASS = amp111
ASTVERSION = 1.4.18

;end of [globals]

[app-callwaiting-cwoff]
include => app-callwaiting-cwoff-custom
exten => *71,1,Answer
exten => *71,n,Wait(1)
exten => *71,n,Macro(user-callerid,)
exten => *71,n,dbDel(CW/${AMPUSER})
exten => *71,n,Playback(call-waiting&de-activated)
exten => *71,n,Macro(hangupcall,)

; end of [app-callwaiting-cwoff]

[app-callwaiting-cwon]
include => app-callwaiting-cwon-custom
exten => *70,1,Answer
exten => *70,n,Wait(1)
exten => *70,n,Macro(user-callerid,)
exten => *70,n,Set(DB(CW/${AMPUSER})=ENABLED)
exten => *70,n,Playback(call-waiting&activated)
exten => *70,n,Macro(hangupcall,)

; end of [app-callwaiting-cwon]

[app-blacklist-check]
include => app-blacklist-check-custom
exten => s,1,LookupBlacklist()
exten => s,n,GotoIf($["${LOOKUPBLSTATUS}"="FOUND"]?blacklisted)
exten => s,n,Return()
exten => s,n(blacklisted),Answer
exten => s,n,Wait(1)
exten => s,n,Zapateller()
exten => s,n,Playback(ss-noservice)
exten => s,n,Hangup

; end of [app-blacklist-check]

[app-blacklist]
include => app-blacklist-custom
exten => *30,1,Goto(app-blacklist-add,s,1)
exten => *32,1,Goto(app-blacklist-last,s,1)
exten => *31,1,Goto(app-blacklist-remove,s,1)

; end of [app-blacklist]

[app-blacklist-add]
include => app-blacklist-add-custom
exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n,Playback(enter-num-blacklist)
exten => s,n,Set(TIMEOUT(digit)=5)
exten => s,n,Set(TIMEOUT(response)=60)
exten => s,n,Read(blacknr,then-press-pound,,,,)
exten => s,n,SayDigits(${blacknr})
exten => s,n,Playback(if-correct-press&digits/1)
exten => s,n,Noop(Waiting for input)
exten => s,n(end),WaitExten(60,)
exten => s,n,Playback(sorry-youre-having-problems&goodbye)
exten => 1,1,Set(DB(blacklist/${blacknr})=1)
exten => 1,n,Playback(num-was-successfully&added)
exten => 1,n,Wait(1)
exten => 1,n,Hangup

; end of [app-blacklist-add]

[app-blacklist-last]
include => app-blacklist-last-custom
exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n,Set(lastcaller=${DB(CALLTRACE/${CALLERID(number)})})
exten => s,n,GotoIf($[ $[ "${lastcaller}" = "" ] | $[ "${lastcaller}" = "unknown" ] ]?noinfo)
exten => s,n,Playback(privacy-to-blacklist-last-caller&telephone-number)
exten => s,n,SayDigits(${lastcaller})
exten => s,n,Set(TIMEOUT(digit)=3)
exten => s,n,Set(TIMEOUT(response)=7)
exten => s,n,Playback(if-correct-press&digits/1)
exten => s,n,Goto(end)
exten => s,n(noinfo),Playback(unidentified-no-callback)
exten => s,n,Hangup
exten => s,n,Noop(Waiting for input)
exten => s,n(end),WaitExten(60,)
exten => s,n,Playback(sorry-youre-having-problems&goodbye)
exten => 1,1,Set(DB(blacklist/${lastcaller})=1)
exten => 1,n,Playback(num-was-successfully)
exten => 1,n,Playback(added)
exten => 1,n,Wait(1)
exten => 1,n,Hangup

; end of [app-blacklist-last]

[app-blacklist-remove]
include => app-blacklist-remove-custom
exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n,Playback(entr-num-rmv-blklist)
exten => s,n,Set(TIMEOUT(digit)=5)
exten => s,n,Set(TIMEOUT(response)=60)
exten => s,n,Read(blacknr,then-press-pound,,,,)
exten => s,n,SayDigits(${blacknr})
exten => s,n,Playback(if-correct-press&digits/1)
exten => s,n,Noop(Waiting for input)
exten => s,n(end),WaitExten(60,)
exten => s,n,Playback(sorry-youre-having-problems&goodbye)
exten => 1,1,dbDel(blacklist/${blacknr})
exten => 1,n,Playback(num-was-successfully&removed)
exten => 1,n,Wait(1)
exten => 1,n,Hangup

; end of [app-blacklist-remove]

[app-cf-busy-off]
include => app-cf-busy-off-custom
exten => *91,1,Answer
exten => *91,n,Wait(1)
exten => *91,n,Macro(user-callerid,)
exten => *91,n,dbDel(CFB/${AMPUSER})
exten => *91,n,Playback(call-fwd-on-busy&de-activated)
exten => *91,n,Macro(hangupcall,)
exten => _*91.,1,Answer
exten => _*91.,n,Wait(1)
exten => _*91.,n,Set(fromext=${EXTEN:3})
exten => _*91.,n,dbDel(CFB/${fromext})
exten => _*91.,n,Playback(call-fwd-on-busy&for&extension)
exten => _*91.,n,SayDigits(${fromext})
exten => _*91.,n,Playback(cancelled)
exten => _*91.,n,Macro(hangupcall,)

; end of [app-cf-busy-off]

[app-cf-busy-off-any]
include => app-cf-busy-off-any-custom
exten => *92,1,Answer
exten => *92,n,Wait(1)
exten => *92,n,Playback(please-enter-your&extension)
exten => *92,n,Read(fromext,then-press-pound,,,,)
exten => *92,n,Wait(1)
exten => *92,n,dbDel(CFB/${fromext})
exten => *92,n,Playback(call-fwd-on-busy&for&extension)
exten => *92,n,SayDigits(${fromext})
exten => *92,n,Playback(cancelled)
exten => *92,n,Macro(hangupcall,)

; end of [app-cf-busy-off-any]

[app-cf-busy-on]
include => app-cf-busy-on-custom
exten => *90,1,Answer
exten => *90,n,Wait(1)
exten => *90,n,Macro(user-callerid,)
exten => *90,n,Playback(call-fwd-on-busy)
exten => *90,n,Playback(please-enter-your&extension)
exten => *90,n,Read(fromext,then-press-pound,,,,)
exten => *90,n,Set(fromext=${IF($["foo${fromext}"="foo"]?${AMPUSER}:${fromext})})
exten => *90,n,Wait(1)
exten => *90,n(startread),Playback(ent-target-attendant)
exten => *90,n,Read(toext,then-press-pound,,,,)
exten => *90,n,GotoIf($["foo${toext}"="foo"]?startread)
exten => *90,n,Wait(1)
exten => *90,n,Set(DB(CFB/${fromext})=${toext})
exten => *90,n,Playback(call-fwd-on-busy&for&extension)
exten => *90,n,SayDigits(${fromext})
exten => *90,n,Playback(is-set-to)
exten => *90,n,SayDigits(${toext})
exten => *90,n,Macro(hangupcall,)
exten => _*90.,1,Answer
exten => _*90.,n,Wait(1)
exten => _*90.,n,Macro(user-callerid,)
exten => _*90.,n,Set(DB(CFB/${AMPUSER})=${EXTEN:3})
exten => _*90.,n,Playback(call-fwd-on-busy&for&extension)
exten => _*90.,n,SayDigits(${AMPUSER})
exten => _*90.,n,Playback(is-set-to)
exten => _*90.,n,SayDigits(${EXTEN:3})
exten => _*90.,n,Macro(hangupcall,)

; end of [app-cf-busy-on]

[app-cf-off]
include => app-cf-off-custom
exten => *73,1,Answer
exten => *73,n,Wait(1)
exten => *73,n,Macro(user-callerid,)
exten => *73,n,dbDel(CF/${AMPUSER})
exten => *73,n,Playback(call-fwd-unconditional&de-activated)
exten => *73,n,Macro(hangupcall,)
exten => _*73.,1,Answer
exten => _*73.,n,Wait(1)
exten => _*73.,n,Set(fromext=${EXTEN:3})
exten => _*73.,n,dbDel(CF/${fromext})
exten => _*73.,n,Playback(call-fwd-unconditional&for&extension)
exten => _*73.,n,SayDigits(${fromext})
exten => _*73.,n,Playback(cancelled)
exten => _*73.,n,Macro(hangupcall,)

; end of [app-cf-off]

[app-cf-off-any]
include => app-cf-off-any-custom
exten => *74,1,Answer
exten => *74,n,Wait(1)
exten => *74,n,Playback(please-enter-your&extension)
exten => *74,n,Read(fromext,then-press-pound,,,,)
exten => *74,n,Wait(1)
exten => *74,n,dbDel(CF/${fromext})
exten => *74,n,Playback(call-fwd-unconditional&for&extension)
exten => *74,n,SayDigits(${fromext})
exten => *74,n,Playback(cancelled)
exten => *74,n,Macro(hangupcall,)

; end of [app-cf-off-any]

[app-cf-on]
include => app-cf-on-custom
exten => *72,1,Answer
exten => *72,n,Wait(1)
exten => *72,n,Macro(user-callerid,)
exten => *72,n,Playback(call-fwd-unconditional)
exten => *72,n,Playback(please-enter-your&extension)
exten => *72,n,Read(fromext,then-press-pound,,,,)
exten => *72,n,Set(fromext=${IF($["foo${fromext}"="foo"]?${AMPUSER}:${fromext})})
exten => *72,n,Wait(1)
exten => *72,n(startread),Playback(ent-target-attendant)
exten => *72,n,Read(toext,then-press-pound,,,,)
exten => *72,n,GotoIf($["foo${toext}"="foo"]?startread)
exten => *72,n,Wait(1)
exten => *72,n,Set(DB(CF/${fromext})=${toext})
exten => *72,n,Playback(call-fwd-unconditional&for&extension)
exten => *72,n,SayDigits(${fromext})
exten => *72,n,Playback(is-set-to)
exten => *72,n,SayDigits(${toext})
exten => *72,n,Macro(hangupcall,)
exten => _*72.,1,Answer
exten => _*72.,n,Wait(1)
exten => _*72.,n,Macro(user-callerid,)
exten => _*72.,n,Set(DB(CF/${AMPUSER})=${EXTEN:3})
exten => _*72.,n,Playback(call-fwd-unconditional&for&extension)
exten => _*72.,n,SayDigits(${AMPUSER})
exten => _*72.,n,Playback(is-set-to)
exten => _*72.,n,SayDigits(${EXTEN:3})
exten => _*72.,n,Macro(hangupcall,)

; end of [app-cf-on]

[app-cf-unavailable-off]
include => app-cf-unavailable-off-custom
exten => *53,1,Answer
exten => *53,n,Wait(1)
exten => *53,n,Macro(user-callerid,)
exten => *53,n,dbDel(CFU/${AMPUSER})
exten => *53,n,Playback(call-fwd-no-ans&de-activated)
exten => *53,n,Macro(hangupcall,)
exten => _*53.,1,Answer
exten => _*53.,n,Wait(1)
exten => _*53.,n,Set(fromext=${EXTEN:3})
exten => _*53.,n,dbDel(CFU/${fromext})
exten => _*53.,n,Playback(call-fwd-no-ans&for&extension)
exten => _*53.,n,SayDigits(${fromext})
exten => _*53.,n,Playback(cancelled)
exten => _*53.,n,Macro(hangupcall,)

; end of [app-cf-unavailable-off]

[app-cf-unavailable-on]
include => app-cf-unavailable-on-custom
exten => *52,1,Answer
exten => *52,n,Wait(1)
exten => *52,n,Macro(user-callerid,)
exten => *52,n,Playback(call-fwd-no-ans)
exten => *52,n,Playback(please-enter-your&extension)
exten => *52,n,Read(fromext,then-press-pound,,,,)
exten => *52,n,Set(fromext=${IF($["foo${fromext}"="foo"]?${AMPUSER}:${fromext})})
exten => *52,n,Wait(1)
exten => *52,n(startread),Playback(ent-target-attendant)
exten => *52,n,Read(toext,then-press-pound,,,,)
exten => *52,n,GotoIf($["foo${toext}"="foo"]?startread)
exten => *52,n,Wait(1)
exten => *52,n,Set(DB(CFU/${fromext})=${toext})
exten => *52,n,Playback(call-fwd-no-ans&for&extension)
exten => *52,n,SayDigits(${fromext})
exten => *52,n,Playback(is-set-to)
exten => *52,n,SayDigits(${toext})
exten => *52,n,Macro(hangupcall,)
exten => _*52.,1,Answer
exten => _*52.,n,Wait(1)
exten => _*52.,n,Macro(user-callerid,)
exten => _*52.,n,Set(DB(CFU/${AMPUSER})=${EXTEN:3})
exten => _*52.,n,Playback(call-fwd-no-ans&for&extension)
exten => _*52.,n,SayDigits(${AMPUSER})
exten => _*52.,n,Playback(is-set-to)
exten => _*52.,n,SayDigits(${EXTEN:3})
exten => _*52.,n,Macro(hangupcall,)

; end of [app-cf-unavailable-on]

[app-daynight-toggle]
include => app-daynight-toggle-custom
exten => s,1,Set(DAYNIGHTMODE=${DB(DAYNIGHT/C${INDEX})})
exten => s,n,GotoIf($["${DAYNIGHTMODE}" = "NIGHT"]?day:night)
exten => s,n(day),Set(DB(DAYNIGHT/C${INDEX})=DAY)
exten => s,n,Playback(beep&silence/1&day&reception&digits/${INDEX}&enabled)
exten => s,n,Hangup
exten => s,n(night),Set(DB(DAYNIGHT/C${INDEX})=NIGHT)
exten => s,n,Playback(beep&silence/1&beep&silence/1&day&reception&digits/${INDEX}&disabled)
exten => s,n,Hangup

; end of [app-daynight-toggle]

[app-dnd-off]
include => app-dnd-off-custom
exten => *79,1,Answer
exten => *79,n,Wait(1)
exten => *79,n,Macro(user-callerid,)
exten => *79,n,dbDel(DND/${AMPUSER})
exten => *79,n,Playback(do-not-disturb&de-activated)
exten => *79,n,Macro(hangupcall,)

; end of [app-dnd-off]

[app-dnd-on]
include => app-dnd-on-custom
exten => *78,1,Answer
exten => *78,n,Wait(1)
exten => *78,n,Macro(user-callerid,)
exten => *78,n,Set(DB(DND/${AMPUSER})=YES)
exten => *78,n,Playback(do-not-disturb&activated)
exten => *78,n,Macro(hangupcall,)

; end of [app-dnd-on]

[macro-speeddial-lookup]
include => macro-speeddial-lookup-custom
exten => s,1,GotoIf($["${ARG2}"=""]]?lookupsys)
exten => s,n,Set(SPEEDDIALNUMBER=)
exten => s,n(lookupuser),Set(SPEEDDIALNUMBER=${DB(AMPUSER/${ARG2}/speeddials/${ARG1})})
exten => s,n,GotoIf($["${SPEEDDIALNUMBER}"=""]?lookupsys)
exten => s,n,Noop(Found speeddial ${ARG1} for user ${ARG2}: ${SPEEDDIALNUMBER})
exten => s,n,Goto(end)
exten => s,lookupuser+101(lookupsys),Set(SPEEDDIALNUMBER=${DB(sysspeeddials/${ARG1})})
exten => s,n,GotoIf($["${SPEEDDIALNUMBER}"=""]?failed)
exten => s,n,Noop(Found system speeddial ${ARG1}: ${SPEEDDIALNUMBER})
exten => s,n,Goto(end)
exten => s,lookupsys+101(failed),Noop(No system or user speeddial found)
exten => s,n(end),Noop(End of Speeddial-lookup)

; end of [macro-speeddial-lookup]

[app-speeddial]
include => app-speeddial-custom
exten => _*0.,1,Macro(user-callerid,)
exten => _*0.,n,Set(SPEEDDIALLOCATION=${EXTEN:2})
exten => _*0.,n(lookup),Macro(speeddial-lookup,${SPEEDDIALLOCATION},${AMPUSER})
exten => _*0.,n,GotoIf($["${SPEEDDIALNUMBER}"=""]?failed)
exten => _*0.,n,Dial(Local/${SPEEDDIALNUMBER}@from-internal/n,)
exten => _*0.,lookup+101(failed),Playback(speed-dial-empty)
exten => _*0.,n,Congestion(20)
exten => *75,1,Goto(app-speeddial-set,s,1)

; end of [app-speeddial]

[app-speeddial-set]
include => app-speeddial-set-custom
exten => s,1,Macro(user-callerid,)
exten => s,n(setloc),Read(newlocation,speed-enterlocation,,,,)
exten => s,n(lookup),Macro(speeddial-lookup,${newlocation},${AMPUSER})
exten => s,n(lookup),GotoIf($["${SPEEDDIALNUMBER}"!=""]?conflicts)
exten => s,n(setnum),Read(newnum,speed-enternumber,,,,)
exten => s,n(success),Set(DB(AMPUSER/${AMPUSER}/speeddials/${newlocation})=${newnum})
exten => s,n,Playback(speed-dial)
exten => s,n,SayDigits(${newlocation})
exten => s,n,Playback(is-set-to)
exten => s,n,SayDigits(${newnum})
exten => s,n,Hangup
exten => s,n(conflicts),Playback(speed-dial)
exten => s,n,SayDigits(${newlocation})
exten => s,n,Playback(is-in-use)
exten => s,n,Background(press-1&to-listen-to-it&press-2&to-enter-a-diff&location&press-3&to-change&telephone-number)
exten => s,n,WaitExten(60,)
exten => 1,1,Playback(speed-dial)
exten => 1,n,SayDigits(${newlocation})
exten => 1,n,Playback(is-set-to)
exten => 1,n,SayDigits(${SPEEDDIALNUMBER})
exten => 1,n,Goto(s,conflicts)
exten => 2,1,Goto(s,setloc)
exten => 3,1,Goto(s,setnum)
exten => t,1,Congestion(20)

; end of [app-speeddial-set]

[app-dictate-record]
include => app-dictate-record-custom
exten => *34,1,Answer
exten => *34,n,Macro(user-callerid,)
exten => *34,n,Noop(CallerID is ${AMPUSER})
exten => *34,n,Set(DICTENABLED=${DB(AMPUSER/${AMPUSER}/dictate/enabled)})
exten => *34,n,GotoIf($[$["x${DICTENABLED}"="x"]|$["x${DICTENABLED}"="xdisabled"]]?nodict:dictok)
exten => *34,n(nodict),Playback(feature-not-avail-line)
exten => *34,n,Hangup
exten => *34,n(dictok),Dictate(/var/lib/asterisk/sounds/dictate/${AMPUSER})
exten => *34,n,Macro(hangupcall,)

; end of [app-dictate-record]

[app-dictate-send]
include => app-dictate-send-custom
exten => *35,1,Answer
exten => *35,n,Macro(user-callerid,)
exten => *35,n,Noop(CallerID is ${AMPUSER})
exten => *35,n,Set(DICTENABLED=${DB(AMPUSER/${AMPUSER}/dictate/enabled)})
exten => *35,n,GotoIf($[$["x${DICTENABLED}"="x"]|$["x${DICTENABLED}"="xdisabled"]]?nodict:dictok)
exten => *35,n(nodict),Playback(feature-not-avail-line)
exten => *35,n,Hangup
exten => *35,n(dictok),Read(DICTFILE,enter-filename-short,,,,)
exten => *35,n,Set(DICTEMAIL=${DB(AMPUSER/${AMPUSER}/dictate/email)})
exten => *35,n,Set(DICTFMT=${DB(AMPUSER/${AMPUSER}/dictate/format)})
exten => *35,n,Set(NAME=${DB(AMPUSER/${AMPUSER}/cidname)})
exten => *35,n,Playback(dictation-being-processed)
exten => *35,n,System(/var/lib/asterisk/bin/audio-email.pl --file /var/lib/asterisk/sounds/dictate/${AMPUSER}/${DICTFILE}.raw --attachment dict-${DICTFILE} --format ${DICTFMT} --to ${DICTEMAIL} --subject "Dictation from ${NAME} Attached")
exten => *35,n,Playback(dictation-sent)
exten => *35,n,Macro(hangupcall,)

; end of [app-dictate-send]

[park-dial]
include => park-dial-custom
exten => t,1,Noop(Parked Call Timed Out and Got Orphaned)
exten => t,n,Set(CALLERID(name)=*8*${CALLERID(name)})
exten => t,n,Goto(from-did-direct,10,1)

; end of [park-dial]

[park-hints]
include => park-hints-custom
exten => 102,1,ParkedCall(102)
exten => 102,hint,park:102@parkedcalls
exten => 103,1,ParkedCall(103)
exten => 103,hint,park:103@parkedcalls
exten => 104,1,ParkedCall(104)
exten => 104,hint,park:104@parkedcalls
exten => 105,1,ParkedCall(105)
exten => 105,hint,park:105@parkedcalls
exten => 106,1,ParkedCall(106)
exten => 106,hint,park:106@parkedcalls
exten => 107,1,ParkedCall(107)
exten => 107,hint,park:107@parkedcalls
exten => 108,1,ParkedCall(108)
exten => 108,hint,park:108@parkedcalls
exten => 109,1,ParkedCall(109)
exten => 109,hint,park:109@parkedcalls
exten => 110,1,ParkedCall(110)
exten => 110,hint,park:110@parkedcalls

; end of [park-hints]

[app-recordings]
include => app-recordings-custom
exten => *77,1,Macro(user-callerid,)
exten => *77,n,Wait(2)
exten => *77,n,Macro(systemrecording,dorecord)
exten => *99,1,Macro(user-callerid,)
exten => *99,n,Wait(2)
exten => *99,n,Macro(systemrecording,docheck)

; end of [app-recordings]

[macro-autoanswer]
include => macro-autoanswer-custom
exten => s,1,Set(DIAL=${DB(DEVICE/${ARG1}/dial)})
exten => s,n,GotoIf($["${DB(DEVICE/${ARG1}/autoanswer/macro)}" != "" ]?macro)
exten => s,n,Set(phone=${SIPPEER(${CUT(DIAL,/,2)}:useragent)})
exten => s,n,Set(ALERTINFO=Alert-Info: Ring Answer)
exten => s,n,Set(CALLINFO=Call-Info: \;answer-after=0)
exten => s,n,Set(SIPURI=intercom=true)
exten => s,n,Set(ANSWERMACRO=)
exten => s,n,GotoIf($["${ANSWERMACRO}" != ""]?macro2)
exten => s,n,ExecIf($["${ALERTINFO}" != ""],SipAddHeader,${ALERTINFO})
exten => s,n,ExecIf($["${CALLINFO}" != ""],SipAddHeader,${CALLINFO})
exten => s,n,ExecIf($["${SIPURI}" != ""],Set,__SIP_URI_OPTIONS=${SIPURI})
exten => s,n+2(macro),Macro(${DB(DEVICE/${ARG1}/autoanswer/macro)},${ARG1})
exten => s,n+2(macro2),Macro(${ANSWERMACRO},${ARG1})

; end of [macro-autoanswer]

[ext-paging]
include => ext-paging-custom
exten => _PAGE.,1,GotoIf($[ ${AMPUSER} = ${EXTEN:4} ]?skipself)
exten => _PAGE.,n,GotoIf($[ ${FORCE_PAGE} != 1 ]?AVAIL)
exten => _PAGE.,n,Set(AVAILSTATUS=not checked)
exten => _PAGE.,n,Goto(SKIPCHECK)
exten => _PAGE.,n(AVAIL),ChanIsAvail(${DB(DEVICE/${EXTEN:4}/dial)},js)
exten => _PAGE.,n(SKIPCHECK),Noop(Seems to be available (state = ${AVAILSTATUS})
exten => _PAGE.,n,Macro(autoanswer,${EXTEN:4})
exten => _PAGE.,n,Dial(${DIAL},5, A(beep))
exten => _PAGE.,n(skipself),Noop(Not paging originator)
exten => _PAGE.,n,Hangup
exten => _PAGE.,AVAIL+101,Noop(Channel ${AVAILCHAN} is not available (state = ${AVAILSTATUS}))

; end of [ext-paging]

[app-gabcast]
include => app-gabcast-custom
exten => *422,1,Macro(user-callerid,)
exten => *422,n,Goto(gabcast,${AMPUSER},1)

; end of [app-gabcast]

[gabcast]
include => gabcast-custom
exten => _X.,1,Dial(IAX2/iax.gabcast.com/422,120,tr)
exten => s,1,Dial(IAX2/iax.gabcast.com/422,120,tr)

; end of [gabcast]

[app-calltrace]
include => app-calltrace-custom
exten => *69,1,Goto(app-calltrace-perform,s,1)

; end of [app-calltrace]

[app-calltrace-perform]
include => app-calltrace-perform-custom
exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n,Macro(user-callerid,)
exten => s,n,Playback(info-about-last-call&telephone-number)
exten => s,n,Set(lastcaller=${DB(CALLTRACE/${AMPUSER})})
exten => s,n,GotoIf($[ $[ "${lastcaller}" = "" ] | $[ "${lastcaller}" = "unknown" ] ]?noinfo)
exten => s,n,SayDigits(${lastcaller})
exten => s,n,Set(TIMEOUT(digit)=3)
exten => s,n,Set(TIMEOUT(response)=7)
exten => s,n,Background(to-call-this-number&press-1)
exten => s,n,Goto(fin)
exten => s,n(noinfo),Playback(from-unknown-caller)
exten => s,n,Macro(hangupcall,)
exten => s,n(fin),Noop(Waiting for input)
exten => s,n,WaitExten(60,)
exten => s,n,Playback(sorry-youre-having-problems&goodbye)
exten => 1,1,Goto(from-internal,${lastcaller},1)
exten => i,1,Playback(vm-goodbye)
exten => i,n,Macro(hangupcall,)
exten => t,1,Playback(vm-goodbye)
exten => t,n,Macro(hangupcall,)

; end of [app-calltrace-perform]

[app-directory]
include => app-directory-custom
exten => *42,1,Answer
exten => *42,n,Wait(1)
exten => *42,n,AGI(directory,${DIR-CONTEXT},from-did-direct,${DIRECTORY:0:1}${DIRECTORY_OPTS}o)
exten => *42,n,Playback(vm-goodbye)
exten => *42,n,Hangup
exten => o,1,Goto(from-internal,${OPERATOR_XTN},1)

; end of [app-directory]

[app-echo-test]
include => app-echo-test-custom
exten => *43,1,Answer
exten => *43,n,Wait(1)
exten => *43,n,Playback(demo-echotest)
exten => *43,n,Echo()
exten => *43,n,Playback(demo-echodone)
exten => *43,n,Hangup

; end of [app-echo-test]

[app-speakextennum]
include => app-speakextennum-custom
exten => *65,1,Answer
exten => *65,n,Wait(1)
exten => *65,n,Macro(user-callerid,)
exten => *65,n,Playback(your)
exten => *65,n,Playback(extension)
exten => *65,n,Playback(number)
exten => *65,n,Playback(is)
exten => *65,n,SayDigits(${AMPUSER})
exten => *65,n,Wait(2)
exten => *65,n,Hangup

; end of [app-speakextennum]

[app-speakingclock]
include => app-speakingclock-custom
exten => *60,1,Answer
exten => *60,n,Wait(1)
exten => *60,n,Set(NumLoops=0)
exten => *60,n(start),Set(FutureTime=$[${EPOCH} + 11])
exten => *60,n,Playback(at-tone-time-exactly)
exten => *60,n,GotoIf($["${TIMEFORMAT}" = "kM"]?hr24format)
exten => *60,n,SayUnixTime(${FutureTime},,IM \'and\' S \'seconds\' p)
exten => *60,n,Goto(waitloop)
exten => *60,n(hr24format),SayUnixTime(${FutureTime},,kM \'and\' S \'seconds\')
exten => *60,n(waitloop),Set(TimeLeft=$[${FutureTime} - ${EPOCH}])
exten => *60,n,GotoIf($[${TimeLeft} exten => *60,n,Wait(1)
exten => *60,n,Goto(waitloop)
exten => *60,n(playbeep),Playback(beep)
exten => *60,n,Wait(5)
exten => *60,n,Set(NumLoops=$[${NumLoops} + 1])
exten => *60,n,GotoIf($[${NumLoops} exten => *60,n,Playback(goodbye)
exten => *60,n,Hangup

; end of [app-speakingclock]

[app-dialvm]
include => app-dialvm-custom
exten => *98,1,Answer
exten => *98,n,Wait(1)
exten => *98,n,Macro(user-callerid,)
exten => *98,n,VoiceMailMain()
exten => *98,n,Macro(hangupcall,)
exten => _*98.,1,Answer
exten => _*98.,n,Wait(1)
exten => _*98.,n,Macro(get-vmcontext,${EXTEN:3})
exten => _*98.,n,VoiceMailMain(${EXTEN:3}@${VMCONTEXT})
exten => _*98.,n,Macro(hangupcall,)

; end of [app-dialvm]

[app-vmmain]
include => app-vmmain-custom
exten => *97,1,Answer
exten => *97,n,Wait(1)
exten => *97,n,Macro(user-callerid,)
exten => *97,n,Macro(get-vmcontext,${AMPUSER})
exten => *97,n(check),MailBoxExists(${AMPUSER}@${VMCONTEXT})
exten => *97,n,GotoIf($["${VMBOXEXISTSSTATUS}" = "SUCCESS"]?mbexist)
exten => *97,n,VoiceMailMain()
exten => *97,n,Macro(hangupcall,)
exten => *97,check+101(mbexist),VoiceMailMain(${AMPUSER}@${VMCONTEXT})
exten => *97,n,Macro(hangupcall,)

; end of [app-vmmain]

[ext-group]
include => ext-group-custom
exten => 600,1,Macro(user-callerid,)
exten => 600,n,GotoIf($["foo${BLKVM_OVERRIDE}" = "foo"]?skipdb)
exten => 600,n,GotoIf($["${DB(${BLKVM_OVERRIDE})}" = "TRUE"]?skipov)
exten => 600,n(skipdb),Set(__NODEST=)
exten => 600,n,Set(__BLKVM_OVERRIDE=BLKVM/${EXTEN}/${CHANNEL})
exten => 600,n,Set(__BLKVM_BASE=${EXTEN})
exten => 600,n,Set(DB(${BLKVM_OVERRIDE})=TRUE)
exten => 600,n(skipov),Set(RRNODEST=${NODEST})
exten => 600,n(skipvmblk),Set(__NODEST=${EXTEN})
exten => 600,n,Set(RecordMethod=Group)
exten => 600,n,Macro(record-enable,32-66,${RecordMethod})
exten => 600,n,Set(RingGroupMethod=memoryhunt)
exten => 600,n(DIALGRP),Macro(dial,10,m(default)t,32-66)
exten => 600,n,Set(RingGroupMethod=)
exten => 600,n,GotoIf($["foo${RRNODEST}" != "foo"]?nodest)
exten => 600,n,Set(__NODEST=)
exten => 600,n,dbDel(${BLKVM_OVERRIDE})
exten => 600,n,Goto(from-did-direct,10,1)
exten => 600,n(nodest),Noop(SKIPPING DEST, CALL CAME FROM Q/RG: ${RRNODEST})

; end of [ext-group]

[app-pbdirectory]
include => app-pbdirectory-custom
exten => 411,1,Answer
exten => 411,n,Wait(1)
exten => 411,n,Goto(pbdirectory,1)
exten => pbdirectory,1,Macro(user-callerid,)
exten => pbdirectory,n,AGI(pbdirectory)
exten => pbdirectory,n,GotoIf($["${dialnumber}"=""]?hangup,1)
exten => pbdirectory,n,Noop(Got number to dial: ${dialnumber})
exten => pbdirectory,n,Dial(Local/${dialnumber}@from-internal/n,)
exten => hangup,1,Hangup

; end of [app-pbdirectory]

[cidlookup]
include => cidlookup-custom
exten => cidlookup_return,1,LookupCIDName
exten => cidlookup_return,n,Return()

; end of [cidlookup]

[app-userlogonoff]
include => app-userlogonoff-custom
exten => *12,1,Macro(user-logoff,)
exten => *12,n,Hangup
exten => *11,1,Macro(user-logon,)
exten => *11,n,Hangup
exten => _*11.,1,Macro(user-logon,${EXTEN:3},)
exten => _*11.,n,Hangup

; end of [app-userlogonoff]

[app-pickup]
include => app-pickup-custom
exten => _**.,1,Noop(Attempt to Pickup ${EXTEN:2} by ${CALLERID(num)})
exten => _**.,n,Pickup(${EXTEN:2})

; end of [app-pickup]

[app-zapbarge]
include => app-zapbarge-custom
exten => 888,1,Macro(user-callerid,)
exten => 888,n,Set(GROUP()=${CALLERID(number)})
exten => 888,n,Answer
exten => 888,n,Wait(1)
exten => 888,n,ZapBarge()
exten => 888,n,Hangup

; end of [app-zapbarge]

[app-chanspy]
include => app-chanspy-custom
exten => 555,1,Macro(user-callerid,)
exten => 555,n,Answer
exten => 555,n,Wait(1)
exten => 555,n,ChanSpy()
exten => 555,n,Hangup

; end of [app-chanspy]

[ext-test]
include => ext-test-custom
exten => 7777,1,Goto(from-pstn,s,1)
exten => 666,1,Goto(ext-fax,in_fax,1)
exten => h,1,Macro(hangupcall,)

; end of [ext-test]

[ext-did]
include => ext-did-custom
exten => fax,1,Goto(ext-fax,in_fax,1)
exten => 88,1,Set(__FROM_DID=${EXTEN})
exten => 88,n,Gosub(app-blacklist-check,s,1)
exten => 88,n,GotoIf($[ "${CALLERID(name)}" != "" ] ?cidok)
exten => 88,n,Set(CALLERID(name)=${CALLERID(num)})
exten => 88,n(cidok),Noop(CallerID is ${CALLERID(all)})
exten => 88,n,Set(FAX_RX=disabled)
exten => 88,n,Goto(ext-group,600,1)
exten => 68,1,Set(__FROM_DID=${EXTEN})
exten => 68,n,GotoIf($[ "${CALLERID(name)}" != "" ] ?cidok)
exten => 68,n,Set(CALLERID(name)=${CALLERID(num)})
exten => 68,n(cidok),Noop(CallerID is ${CALLERID(all)})
exten => 68,n,Goto(from-did-direct,68,1)
exten => 8,1,Set(__FROM_DID=${EXTEN})
exten => 8,n,GotoIf($[ "${CALLERID(name)}" != "" ] ?cidok)
exten => 8,n,Set(CALLERID(name)=${CALLERID(num)})
exten => 8,n(cidok),Noop(CallerID is ${CALLERID(all)})
exten => 8,n,Set(FAX_RX=disabled)
exten => 8,n,Goto(from-did-direct,8,1)

; end of [ext-did]

[ext-did-catchall]
include => ext-did-catchall-custom
exten => s,1,Noop(No DID or CID Match)
exten => s,n,Answer
exten => s,n,Wait(2)
exten => s,n,Playback(ss-noservice)
exten => s,n,SayAlpha(${FROM_DID})
exten => _[*#X].,1,Set(__FROM_DID=${EXTEN})
exten => _[*#X].,n,Noop(Received an unknown call with DID set to ${EXTEN})
exten => _[*#X].,n,Goto(ext-did,s,1)

; end of [ext-did-catchall]

[macro-from-zaptel-4]
include => macro-from-zaptel-4-custom
exten => s,1,Noop(Entering macro-from-zaptel-4 with DID = ${DID} and setting to: 88)
exten => s,n,Set(__FROM_DID=88)
exten => s,n,Goto(from-trunk,88,1)

; end of [macro-from-zaptel-4]

[ext-local]
include => ext-local-custom
exten => 8,1,Macro(exten-vm,novm,8)
exten => 8,n,Hangup
exten => 8,hint,ZAP/4
exten => 10,1,Macro(exten-vm,novm,10)
exten => 10,n,Hangup
exten => 10,n,Goto(from-internal,10,1)
exten => 10,hint,SIP/10
exten => 11,1,Macro(exten-vm,novm,11)
exten => 11,n,Hangup
exten => 11,hint,SIP/11
exten => Bernie,1,Goto(from-internal,11,1)
exten => 13,1,Macro(exten-vm,13,13)
exten => 13,n,Hangup
exten => 13,n,Goto(from-internal,13,1)
exten => 13,hint,SIP/13
exten => ${VM_PREFIX}13,1,Macro(vm,13,DIRECTDIAL)
exten => ${VM_PREFIX}13,n,Hangup
exten => vmb13,1,Macro(vm,13,BUSY)
exten => vmb13,n,Hangup
exten => vmu13,1,Macro(vm,13,NOANSWER)
exten => vmu13,n,Hangup
exten => vms13,1,Macro(vm,13,NOMESSAGE)
exten => vms13,n,Hangup
exten => 14,1,Macro(exten-vm,14,14)
exten => 14,n,Hangup
exten => 14,n,Goto(from-internal,14,1)
exten => 14,hint,SIP/14
exten => ${VM_PREFIX}14,1,Macro(vm,14,DIRECTDIAL)
exten => ${VM_PREFIX}14,n,Hangup
exten => vmb14,1,Macro(vm,14,BUSY)
exten => vmb14,n,Hangup
exten => vmu14,1,Macro(vm,14,NOANSWER)
exten => vmu14,n,Hangup
exten => vms14,1,Macro(vm,14,NOMESSAGE)
exten => vms14,n,Hangup
exten => 15,1,Macro(exten-vm,novm,15)
exten => 15,n,Hangup
exten => 15,n,Goto(from-internal,15,1)
exten => 15,hint,SIP/15
exten => 16,1,Macro(exten-vm,novm,16)
exten => 16,n,Hangup
exten => 16,n,Goto(from-internal,16,1)
exten => 16,hint,SIP/16
exten => 19,1,Macro(exten-vm,novm,19)
exten => 19,n,Hangup
exten => 19,n,Goto(from-internal,19,1)
exten => 19,hint,SIP/19
exten => 20,1,Macro(exten-vm,novm,20)
exten => 20,n,Hangup
exten => 20,n,Goto(from-internal,20,1)
exten => 20,hint,SIP/20
exten => 21,1,Macro(exten-vm,novm,21)
exten => 21,n,Hangup
exten => 21,n,Goto(from-internal,21,1)
exten => 21,hint,SIP/21
exten => 22,1,Macro(exten-vm,novm,22)
exten => 22,n,Hangup
exten => 22,n,Goto(from-internal,22,1)
exten => 22,hint,SIP/22
exten => 23,1,Macro(exten-vm,novm,23)
exten => 23,n,Hangup
exten => 23,n,Goto(from-internal,23,1)
exten => 23,hint,SIP/23
exten => 24,1,Macro(exten-vm,novm,24)
exten => 24,n,Hangup
exten => 24,n,Goto(from-internal,24,1)
exten => 24,hint,SIP/24
exten => 27,1,Macro(exten-vm,novm,27)
exten => 27,n,Hangup
exten => 27,n,Goto(from-internal,27,1)
exten => 27,hint,SIP/27
exten => 32,1,Macro(exten-vm,novm,32)
exten => 32,n,Hangup
exten => 32,n,Goto(from-internal,32,1)
exten => 32,hint,SIP/32
exten => 37,1,Macro(exten-vm,37,37)
exten => 37,n,Hangup
exten => 37,n,Goto(from-internal,37,1)
exten => 37,hint,SIP/37
exten => ${VM_PREFIX}37,1,Macro(vm,37,DIRECTDIAL)
exten => ${VM_PREFIX}37,n,Hangup
exten => vmb37,1,Macro(vm,37,BUSY)
exten => vmb37,n,Hangup
exten => vmu37,1,Macro(vm,37,NOANSWER)
exten => vmu37,n,Hangup
exten => vms37,1,Macro(vm,37,NOMESSAGE)
exten => vms37,n,Hangup
exten => 38,1,Macro(exten-vm,novm,38)
exten => 38,n,Hangup
exten => 38,n,Goto(from-internal,38,1)
exten => 38,hint,SIP/38
exten => 60,1,Macro(exten-vm,novm,60)
exten => 60,n,Hangup
exten => 60,n,Goto(from-internal,60,1)
exten => 60,hint,SIP/60
exten => 61,1,Macro(exten-vm,novm,61)
exten => 61,n,Hangup
exten => 61,n,Goto(from-internal,61,1)
exten => 61,hint,SIP/61
exten => 62,1,Macro(exten-vm,novm,62)
exten => 62,n,Hangup
exten => 62,n,Goto(from-internal,62,1)
exten => 62,hint,SIP/62
exten => 63,1,Macro(exten-vm,novm,63)
exten => 63,n,Hangup
exten => 63,n,Goto(from-internal,63,1)
exten => 63,hint,SIP/63
exten => 64,1,Macro(exten-vm,novm,64)
exten => 64,n,Hangup
exten => 64,n,Goto(from-internal,64,1)
exten => 64,hint,SIP/64
exten => 65,1,Macro(exten-vm,novm,65)
exten => 65,n,Hangup
exten => 65,n,Goto(from-internal,65,1)
exten => 65,hint,SIP/10
exten => 66,1,Macro(exten-vm,novm,66)
exten => 66,n,Hangup
exten => 66,n,Goto(from-internal,66,1)
exten => 66,hint,SIP/66
exten => 67,1,Macro(exten-vm,67,67)
exten => 67,n,Hangup
exten => 67,n,Goto(from-internal,67,1)
exten => 67,hint,SIP/67
exten => ${VM_PREFIX}67,1,Macro(vm,67,DIRECTDIAL)
exten => ${VM_PREFIX}67,n,Hangup
exten => vmb67,1,Macro(vm,67,BUSY)
exten => vmb67,n,Hangup
exten => vmu67,1,Macro(vm,67,NOANSWER)
exten => vmu67,n,Hangup
exten => vms67,1,Macro(vm,67,NOMESSAGE)
exten => vms67,n,Hangup
exten => 68,1,Macro(exten-vm,68,68)
exten => 68,n,Hangup
exten => 68,n,Goto(from-internal,68,1)
exten => 68,hint,SIP/68
exten => ${VM_PREFIX}68,1,Macro(vm,68,DIRECTDIAL)
exten => ${VM_PREFIX}68,n,Hangup
exten => vmb68,1,Macro(vm,68,BUSY)
exten => vmb68,n,Hangup
exten => vmu68,1,Macro(vm,68,NOANSWER)
exten => vmu68,n,Hangup
exten => vms68,1,Macro(vm,68,NOMESSAGE)
exten => vms68,n,Hangup

; end of [ext-local]

[from-did-direct-ivr]
include => from-did-direct-ivr-custom
exten => 8,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => 8,n,Set(__NODEST=)
exten => 8,n,Goto(from-did-direct,8,1)
exten => 10,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => 10,n,Set(__NODEST=)
exten => 10,n,Goto(from-did-direct,10,1)
exten => 11,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => 11,n,Set(__NODEST=)
exten => 11,n,Goto(from-did-direct,11,1)
exten => 13,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => 13,n,Set(__NODEST=)
exten => 13,n,Goto(from-did-direct,13,1)
exten => ${VM_PREFIX}13,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => ${VM_PREFIX}13,n,Set(__NODEST=)
exten => ${VM_PREFIX}13,n,Macro(vm,13,DIRECTDIAL)
exten => 14,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => 14,n,Set(__NODEST=)
exten => 14,n,Goto(from-did-direct,14,1)
exten => ${VM_PREFIX}14,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => ${VM_PREFIX}14,n,Set(__NODEST=)
exten => ${VM_PREFIX}14,n,Macro(vm,14,DIRECTDIAL)
exten => 15,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => 15,n,Set(__NODEST=)
exten => 15,n,Goto(from-did-direct,15,1)
exten => 16,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => 16,n,Set(__NODEST=)
exten => 16,n,Goto(from-did-direct,16,1)
exten => 19,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => 19,n,Set(__NODEST=)
exten => 19,n,Goto(from-did-direct,19,1)
exten => 20,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => 20,n,Set(__NODEST=)
exten => 20,n,Goto(from-did-direct,20,1)
exten => 21,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => 21,n,Set(__NODEST=)
exten => 21,n,Goto(from-did-direct,21,1)
exten => 22,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => 22,n,Set(__NODEST=)
exten => 22,n,Goto(from-did-direct,22,1)
exten => 23,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => 23,n,Set(__NODEST=)
exten => 23,n,Goto(from-did-direct,23,1)
exten => 24,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => 24,n,Set(__NODEST=)
exten => 24,n,Goto(from-did-direct,24,1)
exten => 27,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => 27,n,Set(__NODEST=)
exten => 27,n,Goto(from-did-direct,27,1)
exten => 32,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => 32,n,Set(__NODEST=)
exten => 32,n,Goto(from-did-direct,32,1)
exten => 37,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => 37,n,Set(__NODEST=)
exten => 37,n,Goto(from-did-direct,37,1)
exten => ${VM_PREFIX}37,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => ${VM_PREFIX}37,n,Set(__NODEST=)
exten => ${VM_PREFIX}37,n,Macro(vm,37,DIRECTDIAL)
exten => 38,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => 38,n,Set(__NODEST=)
exten => 38,n,Goto(from-did-direct,38,1)
exten => 60,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => 60,n,Set(__NODEST=)
exten => 60,n,Goto(from-did-direct,60,1)
exten => 61,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => 61,n,Set(__NODEST=)
exten => 61,n,Goto(from-did-direct,61,1)
exten => 62,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => 62,n,Set(__NODEST=)
exten => 62,n,Goto(from-did-direct,62,1)
exten => 63,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => 63,n,Set(__NODEST=)
exten => 63,n,Goto(from-did-direct,63,1)
exten => 64,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => 64,n,Set(__NODEST=)
exten => 64,n,Goto(from-did-direct,64,1)
exten => 65,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => 65,n,Set(__NODEST=)
exten => 65,n,Goto(from-did-direct,65,1)
exten => 66,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => 66,n,Set(__NODEST=)
exten => 66,n,Goto(from-did-direct,66,1)
exten => 67,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => 67,n,Set(__NODEST=)
exten => 67,n,Goto(from-did-direct,67,1)
exten => ${VM_PREFIX}67,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => ${VM_PREFIX}67,n,Set(__NODEST=)
exten => ${VM_PREFIX}67,n,Macro(vm,67,DIRECTDIAL)
exten => 68,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => 68,n,Set(__NODEST=)
exten => 68,n,Goto(from-did-direct,68,1)
exten => ${VM_PREFIX}68,1,ExecIf($["${BLKVM_OVERRIDE}" != ""],dbDel,${BLKVM_OVERRIDE})
exten => ${VM_PREFIX}68,n,Set(__NODEST=)
exten => ${VM_PREFIX}68,n,Macro(vm,68,DIRECTDIAL)

; end of [from-did-direct-ivr]

[outbound-allroutes]
include => outbound-allroutes-custom
include => outrt-001-outbound test
exten => foo,1,Noop(bar)

; end of [outbound-allroutes]

[outrt-001-outbound test]
include => outrt-001-outbound test-custom
exten => _NXXNXXXXXX,1,Macro(user-callerid,SKIPTTL,)
exten => _NXXNXXXXXX,n,Set(_NODEST=)
exten => _NXXNXXXXXX,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _NXXNXXXXXX,n,Macro(dialout-trunk,2,${EXTEN},,)
exten => _NXXNXXXXXX,n,Macro(outisbusy,)
exten => _NXXXXXX,1,Macro(user-callerid,SKIPTTL,)
exten => _NXXXXXX,n,Set(_NODEST=)
exten => _NXXXXXX,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _NXXXXXX,n,Macro(dialout-trunk,2,${EXTEN},,)
exten => _NXXXXXX,n,Macro(outisbusy,)

; end of [outrt-001-outbound test]

[app-blackhole]
include => app-blackhole-custom
exten => hangup,1,Noop(Blackhole Dest: Hangup)
exten => hangup,n,Hangup
exten => zapateller,1,Noop(Blackhole Dest: Play SIT Tone)
exten => zapateller,n,Answer
exten => zapateller,n,Zapateller()
exten => musiconhold,1,Noop(Blackhole Dest: Put caller on hold forever)
exten => musiconhold,n,Answer
exten => musiconhold,n,MusicOnHold()
exten => congestion,1,Noop(Blackhole Dest: Congestion)
exten => congestion,n,Answer
exten => congestion,n,Playtones(congestion)
exten => congestion,n,Congestion(20)
exten => congestion,n,Hangup
exten => busy,1,Noop(Blackhole Dest: Busy)
exten => busy,n,Answer
exten => busy,n,Playtones(busy)
exten => busy,n,Busy(20)
exten => busy,n,Hangup
exten => ring,1,Noop(Blackhole Dest: Ring)
exten => ring,n,Answer
exten => ring,n,Playtones(ring)
exten => ring,n,Wait(300)
exten => ring,n,Hangup

; end of [app-blackhole]

[bad-number]
include => bad-number-custom
exten => _X.,1,ResetCDR()
exten => _X.,n,NoCDR()
exten => _X.,n,Wait(1)
exten => _X.,n,Playback(silence/1&cannot-complete-as-dialed&check-number-dial-again,noanswer)
exten => _X.,n,Wait(1)
exten => _X.,n,Congestion(20)
exten => _X.,n,Hangup
exten => _*.,1,ResetCDR()
exten => _*.,n,NoCDR()
exten => _*.,n,Wait(1)
exten => _*.,n,Playback(silence/1&feature-not-avail-line&silence/1&cannot-complete-as-dialed&check-number-dial-again,noanswer)
exten => _*.,n,Wait(1)
exten => _*.,n,Congestion(20)
exten => _*.,n,Hangup

; end of [bad-number]

[macro-dialout-trunk]
include => macro-dialout-trunk-custom
exten => s,1,Set(DIAL_TRUNK=${ARG1})
exten => s,n,ExecIf($[$["${ARG3}" != ""] & $["${DB(AMPUSER/${AMPUSER}/pinless)}" != "NOPASSWD"]],Authenticate,${ARG3})
exten => s,n,GotoIf($["x${OUTDISABLE_${DIAL_TRUNK}}" = "xon"]?disabletrunk,1)
exten => s,n,Set(DIAL_NUMBER=${ARG2})
exten => s,n,Set(DIAL_TRUNK_OPTIONS=${DIAL_OPTIONS})
exten => s,n,Set(GROUP()=OUT_${DIAL_TRUNK})
exten => s,n,GotoIf($["${OUTMAXCHANS_${DIAL_TRUNK}}foo" = "foo"]?nomax)
exten => s,n,GotoIf($[ ${GROUP_COUNT(OUT_${DIAL_TRUNK})} > ${OUTMAXCHANS_${DIAL_TRUNK}} ]?chanfull)
exten => s,n(nomax),GotoIf($["${INTRACOMPANYROUTE}" = "YES"]?skipoutcid)
exten => s,n,Set(DIAL_TRUNK_OPTIONS=${TRUNK_OPTIONS})
exten => s,n,Macro(outbound-callerid,${DIAL_TRUNK})
exten => s,n(skipoutcid),AGI(fixlocalprefix)
exten => s,n,Set(OUTNUM=${OUTPREFIX_${DIAL_TRUNK}}${DIAL_NUMBER})
exten => s,n,Set(custom=${CUT(OUT_${DIAL_TRUNK},:,1)})
exten => s,n,GotoIf($[$["${MOHCLASS}" = "default"] | $["foo${MOHCLASS}" = "foo"]]?gocall)
exten => s,n,Set(DIAL_TRUNK_OPTIONS=M(setmusic^${MOHCLASS})${DIAL_TRUNK_OPTIONS})
exten => s,n(gocall),Macro(dialout-trunk-predial-hook,)
exten => s,n,GotoIf($["${PREDIAL_HOOK_RET}" = "BYPASS"]?bypass,1)
exten => s,n,GotoIf($["${custom}" = "AMP"]?customtrunk)
exten => s,n,Dial(${OUT_${DIAL_TRUNK}}/${OUTNUM},300,${DIAL_TRUNK_OPTIONS})
exten => s,n,Goto(s-${DIALSTATUS},1)
exten => s,n(customtrunk),Set(pre_num=${CUT(OUT_${DIAL_TRUNK},$,1)})
exten => s,n,Set(the_num=${CUT(OUT_${DIAL_TRUNK},$,2)})
exten => s,n,Set(post_num=${CUT(OUT_${DIAL_TRUNK},$,3)})
exten => s,n,GotoIf($["${the_num}" = "OUTNUM"]?outnum:skipoutnum)
exten => s,n(outnum),Set(the_num=${OUTNUM})
exten => s,n(skipoutnum),Dial(${pre_num:4}${the_num}${post_num},300,${DIAL_TRUNK_OPTIONS})
exten => s,n,Goto(s-${DIALSTATUS},1)
exten => s,n(chanfull),Noop(max channels used up)
exten => s-BUSY,1,Noop(Dial failed due to trunk reporting BUSY - giving up)
exten => s-BUSY,n,Playtones(busy)
exten => s-BUSY,n,Busy(20)
exten => s-NOANSWER,1,Noop(Dial failed due to trunk reporting NOANSWER - giving up)
exten => s-NOANSWER,n,Playtones(congestion)
exten => s-NOANSWER,n,Congestion(20)
exten => s-CANCEL,1,Noop(Dial failed due to trunk reporting CANCEL - giving up)
exten => s-CANCEL,n,Playtones(congestion)
exten => s-CANCEL,n,Congestion(20)
exten => _s-.,1,GotoIf($["x${OUTFAIL_${ARG1}}" = "x"]?noreport)
exten => _s-.,n,AGI(${OUTFAIL_${ARG1}})
exten => _s-.,n(noreport),Noop(TRUNK Dial failed due to ${DIALSTATUS} - failing through to other trunks)
exten => disabletrunk,1,Noop(TRUNK: ${OUT_${DIAL_TRUNK}} DISABLED - falling through to next trunk)
exten => bypass,1,Noop(TRUNK: ${OUT_${DIAL_TRUNK}} BYPASSING because dialout-trunk-predial-hook)
exten => h,1,Macro(hangupcall,)

; end of [macro-dialout-trunk]

[macro-dialout-dundi]
include => macro-dialout-dundi-custom
exten => s,1,Set(DIAL_TRUNK=${ARG1})
exten => s,n,ExecIf($[$["${ARG3}" != ""] & $["${DB(AMPUSER/${AMPUSER}/pinless)}" != "NOPASSWD"]],Authenticate,${ARG3})
exten => s,n,GotoIf($["x${OUTDISABLE_${DIAL_TRUNK}}" = "xon"]?disabletrunk,1)
exten => s,n,Set(DIAL_NUMBER=${ARG2})
exten => s,n,Set(DIAL_TRUNK_OPTIONS=${DIAL_OPTIONS})
exten => s,n,Set(GROUP()=OUT_${DIAL_TRUNK})
exten => s,n,GotoIf($["${OUTMAXCHANS_${DIAL_TRUNK}}foo" = "foo"]?nomax)
exten => s,n,GotoIf($[ ${GROUP_COUNT(OUT_${DIAL_TRUNK})} > ${OUTMAXCHANS_${DIAL_TRUNK}} ]?chanfull)
exten => s,n(nomax),GotoIf($["${INTRACOMPANYROUTE}" = "YES"]?skipoutcid)
exten => s,n,Set(DIAL_TRUNK_OPTIONS=${TRUNK_OPTIONS})
exten => s,n,Macro(outbound-callerid,${DIAL_TRUNK})
exten => s,n(skipoutcid),AGI(fixlocalprefix)
exten => s,n,Set(OUTNUM=${OUTPREFIX_${DIAL_TRUNK}}${DIAL_NUMBER})
exten => s,n,GotoIf($[$["${MOHCLASS}" = "default"] | $["foo${MOHCLASS}" = "foo"]]?gocall)
exten => s,n,Set(DIAL_TRUNK_OPTIONS=M(setmusic^${MOHCLASS})${DIAL_TRUNK_OPTIONS})
exten => s,n(gocall),Macro(dialout-dundi-predial-hook,)
exten => s,n,GotoIf($["${PREDIAL_HOOK_RET}" = "BYPASS"]?bypass,1)
exten => s,n,GotoIf($["${custom}" = "AMP"]?customtrunk)
exten => s,n,Macro(dundi-${DIAL_TRUNK},${OUTNUM})
exten => s,n,Goto(s-${DIALSTATUS},1)
exten => s,n(chanfull),Noop(max channels used up)
exten => s-BUSY,1,Noop(Dial failed due to trunk reporting BUSY - giving up)
exten => s-BUSY,n,Playtones(busy)
exten => s-BUSY,n,Busy(20)
exten => s-NOANSWER,1,Noop(Dial failed due to trunk reporting NOANSWER - giving up)
exten => s-NOANSWER,n,Playtones(congestion)
exten => s-NOANSWER,n,Congestion(20)
exten => s-CANCEL,1,Noop(Dial failed due to trunk reporting CANCEL - giving up)
exten => s-CANCEL,n,Playtones(congestion)
exten => s-CANCEL,n,Congestion(20)
exten => _s-.,1,GotoIf($["x${OUTFAIL_${ARG1}}" = "x"]?noreport)
exten => _s-.,n,AGI(${OUTFAIL_${ARG1}})
exten => _s-.,n(noreport),Noop(TRUNK Dial failed due to ${DIALSTATUS} - failing through to other trunks)
exten => disabletrunk,1,Noop(TRUNK: ${OUT_${DIAL_TRUNK}} DISABLED - falling through to next trunk)
exten => bypass,1,Noop(TRUNK: ${OUT_${DIAL_TRUNK}} BYPASSING because dialout-dundi-predial-hook)
exten => h,1,Macro(hangupcall,)

; end of [macro-dialout-dundi]

[macro-user-callerid]
include => macro-user-callerid-custom
exten => s,1,Noop(user-callerid: ${CALLERID(name)} ${CALLERID(number)})
exten => s,n,Set(AMPUSER=${IF($["foo${AMPUSER}" = "foo"]?${CALLERID(number)}:${AMPUSER})})
exten => s,n,GotoIf($["${CHANNEL:0:5}" = "Local"]?report)
exten => s,n,ExecIf($["${REALCALLERIDNUM:1:2}" = ""],Set,REALCALLERIDNUM=${CALLERID(number)})
exten => s,n(start),Noop(REALCALLERIDNUM is ${REALCALLERIDNUM})
exten => s,n,Set(AMPUSER=${DB(DEVICE/${REALCALLERIDNUM}/user)})
exten => s,n,Set(AMPUSERCIDNAME=${DB(AMPUSER/${AMPUSER}/cidname)})
exten => s,n,GotoIf($["x${AMPUSERCIDNAME:1:2}" = "x"]?report)
exten => s,n,Set(AMPUSERCID=${IF($["${DB_EXISTS(AMPUSER/${AMPUSER}/cidnum)}" = "1"]?${DB_RESULT}:${AMPUSER})})
exten => s,n,Set(CALLERID(all)="${AMPUSERCIDNAME}" )
exten => s,n,Set(REALCALLERIDNUM=${DB(DEVICE/${REALCALLERIDNUM}/user)})
exten => s,n,ExecIf($["${DB(AMPUSER/${AMPUSER}/language)}" != ""],Set,CHANNEL(language)=${DB(AMPUSER/${AMPUSER}/language)})
exten => s,n(report),Noop(TTL: ${TTL} ARG1: ${ARG1})
exten => s,n,GotoIf($[ "${ARG1}" = "SKIPTTL" ]?continue)
exten => s,n(report2),Set(__TTL=${IF($["foo${TTL}" = "foo"]?64:$[ ${TTL} - 1 ])})
exten => s,n,GotoIf($[ ${TTL} > 0 ]?continue)
exten => s,n,Wait(${RINGTIMER})
exten => s,n,Answer
exten => s,n,Wait(2)
exten => s,n,Playback(im-sorry&an-error-has-occured&with&call-forwarding)
exten => s,n,Macro(hangupcall,)
exten => s,n,Congestion(20)
exten => s,n(continue),Noop(Using CallerID ${CALLERID(all)})
exten => h,1,Macro(hangupcall,)

; end of [macro-user-callerid]

[macro-dialout-enum]
include => macro-dialout-enum-custom
exten => s,1,ExecIf($[$["${ARG3}" != ""] & $["${DB(AMPUSER/${AMPUSER}/pinless)}" != "NOPASSWD"]],Authenticate,${ARG3})
exten => s,n,Macro(outbound-callerid,${ARG1})
exten => s,n,Set(GROUP()=OUT_${ARG1})
exten => s,n,GotoIf($["${OUTMAXCHANS_${ARG1}}foo" = "foo"]?nomax)
exten => s,n,GotoIf($[ ${GROUP_COUNT(OUT_${ARG1})} > ${OUTMAXCHANS_${ARG1}} ]?nochans)
exten => s,n(nomax),Set(DIAL_NUMBER=${ARG2})
exten => s,n,Set(DIAL_TRUNK=${ARG1})
exten => s,n,AGI(fixlocalprefix)
exten => s,n,AGI(enumlookup.agi)
exten => s,n(dialloop),GotoIf($["foo${DIALARR}"="foo"]?end)
exten => s,n,Set(TRYDIAL=${CUT(DIALARR,%,1)})
exten => s,n,Set(DIALARR=${CUT(DIALARR,%,2-)})
exten => s,n,Dial(${TRYDIAL},)
exten => s,n,Noop(Dial exited in macro-enum-dialout with ${DIALSTATUS})
exten => s,n,GotoIf($[ $[ "${DIALSTATUS}" = "CHANUNAVAIL" ] | $[ "${DIALSTATUS}" = "CONGESTION" ] ]?dialloop)
exten => s,n(dialfailed),Goto(s-${DIALSTATUS},1)
exten => s,n(nochans),Noop(max channels used up)
exten => s,n(end),Noop(Exiting macro-dialout-enum)
exten => s-BUSY,1,Noop(Trunk is reporting BUSY)
exten => s-BUSY,n,Busy(20)
exten => _s-.,1,Noop(Dial failed due to ${DIALSTATUS})

; end of [macro-dialout-enum]

[macro-outbound-callerid]
include => macro-outbound-callerid-custom
exten => s,1,GotoIf($["${REALCALLERIDNUM:1:2}" != ""]?start)
exten => s,n,Set(REALCALLERIDNUM=${CALLERID(number)})
exten => s,n(start),Noop(REALCALLERIDNUM is ${REALCALLERIDNUM})
exten => s,n,GotoIf($["${KEEPCID}" != "TRUE"]?normcid)
exten => s,n,GotoIf($["x${OUTKEEPCID_${ARG1}}" = "xon"]?normcid)
exten => s,n,GotoIf($["foo${REALCALLERIDNUM}" = "foo"]?normcid)
exten => s,n,Set(USEROUTCID=${REALCALLERIDNUM})
exten => s,n,GotoIf($["foo${DB(AMPUSER/${REALCALLERIDNUM}/device)}" = "foo"]?bypass:normcid)
exten => s,n(normcid),Set(USEROUTCID=${DB(AMPUSER/${REALCALLERIDNUM}/outboundcid)})
exten => s,n(bypass),Set(EMERGENCYCID=${DB(DEVICE/${REALCALLERIDNUM}/emergency_cid)})
exten => s,n,Set(TRUNKOUTCID=${OUTCID_${ARG1}})
exten => s,n,GotoIf($["${EMERGENCYROUTE:1:2}" = ""]?trunkcid)
exten => s,n,GotoIf($["${EMERGENCYCID:1:2}" = ""]?trunkcid)
exten => s,n,Set(CALLERID(all)=${EMERGENCYCID})
exten => s,n,Goto(report)
exten => s,n(trunkcid),GotoIf($["${TRUNKOUTCID:1:2}" = ""]?usercid)
exten => s,n,Set(CALLERID(all)=${TRUNKOUTCID})
exten => s,n(usercid),GotoIf($["${USEROUTCID:1:2}" = ""]?report)
exten => s,n,Set(CALLERID(all)=${USEROUTCID})
exten => s,n,GotoIf($["x${CALLERID(name)}"!="xhidden"]?report:hidecid)
exten => s,n(hidecid),SetCallerPres(prohib_passed_screen)
exten => s,n(report),Noop(CallerID set to ${CALLERID(all)})

; end of [macro-outbound-callerid]

[macro-agent-add]
include => macro-agent-add-custom
exten => s,1,Wait(1)
exten => s,n,Macro(user-callerid,SKIPTTL)
exten => s,n(a3),Read(CALLBACKNUM,agent-user,,,,)
exten => s,n,GotoIf($["${CALLBACKNUM}" != ""]?a7)
exten => s,n(a5),Set(CALLBACKNUM=${AMPUSER})
exten => s,n,ExecIf($["${CALLBACKNUM}" = ""],Set,CALLBACKNUM=${CALLERID(number)})
exten => s,n,GotoIf($["${CALLBACKNUM}" = ""]?a3)
exten => s,n(a7),GotoIf($["${CALLBACKNUM}" = "${ARG1}"]?invalid)
exten => s,n,ExecIf($["${ARG2}" != ""],Authenticate,${ARG2})
exten => s,n(a9),AddQueueMember(${ARG1},Local/${CALLBACKNUM}@from-internal/n)
exten => s,n,UserEvent(Agentlogin,Agent: ${CALLBACKNUM})
exten => s,n,Wait(1)
exten => s,n,Playback(agent-loginok&with&extension)
exten => s,n,SayDigits(${CALLBACKNUM})
exten => s,n,Hangup
exten => s,n,MacroExit()
exten => s,n(invalid),Playback(pbx-invalid)
exten => s,n,Goto(a3)

; end of [macro-agent-add]

[macro-agent-del]
include => macro-agent-del-custom
exten => s,1,Wait(1)
exten => s,n,Macro(user-callerid,SKIPTTL)
exten => s,n(a3),Read(CALLBACKNUM,agent-user,,,,)
exten => s,n,GotoIf($["${CALLBACKNUM}" = ""]?a5:a7)
exten => s,n(a5),Set(CALLBACKNUM=${AMPUSER})
exten => s,n,ExecIf($["${CALLBACKNUM}" = ""],Set,CALLBACKNUM=${CALLERID(number)})
exten => s,n,GotoIf($["${CALLBACKNUM}" = ""]?a3)
exten => s,n(a7),RemoveQueueMember(${ARG1},Local/${CALLBACKNUM}@from-internal/n)
exten => s,n,UserEvent(RefreshQueue)
exten => s,n,Wait(1)
exten => s,n,Playback(agent-loggedoff)
exten => s,n,Hangup

; end of [macro-agent-del]

[macro-systemrecording]
include => macro-systemrecording-custom
exten => s,1,Goto(${ARG1},1)
exten => dorecord,1,Record(/tmp/${AMPUSER}-ivrrecording:wav)
exten => dorecord,n,Wait(1)
exten => dorecord,n,Goto(confmenu,1)
exten => docheck,1,Playback(/tmp/${AMPUSER}-ivrrecording)
exten => docheck,n,Wait(1)
exten => docheck,n,Goto(confmenu,1)
exten => confmenu,1,Background(to-listen-to-it&press-1&to-rerecord-it&press-star,m,${CHANNEL(language)},macro-systemrecording)
exten => confmenu,n,Read(RECRESULT,,1,,,4)
exten => confmenu,n,GotoIf($["x${RECRESULT}"="x*"]?dorecord,1)
exten => confmenu,n,GotoIf($["x${RECRESULT}"="x1"]?docheck,1)
exten => confmenu,n,Goto(1)
exten => 1,1,Goto(docheck,1)
exten => *,1,Goto(dorecord,1)
exten => t,1,Playback(goodbye)
exten => t,n,Hangup
exten => i,1,Playback(pm-invalid-option)
exten => i,n,Goto(confmenu,1)
exten => h,1,Hangup

; end of [macro-systemrecording]

[from-internal-additional]
include => from-internal-additional-custom
include => vmblast-grp
include => app-callwaiting-cwoff
include => app-callwaiting-cwon
include => ext-meetme
include => app-blacklist
include => app-cf-busy-off
include => app-cf-busy-off-any
include => app-cf-busy-on
include => app-cf-off
include => app-cf-off-any
include => app-cf-on
include => app-cf-unavailable-off
include => app-cf-unavailable-on
include => app-daynight
include => app-daynight-toggle
include => app-dnd-off
include => app-dnd-on
include => app-speeddial
include => app-dictate-record
include => app-dictate-send
include => park-hints
include => app-recordings
include => ext-findmefollow
include => fmgrps
include => ext-paging
include => app-gabcast
include => app-calltrace
include => app-directory
include => app-echo-test
include => app-speakextennum
include => app-speakingclock
include => app-languages
include => ext-queues
include => app-dialvm
include => app-vmmain
include => ext-group
include => grps
include => app-pbdirectory
include => app-userlogonoff
include => app-pickup
include => app-zapbarge
include => app-chanspy
include => ext-test
include => ext-local
include => outbound-allroutes
exten => h,1,Hangup

; end of [from-internal-additional]

; This file contains example extensions_custom.conf entries.
; extensions_custom.conf should be used to include customizations
; to AMP's Asterisk dialplan.

; All custom context should contain the string 'custom' in it's name

; Extensions in AMP have access to the 'from-internal' context.
; The context 'from-internal-custom' is included in 'from-internal' by default

#include extensions_hud.conf

[from-internal-custom]

;1234,1,Playback(demo-congrats) ; extensions can dial 1234
;1234,2,Hangup()
;h,1,Hangup()
;include => custom-recordme ; extensions can also dial 5678

; custom-count2four,s,1 can be used as a custom target for
; a Digital Receptionist menu or a Call Group
;[custom-count2four]
;s,1,SayDigits(1234)
;s,2,Hangup

; custom-recordme,5678,1 can be used as a custom target for
; a Digital Receptionist menu or a Call Group
;[custom-recordme]
;exten => 5678,1,Wait(2)
;exten => 5678,2,Record(/tmp/asterisk-recording:gsm)
;exten => 5678,3,Wait(2)
;exten => 5678,4,Playback(/tmp/asterisk-recording)
;exten => 5678,5,Wait(2)
;exten => 5678,6,Hangup

[custom-meetme3]
exten => s,1,Answer
exten => s,n,Wait(3)
exten => s,n,CBMysql()
exten => s,n,Hangup



KodaK
Posts: 1885
Member Since:
2006-06-14
Well, at a glance I'm seeing

Well, at a glance I'm seeing that you're defining multiple contexts in the zapata*.conf files:

signalling=fxo_ks
callerid="Channel 1" <6001>
mailbox=6001
group=5
context=from-internal
channel => 1
callerid=
mailbox=
group=
context=default

You're defining many things multiple times. I suggest you just move all of the zapata*.conf files and the zaptel.conf files to a backup, then re-run setup-pstn and possibly genzaptelconf. If you don't understand what I mean by this, please ask for clarification before you do anything.

Also: 1) I didn't ask for extensions.conf, so it concerns me that you may misunderstand what I meant by zapata*.conf. Just so you don't accidentally hose anything: I'm talking specifically about files that start with zapata have something else in the middle and end in .conf. 2) did you not understand what I meant when I said "use the code tags?" Because that's configuration vomit up there and very hard to follow in these narrow-ass forums.

In the future: long stuff goes to pastebin.ca or pastebin.com, shorter stuff can get copied into a code tag. It's just easier. And in the dentists thread.

--

WARNING: I no longer actively participate in these forums. My thoughts on trixbox in a nutshell: http://www.youtube.com/watch?v=q4xBMkWu1pE Use AsteriskNOW instead.



Peter847
Posts: 41
Member Since:
2007-09-14
TDM 400 Issues

OK I've installed trixbox 2.6.0.7 onto a working 2.4.1 system. Just created one extension & one AnyDID/AnyCD inbound route and it fails again. Here are the key lines from the CLI log (last four digits on dailed number X'd out):

 -- Executing [s@macro-dialout-trunk:20] Dial("Zap/1-1", "ZAP/g0/1224436XXXX|300|") in new stack
    -- Called g0/1224436XXXX
trixbox1*CLI> Use of uninitialized value in concatenation (.) or string at /var/www/html/panel/op_server.pl line 1924.
Use of uninitialized value in concatenation (.) or string at /var/www/html/panel/op_server.pl line 1924.
    -- Hungup 'Zap/4-1'
  == Everyone is busy/congested at this time (1:0/0/1)
    -- Executing [s@macro-dialout-trunk:21] Goto("Zap/1-1", "s-CHANUNAVAIL|1") in new stack
    -- Goto (macro-dialout-trunk,s-CHANUNAVAIL,1)

and I think this is the problem area in the asterisk/full log:

[Apr 26 18:22:25] VERBOSE[3982] logger.c:     -- Executing [s@macro-dialout-trunk:20] Dial("Zap/1-1", "ZAP/g0/1224436XXXX|300|") in new stack
[Apr 26 18:22:25] DEBUG[3982] chan_zap.c: Dialing '1224436XXXX'
[Apr 26 18:22:25] DEBUG[3982] chan_zap.c: Deferring dialing...
[Apr 26 18:22:25] VERBOSE[3982] logger.c:     -- Called g0/1224436XXXX
[Apr 26 18:22:25] WARNING[3982] chan_zap.c: Detected alarm on channel 4: No Alarm
[Apr 26 18:22:25] VERBOSE[3982] logger.c:     -- Hungup 'Zap/4-1'
[Apr 26 18:22:25] VERBOSE[3982] logger.c:   == Everyone is busy/congested at this time (1:0/0/1)
[Apr 26 18:22:25] DEBUG[3982] app_macro.c: Executed application: Dial
[Apr 26 18:22:25] VERBOSE[3982] logger.c:     -- Executing [s@macro-dialout-trunk:21] Goto("Zap/1-1", "s-CHANUNAVAIL|1") in new stack

So it looks to me like the zaptel driver thinks there is an alarm on the channel. Interestingly if I take the PSTN line off hook with another phone it dials out correctly. Inbound calls seem to work but I've not realy checked this out fully. Finally I have the same multiple definitions in my zapata.conf files as castrox but that's what setup-pstn produced.

Let me know if you need the full logs and I'll work out how to paste them into pastebin

Thanks

Peter



castrox
Posts: 13
Member Since:
2008-04-23
We've tried updating the

We've tried updating the zaptel firmware, as suggested in other threads, and it didnt help. having a phone off the hook on that interface did the trick, though. Does anyone have any other ideas? I've recreated all the conf files and yes, there does seem to be 2 contexts defined - what does yours say?



Peter847
Posts: 41
Member Since:
2007-09-14
Have a look in the Help

Have a look in the Help forum at the post "Trixbox 2.6.0.7 Zaptel Card allowing incoming, outgoing always busy. HELP". The consensus is that something broke in the zaptel driver for 2.6.0.7 but the latest beta seems OK. Just wish someone on the trixbox team would pick up on this . . . .



Peter847
Posts: 41
Member Since:
2007-09-14
Oops forgot to answer your

Oops forgot to answer your question - sorry I can't get at my 2.6.0.7 config files as the system is back on line with a 2.4.1 version now. I can send you those (2.4.1 files) later tonight if that will help but I don't think it is the problem.



castrox
Posts: 13
Member Since:
2008-04-23
So do i use the zaphfc

So do i use the zaphfc thing? I'm not sure that i know what that thread is talking about.

Thanks
Cullen



castrox
Posts: 13
Member Since:
2008-04-23
whoops, read the wrong

whoops, read the wrong thread. I got the .10 drivers installed and incoming calls do still work, but i still cant call out. same error. went through all the steps that kodak outlined. any other ideas?



Peter847
Posts: 41
Member Since:
2007-09-14
Reading other threads it

Reading other threads it seems most people reckon a clean instal of 2.6.1 has cured their problems - have you tried this with a minimal configuration, one extension & one inbound route is all you need to setup. I can't try this until the weekend so I don't know if will cure my/your problem.



castrox
Posts: 13
Member Since:
2008-04-23
I will try this today and

I will try this today and get back to you...connection here is awfully slow, not sure when ill be able to.



castrox
Posts: 13
Member Since:
2008-04-23
Reinstalled a brand new

Reinstalled a brand new freshly downloaded version, followed all the steps kodak gave, got the same result. I can call in but not out. taking the line off the hook (so there is a dial tone present) before dialing allows me to dial out. could this be something having to do with dtmf stuff? I want to try updating the zap driver but what i tried before didnt change the version. anyone know how to do this?



Peter847
Posts: 41
Member Since:
2007-09-14
Beta download

Are you sure you are downloading trixbox 2.6.1 (its on a link in the beta forum), the latest "stable" release is still 2.6.0.7. Apologies if this is a dumb question.



dg659
Posts: 1
Member Since:
2008-04-30
I Know nothing i am a newbie here

BUT have you tried looking at the IRQ details of your hardware this sounds much like a hardware issue if on one piece of hardware on version 1 is ok but version 2 of the softwear balks . Suggests to me some kind of PNP b*lls up ( im thinking win95 here yeah im that OLD) if this is posible i would move the card to a different slot reset the bios and do a fresh install.



sbiltda
Posts: 1
Member Since:
2008-04-01
Problem TDM410P

Hello I am also running the 2.6.0.4 version of trixbox, I have a card tdm410P but when I review the system console ame indicates:
Ethernet controller: Digium, Inc. All rights reserved. Unknown Device 8005
I have read the manual "tribox without tears" and this tells me that I should run the command "rebuild_zaptel" but linux indicates that "command not found", you can help me to find out how did you do to recognize that in your system.



netout
Posts: 187
Member Since:
2007-08-18
I am having the same problem

I am having the same problem with a teliax VoIP line and Aastra 57i phone. I have a feeling that it is a problem with the dial plan. The reason I think that is we had problems with the 50i series phones on on trixbox Pro before 2.0 came out. This is a 2.6.0.7. We tried this on two different systems in two different locations.

-- Executing [98327156981@from-internal:1] Macro("SIP/2100-0a1559f8", "user- callerid|SKIPTTL|") in new stack
-- Executing [s@macro-user-callerid:1] NoOp("SIP/2100-0a1559f8", "user-calle rid: device 2100") in new stack
-- Executing [s@macro-user-callerid:2] Set("SIP/2100-0a1559f8", "AMPUSER=210 0") in new stack
-- Executing [s@macro-user-callerid:3] GotoIf("SIP/2100-0a1559f8", "0?report ") in new stack
-- Executing [s@macro-user-callerid:4] ExecIf("SIP/2100-0a1559f8", "1|Set|RE ALCALLERIDNUM=2100") in new stack
-- Executing [s@macro-user-callerid:5] NoOp("SIP/2100-0a1559f8", "REALCALLER IDNUM is 2100") in new stack
-- Executing [s@macro-user-callerid:6] Set("SIP/2100-0a1559f8", "AMPUSER=210 0") in new stack
-- Executing [s@macro-user-callerid:7] Set("SIP/2100-0a1559f8", "AMPUSERCIDN AME=Extension 2") in new stack
-- Executing [s@macro-user-callerid:8] GotoIf("SIP/2100-0a1559f8", "0?report ") in new stack
-- Executing [s@macro-user-callerid:9] Set("SIP/2100-0a1559f8", "AMPUSERCID= 2100") in new stack
-- Executing [s@macro-user-callerid:10] Set("SIP/2100-0a1559f8", "CALLERID(a ll)="Extension 2" ") in new stack
-- Executing [s@macro-user-callerid:11] Set("SIP/2100-0a1559f8", "REALCALLER IDNUM=2100") in new stack
-- Executing [s@macro-user-callerid:12] ExecIf("SIP/2100-0a1559f8", "0|Set|C HANNEL(language)=") in new stack
-- Executing [s@macro-user-callerid:13] NoOp("SIP/2100-0a1559f8", "TTL: ARG 1: SKIPTTL") in new stack
-- Executing [s@macro-user-callerid:14] GotoIf("SIP/2100-0a1559f8", "1?conti nue") in new stack
-- Goto (macro-user-callerid,s,23)
-- Executing [s@macro-user-callerid:23] NoOp("SIP/2100-0a1559f8", "Using Cal lerID "Extension 2" ") in new stack
-- Executing [98327156981@from-internal:2] Set("SIP/2100-0a1559f8", "_NODEST =") in new stack
-- Executing [98327156981@from-internal:3] Macro("SIP/2100-0a1559f8", "recor d-enable|2100|OUT|") in new stack
-- Executing [s@macro-record-enable:1] GotoIf("SIP/2100-0a1559f8", "0?2:4") in new stack
-- Goto (macro-record-enable,s,4)
-- Executing [s@macro-record-enable:4] AGI("SIP/2100-0a1559f8", "recordingch eck|20080502-084145|1209735705.2") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/recordingcheck
recordingcheck|20080502-084145|1209735705.2: Outbound recording not enabled
-- AGI Script recordingcheck completed, returning 0
-- Executing [s@macro-record-enable:5] NoOp("SIP/2100-0a1559f8", "No recordi ng needed") in new stack
-- Executing [98327156981@from-internal:4] Macro("SIP/2100-0a1559f8", "dialo ut-trunk|1|8327156981|") in new stack
-- Executing [s@macro-dialout-trunk:1] Set("SIP/2100-0a1559f8", "DIAL_TRUNK= 1") in new stack
-- Executing [s@macro-dialout-trunk:2] ExecIf("SIP/2100-0a1559f8", "0|Authen ticate|") in new stack
-- Executing [s@macro-dialout-trunk:3] GotoIf("SIP/2100-0a1559f8", "0?disabl etrunk|1") in new stack
-- Executing [s@macro-dialout-trunk:4] Set("SIP/2100-0a1559f8", "DIAL_NUMBER =8327156981") in new stack
-- Executing [s@macro-dialout-trunk:5] Set("SIP/2100-0a1559f8", "DIAL_TRUNK_ OPTIONS=tr") in new stack
-- Executing [s@macro-dialout-trunk:6] Set("SIP/2100-0a1559f8", "GROUP()=OUT _1") in new stack
-- Executing [s@macro-dialout-trunk:7] GotoIf("SIP/2100-0a1559f8", "1?nomax" ) in new stack
-- Goto (macro-dialout-trunk,s,9)
-- Executing [s@macro-dialout-trunk:9] GotoIf("SIP/2100-0a1559f8", "0?skipou tcid") in new stack
-- Executing [s@macro-dialout-trunk:10] Set("SIP/2100-0a1559f8", "DIAL_TRUNK _OPTIONS=") in new stack
-- Executing [s@macro-dialout-trunk:11] Macro("SIP/2100-0a1559f8", "outbound -callerid|1") in new stack
-- Executing [s@macro-outbound-callerid:1] GotoIf("SIP/2100-0a1559f8", "1?st art") in new stack
-- Goto (macro-outbound-callerid,s,3)
-- Executing [s@macro-outbound-callerid:3] NoOp("SIP/2100-0a1559f8", "REALCA LLERIDNUM is 2100") in new stack
-- Executing [s@macro-outbound-callerid:4] GotoIf("SIP/2100-0a1559f8", "1?no rmcid") in new stack
-- Goto (macro-outbound-callerid,s,9)
-- Executing [s@macro-outbound-callerid:9] Set("SIP/2100-0a1559f8", "USEROUT CID=") in new stack
-- Executing [s@macro-outbound-callerid:10] Set("SIP/2100-0a1559f8", "EMERGE NCYCID=") in new stack
-- Executing [s@macro-outbound-callerid:11] Set("SIP/2100-0a1559f8", "TRUNKO UTCID=") in new stack
-- Executing [s@macro-outbound-callerid:12] GotoIf("SIP/2100-0a1559f8", "1?t runkcid") in new stack
-- Goto (macro-outbound-callerid,s,16)
-- Executing [s@macro-outbound-callerid:16] GotoIf("SIP/2100-0a1559f8", "1?u sercid") in new stack
-- Goto (macro-outbound-callerid,s,18)
-- Executing [s@macro-outbound-callerid:18] GotoIf("SIP/2100-0a1559f8", "1?r eport") in new stack
-- Goto (macro-outbound-callerid,s,22)
-- Executing [s@macro-outbound-callerid:22] NoOp("SIP/2100-0a1559f8", "Calle rID set to "Extension 2" ") in new stack
-- Executing [s@macro-dialout-trunk:12] AGI("SIP/2100-0a1559f8", "fixlocalpr efix") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/fixlocalprefix
-- AGI Script fixlocalprefix completed, returning 0
-- Executing [s@macro-dialout-trunk:13] Set("SIP/2100-0a1559f8", "OUTNUM=832 7156981") in new stack
-- Executing [s@macro-dialout-trunk:14] Set("SIP/2100-0a1559f8", "custom=ZAP /g0") in new stack
-- Executing [s@macro-dialout-trunk:15] GotoIf("SIP/2100-0a1559f8", "1?gocal l") in new stack
-- Goto (macro-dialout-trunk,s,17)
-- Executing [s@macro-dialout-trunk:17] Macro("SIP/2100-0a1559f8", "dialout- trunk-predial-hook|") in new stack
-- Executing [s@macro-dialout-trunk:18] GotoIf("SIP/2100-0a1559f8", "0?bypas s|1") in new stack
-- Executing [s@macro-dialout-trunk:19] GotoIf("SIP/2100-0a1559f8", "0?custo mtrunk") in new stack
-- Executing [s@macro-dialout-trunk:20] Dial("SIP/2100-0a1559f8", "ZAP/g0/83 27156981|300|") in new stack
== Everyone is busy/congested at this time (1:0/0/1)
-- Executing [s@macro-dialout-trunk:21] Goto("SIP/2100-0a1559f8", "s-CHANUNA VAIL|1") in new stack
-- Goto (macro-dialout-trunk,s-CHANUNAVAIL,1)
-- Executing [s-CHANUNAVAIL@macro-dialout-trunk:1] GotoIf("SIP/2100-0a1559f8 ", "1?noreport") in new stack
-- Goto (macro-dialout-trunk,s-CHANUNAVAIL,3)
-- Executing [s-CHANUNAVAIL@macro-dialout-trunk:3] NoOp("SIP/2100-0a1559f8", "TRUNK Dial failed due to CHANUNAVAIL - failing through to other trunks") in ne w stack
-- Executing [98327156981@from-internal:5] Macro("SIP/2100-0a1559f8", "outis busy|") in new stack
-- Executing [s@macro-outisbusy:1] Playback("SIP/2100-0a1559f8", "all-circui ts-busy-now|noanswer") in new stack
-- Playing 'all-circuits-busy-now' (language 'en')
-- Executing [s@macro-outisbusy:2] Playback("SIP/2100-0a1559f8", "pls-try-ca ll-later|noanswer") in new stack
-- Playing 'pls-try-call-later' (language 'en')
-- Executing [s@macro-outisbusy:3] Macro("SIP/2100-0a1559f8", "hangupcall") in new stack
-- Executing [s@macro-hangupcall:1] ResetCDR("SIP/2100-0a1559f8", "w") in ne w stack
-- Executing [s@macro-hangupcall:2] NoCDR("SIP/2100-0a1559f8", "") in new st ack
-- Executing [s@macro-hangupcall:3] GotoIf("SIP/2100-0a1559f8", "1?skiprg") in new stack
-- Goto (macro-hangupcall,s,6)
-- Executing [s@macro-hangupcall:6] GotoIf("SIP/2100-0a1559f8", "1?skipblkvm ") in new stack
-- Goto (macro-hangupcall,s,9)
-- Executing [s@macro-hangupcall:9] GotoIf("SIP/2100-0a1559f8", "1?theend") in new stack
-- Goto (macro-hangupcall,s,11)
-- Executing [s@macro-hangupcall:11] Hangup("SIP/2100-0a1559f8", "") in new stack
== Spawn extension (macro-hangupcall, s, 11) exited non-zero on 'SIP/2100-0a15 59f8' in macro 'hangupcall'
== Spawn extension (macro-hangupcall, s, 11) exited non-zero on 'SIP/2100-0a15 59f8' in macro 'outisbusy'
== Spawn extension (macro-hangupcall, s, 11) exited non-zero on 'SIP/2100-0a15 59f8'

--

Michael D Mosier
Sr. Telecom Engineer
Network Outfitters
Houston, Austin and San Antonio
Support Available
832-715-6981



Ceres
Posts: 3
Member Since:
2007-12-04
Same Problem

I had the same problem, but was able to resolve the issue.

TDM400 card
fresh Trixbox 2.6 install
zapata*conf files generated by trixbox (setup-pstn, genzaptelconf)
INbound calls connect
OUTbound calls are met immediatly with "All circuits are busy now"

Here is a snippet of my log:
Dial("SIP/6200-09c96ab8", "ZAP/g0/2815551212|300|") in new stack
[Jun 11 09:59:49] DEBUG[2310] chan_zap.c: Dialing '2815551212'
[Jun 11 09:59:49] DEBUG[2310] chan_zap.c: Deferring dialing...
[Jun 11 09:59:49] VERBOSE[2310] logger.c: -- Called g0/2815551212
[Jun 11 09:59:49] VERBOSE[2310] logger.c: -- Hungup 'Zap/3-1'
[Jun 11 09:59:49] VERBOSE[2310] logger.c: == Everyone is busy/congested at this time (1:0/0/1)

I have two boxes running trixbox 2.4 in different locations, but same card, same zapata*conf files and zaptel.conf as this new 2.6 box, and all is well. Trunks/Inbound Route/Outbound Route are all set the same as well. So the problem can't be config related.

Here is how I resolved the problem.

STEP 1: Updated zaptel modules to the latest version (if you are not comfortable using the command line, this is easy to do using the trixbox interface. Under Settings->Repositories put a check mark next to Trixbox Beta and save. Go to Packages and select the zaptel-modules at or near the bottom of the list, should be v 1.4.10.... click install at the bottom of the page. Reboot)

STEP 2: With the new zaptel modules I was no longer getting "All circuits are busy now", but was getting 20 sec or so of dead air then a hangup. I added a "w" to the "Outbound Dial Prefix" of the zap trunk (tells asterisk to wait few seconds after going off hook before it starts dialing), and now can dial out with no problems.

Hope this helps someone.



agetz1
Posts: 14
Member Since:
2006-06-20
Fixed my problem grrrrr

We were wanting to move from our backup box to our production box and i've tried everything and have spend hours trying to fix it.

I hope this helps someone else because I could find nothing to help me out with my problem. Here is the setup.

Dell PE 830 Raid 1 (Mirrored) with hyper threading enabled.
T1 Card: TE205P
Trixbox Version: 2.6.0.4
Problem: Everything would install fine, including the card but was unable to get the D channel to sync up with our Adtran device. The lights flashed slowly back and forth whether or not the cable was plugged in or not. I saw all the post to update zaptel, move the card to another slot, uninstall zaptel and rebuild, run the 5 commands to initialize the card, setup-pstn, genzaptelconf, etc. Nothing worked

Strange Solution but it worked.
Installed the new version of trixbox 2.6.1 to see if the new zaptel would configure. Still no dice so i thought i'd change the T1 card slot. Shutdown the box, pulled the power plug, hit the power button to completely discharge the power and pulled the card. Attempted to put into another slot but found out that there was only one pci slot, the other two were 64bit slots. Put the card back into where it came from and rebooted. Light was green and the D channel was configured.

So for the real test i wanted to go back to the prior version (2.6.0.4) to see if it would still configure. Installed and immediately the lights turned green with out having to do any command/conf changes. Moral of the story, discharge the power of the box and pull the card. I'm amazed. :)
Hope this helps.



graphx
Posts: 7
Member Since:
2008-06-24
Context issue

same issue ... I will post fresh...

--

-SF-



mwprintequip
Posts: 12
Member Since:
2008-06-25
THANK YOU! I have been

RE: ceres

THANK YOU! I have been pulling my hair out trying to get this box working and this did it!



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.