--- /dev/null
+; How should calls be handled for PSTN/POTS calls?
+; This will probably need to be customised for each site.
+;
+; To use this simple implementation add the following to extensions.conf:
+;
+; #include "pstn.conf"
+;
+
+[pstn]
+;;;
+;;; Handle PSTN dialout
+;;;
+
+; Let the 3 digit numbers out (111, Telecom, TelstraClear, Vodafone, etc)
+exten => _XXX,1,Dial(${TRUNK}/${ARG1})
+
+exten => _188299.,1,Macro(enum-call,pstn-international,${ARG1:1})
+exten => _1Z.,1,Macro(enum-call,pstn-localcall,644${ARG1:1})
+exten => _104.,1,Macro(enum-call,pstn-localcall,64${ARG1:2})
+exten => _102.,1,Macro(enum-call,pstn-mobile,64${ARG1:2})
+exten => _10Z.,1,Macro(enum-call,pstn-longdistance,64${ARG1:2})
+exten => _100644Z.,1,Macro(enum-call,pstn-localcall,${ARG1:3})
+exten => _100642Z.,1,Macro(enum-call,pstn-mobile,${ARG1:3})
+exten => _10064XXXXXXXX,1,Macro(enum-call,pstn-longdistance,${ARG1:3})
+exten => _100Z.,1,Macro(enum-call,pstn-international,${ARG1:3})
+
+[macro-enum-call]
+exten => s,1,AGI(enum.agi,${ARG2})
+exten => s,n,Macro(${ARG1},${ARG2})
+
+[macro-pstn-localcall] ; local calls by PSTN is a fixed charge, voip is per minute
+;exten => s,1,Dial(ZAP/1/${ARG1:3},60,t)
+;exten => s,2,Dial(IAX2/user:pass@localprovider.co.nz/${ARG1:3},60,t)
+;exten => s,3,Dial(IAX2/user:pass@secondprovider.co.nz/${ARG1:3},60,t)
+exten => s,4,Hangup
+exten => s,101,Hangup
+exten => s,102,Hangup
+exten => s,103,Hangup
+
+[macro-pstn-longdistance] ; long distance by VOIP is deffinately cheaper then PSTN in Australia
+;exten => s,1,StripMSD(2)
+;exten => s,2,Prefix(0)
+;exten => s,3,Dial(IAX2/user:pass@localprovider.co.nz/0${ARG1:2},60,t)
+;exten => s,4,Dial(IAX2/user:pass@secondprovider.co.nz/0${ARG1:2},60,t)
+exten => s.,5,Hangup
+;exten => _X.,103,Hangup
+;exten => _X.,104,Hangup
+
+[macro-pstn-mobile] ; Maybe be cheaper to route pstn-mobile calls differently to pstn-longdistance in some cases
+exten => s,1,Macro(pstn-longdistance,${ARG1})
+
+[macro-pstn-international] ; Using overseas providers for calls is usually cheaper but more lag
+;exten => s,1,Dial(IAX2/user:pass@provider1.com/00${ARG1},60,t)
+;exten => s,2,Dial(IAX2/user:pass@provider2.com/00${ARG1},60,t)
+;exten => s,3,Dial(ZAP/1/00${ARG1},60,t)
+;exten => s,4,Hangup
+;exten => s,102,Hangup
+;exten => s,103,Hangup
+;exten => s,104,Hangup