All pastes #911421 Raw Edit

Untitled

public text v1 · immutable
·published 2008-02-20 18:14 UTC
rendered paste body
------------------------------------------------------------------------
extensions.conf
------------------------------------------------------------------------
;
; Static extension configuration file, used by
; the pbx_config module. This is where you configure all your 
; inbound and outbound calls in Asterisk. 
; 
; This configuration file is reloaded 
; - With the "extensions reload" command in the CLI
; - With the "reload" command (that reloads everything) in the CLI

;
; The "General" category is for certain variables.  
;
[general]
;
; If static is set to no, or omitted, then the pbx_config will rewrite
; this file when extensions are modified.  Remember that all comments
; made in the file will be lost when that happens. 
;
; XXX Not yet implemented XXX
;
static=yes
;
; if static=yes and writeprotect=no, you can save dialplan by
; CLI command 'save dialplan' too
;
writeprotect=no
;
; If autofallthrough is set, then if an extension runs out of
; things to do, it will terminate the call with BUSY, CONGESTION
; or HANGUP depending on Asterisk's best guess (strongly recommended).
;
; If autofallthrough is not set, then if an extension runs out of 
; things to do, asterisk will wait for a new extension to be dialed 
; (this is the original behavior of Asterisk 1.0 and earlier).
;
autofallthrough=yes
;
; If clearglobalvars is set, global variables will be cleared 
; and reparsed on an extensions reload, or Asterisk reload.
;
; If clearglobalvars is not set, then global variables will persist
; through reloads, and even if deleted from the extensions.conf or
; one if its included files, will remain set to the previous value.
;
clearglobalvars=no
;
; If priorityjumping is set to 'yes', then applications that support
; 'jumping' to a different priority based on the result of their operations
; will do so (this is backwards compatible behavior with pre-1.2 releases
; of Asterisk). Individual applications can also be requested to do this
; by passing a 'j' option in their arguments.
;
priorityjumping=no
;
; You can include other config files, use the #include command
; (without the ';'). Note that this is different from the "include" command
; that includes contexts within other contexts. The #include command works
; in all asterisk configuration files.
;#include "filename.conf"

; The "Globals" category contains global variables that can be referenced
; in the dialplan with ${VARIABLE} or ${ENV(VARIABLE)} for Environmental
; variables,
; ${${VARIABLE}} or ${text${VARIABLE}} or any hybrid
;
[globals]
CONSOLE=Console/dsp				; Console interface for demo
;CONSOLE=Zap/1
;CONSOLE=Phone/phone0
IAXINFO=guest					; IAXtel username/password
;IAXINFO=myuser:mypass
TRUNK=Zap/G1					; Trunk interface
CELLTRUNK=Zap/2
;FIREBALLIAXTRUNK=IAX2/kirkhamsystems@teliax
KIRKHAMIAXTRUNK=IAX2/kirkhamsystems2@teliax2
RINGTIME=25
MAXPSTNCALLS=1
;
; Note the 'g2' in the TRUNK variable above. It specifies which group (defined
; in zapata.conf) to dial, i.e. group 2, and how to choose a channel to use in
; the specified group. The four possible options are:
;
; g: select the lowest-numbered non-busy Zap channel
;    (aka. ascending sequential hunt group).
; G: select the highest-numbered non-busy Zap channel
;    (aka. descending sequential hunt group).
; r: use a round-robin search, starting at the next highest channel than last
;    time (aka. ascending rotary hunt group).
; R: use a round-robin search, starting at the next lowest channel than last
;    time (aka. descending rotary hunt group).
;
TRUNKMSD=1	; MSD digits to strip (usually 1 or 0)
;TRUNK=IAX2/user:pass@provider

;
; Any category other than "General" and "Globals" represent 
; extension contexts, which are collections of extensions.  
;
; Extension names may be numbers, letters, or combinations
; thereof. If an extension name is prefixed by a '_'
; character, it is interpreted as a pattern rather than a
; literal.  In patterns, some characters have special meanings:
;
;   X - any digit from 0-9
;   Z - any digit from 1-9
;   N - any digit from 2-9
;   [1235-9] - any digit in the brackets (in this example, 1,2,3,5,6,7,8,9)
;   . - wildcard, matches anything remaining (e.g. _9011. matches 
;	anything starting with 9011 excluding 9011 itself)
;   ! - wildcard, causes the matching process to complete as soon as
;       it can unambiguously determine that no other matches are possible
;
; For example the extension _NXXXXXX would match normal 7 digit dialings, 
; while _1NXXNXXXXXX would represent an area code plus phone number
; preceeded by a one.
;
; Each step of an extension is ordered by priority, which must
; always start with 1 to be considered a valid extension.  The priority
; "next" or "n" means the previous priority plus one, regardless of whether
; the previous priority was associated with the current extension or not.
; The priority "same" or "s" means the same as the previously specified
; priority, again regardless of whether the previous entry was for the
; same extension.  Priorities may be immediately followed by a plus sign
; and another integer to add that amount (most useful with 's' or 'n').  
; Priorities may then also have an alias, or label, in 
; parenthesis after their name which can be used in goto situations
;
; Contexts contain several lines, one for each step of each
; extension, which can take one of two forms as listed below,
; with the first form being preferred.  One may include another
; context in the current one as well, optionally with a
; date and time.  Included contexts are included in the order
; they are listed.
;
;[context]
;exten => someexten,priority[+offset][(alias)],application(arg1,arg2,...)
;exten => someexten,priority[+offset][(alias)],application,arg1|arg2...
;
; Timing list for includes is 
;
;   <time range>|<days of week>|<days of month>|<months>
;
;include => daytime|9:00-17:00|mon-fri|*|*
;
; ignorepat can be used to instruct drivers to not cancel dialtone upon
; receipt of a particular pattern.  The most commonly used example is
; of course '9' like this:
;
;ignorepat => 9
;
; so that dialtone remains even after dialing a 9.
;

;
; Sample entries for extensions.conf
;
;
[dundi-e164-canonical]
;
; List canonical entries here
;
;exten => 12564286000,1,Macro(std-exten,6000,IAX2/foo)
;exten => _125642860XX,1,Dial(IAX2/otherbox/${EXTEN:7})

[dundi-e164-customers]
;
; If you are an ITSP or Reseller, list your customers here.
;
;exten => _12564286000,1,Dial(SIP/customer1)
;exten => _12564286001,1,Dial(IAX2/customer2)

[dundi-e164-via-pstn]
;
; If you are freely delivering calls to the PSTN, list them here
;
;exten => _1256428XXXX,1,Dial(Zap/g2/${EXTEN:7}) ; Expose all of 256-428 
;exten => _1256325XXXX,1,Dial(Zap/g2/${EXTEN:7}) ; Ditto for 256-325

[dundi-e164-local]
;
; Context to put your dundi IAX2 or SIP user in for
; full access
;
include => dundi-e164-canonical
include => dundi-e164-customers
include => dundi-e164-via-pstn

[dundi-e164-switch]
;
; Just a wrapper for the switch
;
switch => DUNDi/e164

[dundi-e164-lookup]
;
; Locally to lookup, try looking for a local E.164 solution
; then try DUNDi if we don't have one.
;
include => dundi-e164-local
include => dundi-e164-switch
;
; DUNDi can also be implemented as a Macro instead of using 
; the Local channel driver. 
;
[macro-dundi-e164]
;
; ARG1 is the extension to Dial
;
exten => s,1,Goto(${ARG1},1)
include => dundi-e164-lookup

;
; Here are the entries you need to participate in the IAXTEL
; call routing system.  Most IAXTEL numbers begin with 1-700, but
; there are exceptions.  For more information, and to sign
; up, please go to www.gnophone.com or www.iaxtel.com
;
[iaxtel700]
exten => _91700XXXXXXX,1,Dial(IAX2/${IAXINFO}@iaxtel.com/${EXTEN:1}@iaxtel)

;
; The SWITCH statement permits a server to share the dialplain with
; another server. Use with care: Reciprocal switch statements are not
; allowed (e.g. both A -> B and B -> A), and the switched server needs
; to be on-line or else dialing can be severly delayed.
;
[iaxprovider]
;switch => IAX2/user:[key]@myserver/mycontext

[trunkint]
;
; International long distance through trunk
;
exten => _9011.,1,Macro(dundi-e164,${EXTEN:4})
exten => _9011.,n,Dial(${TRUNK}/${EXTEN:${TRUNKMSD}})
;exten => _9011.,n,Dial(SIP/${EXTEN:${TRUNKMSD}}@newroads-outkirkham)

[trunkld]
;
; Long distance context accessed through trunk
;
exten => _91NXXNXXXXXX,1,Macro(dundi-e164,${EXTEN:1})
exten => _91NXXNXXXXXX,n,Macro(fallback,${TRUNK},${EXTEN:${TRUNKMSD}},45,rT)
;exten => _91NXXNXXXXXX,n,Dial(SIP/${EXTEN:${TRUNKMSD}}@newroads-outkirkham,45,rT)

[trunklocal]
;
; Local seven-digit dialing accessed through trunk interface
;
exten => _9[2-9]XXXXXX,1,Macro(fallback,${TRUNK},${EXTEN:${TRUNKMSD}},45,rT)

[macro-fallback]
; ${ARG1} : Trunk to call out on
; ${ARG2} : Number to call
; ${ARG3} : Time to let ring
; ${ARG4} : Dial Options

exten => s,1,UserEvent(TAPI|TAPIEVENT: LINE_NEWCALL ${CHANNEL:0:7})
exten => s,2,UserEvent(TAPI|TAPIEVENT: LINE_CALLSTATE LINECALLSTATE_DIALTONE)
exten => s,3,UserEvent(TAPI|TAPIEVENT: LINE_CALLSTATE LINECALLSTATE_DIALING)
exten => s,4,UserEvent(TAPI|TAPIEVENT: LINE_CALLSTATE LINECALLSTATE_PROCEEDING)
exten => s,5,Dial(${ARG1}/${ARG2},${ARG3},${ARG4}M(tapi^${UNIQUEID}|${CHANNEL:0:7}))
exten => s,6,GotoIf($["${TRUNK}" = "Zap/g2"]?100:7)
exten => s,7,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?trunkcongest,9${ARG2},1:8)
exten => s,8,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?trunkcongest,9${ARG2},1)



[trunkcongest]

exten => _9.,1,GotoIf($["${TRUNK}" = "Zap/2"]?${EXTEN},100:2)
exten => _9.,2,GotoIf($["${TRUNK}" = "Zap/G1"]?${EXTEN},100:3)
exten => _9.,3,GotoIf($["${TRUNK}" = "Zap/G2"]?${EXTEN},200:4)
exten => _9.,4,Noop("No more trunks")

exten => _9.,100,Set(NEWTRUNK=${KIRKHAMIAXTRUNK})
exten => _9.,102,Set(CALLERID(name)="KIRKHAM SYSTEMS")
exten => _9.,103,Goto(${EXTEN},300)

exten => _9.,200,Set(NEWTRUNK=${FIREBALLIAXTRUNK})
;exten => _9.,201,Set(CALLERID(number)=479646xxxx) ; clint's old fireball extension
exten => _9.,202,Set(CALLERID(name)="FIREBALL MEDIA")
exten => _9.,203,Goto(${EXTEN},300)

exten => _9.,300,GotoIf($["${LEN(${EXTEN:${TRUNKMSD}})}" = "7"]?310:302)
exten => _9.,301,GotoIf($["${LEN(${EXTEN:${TRUNKMSD}})}" = "10"]?320:350)
exten => _9.,310,Set(NEWEXTEN=91479${EXTEN:${TRUNKMSD}})
exten => _9.,311,Goto(${EXTEN},350)
exten => _9.,320,Set(NEWEXTEN=91${EXTEN:${TRUNKMSD}})
exten => _9.,321,Goto(${EXTEN},350)
exten => _9.,350,Dial(${NEWTRUNK}/${NEWEXTEN:${TRUNKMSD}},45,rTM(tapi^${UNIQUEID}|${CHANNEL:0:7}))

[trunkshortcodes]
exten => _9N11,1,Dial(${TRUNK}/${EXTEN:${TRUNKMSD}})
exten => _91411,1,Dial(${TRUNK}/${EXTEN:${TRUNKMSD}})

[trunktollfree]
;
; Long distance context accessed through trunk interface
;
exten => _91800NXXXXXX,1,Dial(${TRUNK}/${EXTEN:${TRUNKMSD}})
exten => _91888NXXXXXX,1,Dial(${TRUNK}/${EXTEN:${TRUNKMSD}})
exten => _91877NXXXXXX,1,Dial(${TRUNK}/${EXTEN:${TRUNKMSD}})
exten => _91866NXXXXXX,1,Dial(${TRUNK}/${EXTEN:${TRUNKMSD}})

[international]
;
; Master context for international long distance
;
ignorepat => 9
include => longdistance
include => trunkint

[longdistance]
;
; Master context for long distance
;
ignorepat => 9
include => local
include => trunkld

[trunktendigit]

[local]
;
; Master context for local, toll-free, and iaxtel calls only
;
ignorepat => 9
include => default
include => parkedcalls
include => trunktendigit
include => trunklocal
include => iaxtel700
include => trunktollfree
include => iaxprovider
include => trunkshortcodes
;
; You can use an alternative switch type as well, to resolve
; extensions that are not known here, for example with remote 
; IAX switching you transparently get access to the remote
; Asterisk PBX
; 
; switch => IAX2/user:password@bigserver/local
;
; An "lswitch" is like a switch but is literal, in that
; variable substitution is not performed at load time
; but is passed to the switch directly (presumably to
; be substituted in the switch routine itself)
;
; lswitch => Loopback/12${EXTEN}@othercontext
;
; An "eswitch" is like a switch but the evaluation of
; variable substitution is performed at runtime before
; being passed to the switch routine.
;
; eswitch => IAX2/context@${CURSERVER}

[macro-pstnexten];
;
; Standard extension macro:
;   ${ARG1} - Extension  (we could have used ${MACRO_EXTEN} here as well
;   ${ARG2} - Device(s) to ring
;
exten => s,1,Set(GROUPCOUNT=${GROUP_COUNT(pstn@${ARG1})})
exten => s,2,GotoIf($[${GROUPCOUNT} > 1]?104)
exten => s,3,Dial(${ARG2},20,M(setgroup^${ARG1}))					; Ring the interface, 20 seconds maximum
;exten => s,104,Busy

[macro-tapi];
exten => s,1,UserEvent(TAPI|TAPIEVENT: [~${ARG1}&${ARG2}] LINE_CALLSTATE LINECALLSTATE_CONNECTED)
exten => s,2,UserEvent(TAPI|TAPIEVENT: [~${ARG1}&!${ARG2}] LINE_CALLSTATE LINECALLSTATE_HANGUP)


[macro-stdexten];
;
; Standard extension macro:
;   ${ARG1} - Extension  (we could have used ${MACRO_EXTEN} here as well
;   ${ARG2} - Device(s) to ring
;
exten => s,1,UserEvent(TAPI|TAPIEVENT: LINE_NEWCALL ${ARG2})
exten => s,n,UserEvent(TAPI|TAPIEVENT: LINE_CALLSTATE LINECALLSTATE_OFFERING)
exten => s,n,UserEvent(TAPI|TAPIEVENT: SET CALLERID ${CALLERID(num)})
exten => s,n,UserEvent(TAPI|TAPIEVENT: LINE_CALLINFO LINECALLINFOSTATE_CALLERID)

exten => s,n,Dial(${ARG2},20,rtM(tapi^${UNIQUEID}|${ARG2}))
exten => s,n,Goto(s-${DIALSTATUS},1)				; Jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)
;exten => s,104,Goto(s-BUSY,1)

exten => s-NOANSWER,1,Voicemail(u${ARG1})		; If unavailable, send to voicemail w/ unavail announce
exten => s-NOANSWER,2,Goto(default,s,1)			; If they press #, return to start

exten => s-BUSY,1,Voicemail(b${ARG1})			; If busy, send to voicemail w/ busy announce
exten => s-BUSY,2,Goto(default,s,1)				; If they press #, return to start

exten => _s-.,1,Goto(s-NOANSWER,1)				; Treat anything else as no answer

exten => a,1,VoicemailMain(${ARG1})				; If they press *, send the user into VoicemailMain

exten => h,1,UserEvent(TAPI|TAPIEVENT: LINE_CALLSTATE LINECALLSTATE_IDLE)

[macro-fmfmexten];
;
; Standard extension macro:
;   ${ARG1} - Extension  (we could have used ${MACRO_EXTEN} here as well
;   ${ARG2} - Device(s) to ring
;   ${ARG3} - Device(s) to ring after first try to follow you
;
exten => s,1,UserEvent(TAPI|TAPIEVENT: LINE_NEWCALL ${ARG2})
exten => s,n,UserEvent(TAPI|TAPIEVENT: LINE_CALLSTATE LINECALLSTATE_OFFERING)
exten => s,n,UserEvent(TAPI|TAPIEVENT: SET CALLERID ${CALLERID(num)})
exten => s,n,UserEvent(TAPI|TAPIEVENT: LINE_CALLINFO LINECALLINFOSTATE_CALLERID)
exten => s,n,Dial(${ARG2},7,rtM(tapi^${UNIQUEID}|${ARG2}))
exten => s,n,Dial(${ARG2}&${ARG3},15,rtM(tapi^${UNIQUEID}|${ARG2}))
exten => s,n,Goto(s-${DIALSTATUS},1)				; Jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)

exten => s-NOANSWER,1,Voicemail(u${ARG1})		; If unavailable, send to voicemail w/ unavail announce
exten => s-NOANSWER,2,Goto(default,s,1)			; If they press #, return to start

exten => s-BUSY,1,Voicemail(b${ARG1})			; If busy, send to voicemail w/ busy announce
exten => s-BUSY,2,Goto(default,s,1)				; If they press #, return to start

exten => _s-.,1,Goto(s-NOANSWER,1)				; Treat anything else as no answer

exten => a,1,VoicemailMain(${ARG1})				; If they press *, send the user into VoicemailMain

exten => h,1,UserEvent(TAPI|TAPIEVENT: LINE_CALLSTATE LINECALLSTATE_IDLE)

[macro-setgroup]
exten => s,1,Set(GROUP(${ARG1})=pstn)

[macro-superdial]
; add some abilities to Dial(Technology/resource[&Technology2/resource2...][|timeout][|options][|URL]):
;       ${ARG1} - Technology/resource[&Technology2/resource2...] (like SIP/2201)
;       ${ARG2} - timeout in seconds
;       ${ARG3} - Dial command options
;       ${ARG4} - URL (see Dial command for info)
;       ${ARG5} - Group name (used if you want to limit the number of calls in any way)
;       ${ARG6} - Max. group number (maximum number of concurrent calls you want to allow for that group)
;       ${ARG7} - Caller ID name (typically for outgoing calls only)
;       ${ARG8} - Caller ID number (typically for outgoing calls only)
;       ${ARG9} - CDR account name (over-rides account group setting in sip.conf or iax.conf)
;       ${ARG10} - voicemail to send to if noanswer (typically for incoming calls only)
; Usage instructions:
;       for an outgoing call, in extensions.conf you just list multiple lines like:
;               exten => s,1,Macro(superdial,IAX2/voipjet/${tfnumber},,,,voip,${MAXVOIPCALLS},yourname,8005551234,voipjet)
;               exten => s,2,Macro(superdial,IAX2/alpeh-com/${tfnumber},,,,voip,${MAXVOIPCALLS},yourname,8005551234,aleph)
;       and it will take the first one that is available
;
;       it also works for incoming like so ..
;               exten => s,1,Wait(2)
;               exten => s,2,Macro(superdial,${PHONE1},15,Ttm,,pstn,${MAXPSTNCALLS},${CALLERIDNAME},${CALLERIDNUM},pstn,u${GENERALVM})
;               exten => s,3,Macro(superdial,${PHONE1},15,Ttm,,pstn,${MAXPSTNCALLS},${CALLERIDNAME},${CALLERIDNUM},pstn,u${GENERALVM})
;               exten => s,4,Voicemail(b${GENERALVM})
;       and then goes to unavailable voicemail if one times out .. otherwise (eg if busy) it tries the next extension
;       if all are busy or unavailable .. it gets to the last priority which is the busy voicemail
;
exten => s,1,Set(GROUP()=${ARG5})
exten => s,2,Set(GROUPCOUNT=${GROUP_COUNT(${ARG5})})
exten => s,3,GotoIf($[${GROUPCOUNT} > ${ARG6}]?104)
exten => s,4,GotoIf($["${ARG7}" = ""]?macro-superdial,s,6)
exten => s,5,Set(CALLERID(name)=${ARG7})        ; skip this if ARG7 is empty
exten => s,6,GotoIf($["${ARG8}" = ""]?macro-superdial,s,8)
exten => s,7,Set(CALLERID(number)=${ARG8})              ; skip this if ARG8 is empty
exten => s,8,GotoIf($["${ARG9}" = ""]?macro-superdial,s,10)
exten => s,9,SetAccount(${ARG9})        ; skip this if ARG9 is empty
exten => s,10,Dial(${ARG1},${ARG2},${ARG3},${ARG4})
exten => s,11,Goto(s-${DIALSTATUS},1)
exten => s,104,Goto(s-CHANUNAVAIL,1)
exten => s-BUSY,1,Noop
exten => s-NOANSWER,1,GotoIf($["${ARG10}" = ""]?macro-superdial,s-NOANSWER,3)
exten => s-NOANSWER,2,Voicemail(${ARG10})
exten => s-NOANSWER,3,Noop
exten => _s-.,1,Noop

[macro-stdPrivacyexten];
;
; Standard extension macro:
;   ${ARG1} - Extension  (we could have used ${MACRO_EXTEN} here as well
;   ${ARG2} - Device(s) to ring
;   ${ARG3} - Optional DONTCALL context name to jump to (assumes the s,1 extension-priority)
;   ${ARG4} - Optional TORTURE context name to jump to (assumes the s,1 extension-priority)`
;
exten => s,1,Dial(${ARG2},20|p)					; Ring the interface, 20 seconds maximum, call screening option (or use P for databased call screening)
exten => s,2,Goto(s-${DIALSTATUS},1)				; Jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)

exten => s-NOANSWER,1,Voicemail(u${ARG1})		; If unavailable, send to voicemail w/ unavail announce
exten => s-NOANSWER,2,Goto(default,s,1)			; If they press #, return to start

exten => s-BUSY,1,Voicemail(b${ARG1})			; If busy, send to voicemail w/ busy announce
exten => s-BUSY,2,Goto(default,s,1)				; If they press #, return to start

exten => s-DONTCALL,1,Goto(${ARG3},s,1)               ; Callee chose to send this call to a polite "Don't call again" script.

exten => s-TORTURE,1,Goto(${ARG4},s,1)                ; Callee chose to send this call to a telemarketer torture script.

exten => _s-.,1,Goto(s-NOANSWER,1)				; Treat anything else as no answer

exten => a,1,VoicemailMain(${ARG1})				; If they press *, send the user into VoicemailMain

[demo]
;
; We start with what to do when a call first comes in.
;
exten => s,1,Wait,1			; Wait a second, just for fun
exten => s,n,Answer			; Answer the line
exten => s,n,Set(TIMEOUT(digit)=5)	; Set Digit Timeout to 5 seconds
exten => s,n,Set(TIMEOUT(response)=10)	; Set Response Timeout to 10 seconds
exten => s,n(restart),BackGround(demo-congrats)	; Play a congratulatory message
exten => s,n(instruct),BackGround(demo-instruct)	; Play some instructions
exten => s,n,WaitExten		; Wait for an extension to be dialed.

exten => 2,1,BackGround(demo-moreinfo)	; Give some more information.
exten => 2,n,Goto(s,instruct)

exten => 3,1,Set(LANGUAGE()=fr)		; Set language to french
exten => 3,n,Goto(s,restart)			; Start with the congratulations

exten => 1000,1,Goto(default,s,1)
;
; We also create an example user, 1234, who is on the console and has
; voicemail, etc.
;
exten => 1234,1,Playback(transfer,skip)		; "Please hold while..." 
					; (but skip if channel is not up)
exten => 1234,n,Macro(stdexten,1234,${CONSOLE})

exten => 1235,1,Voicemail(u1234)		; Right to voicemail

exten => 1236,1,Dial(Console/dsp)		; Ring forever
exten => 1236,n,Voicemail(u1234)		; Unless busy

;
; # for when they're done with the demo
;
exten => #,1,Playback(demo-thanks)		; "Thanks for trying the demo"
exten => #,n,Hangup			; Hang them up.

;
; A timeout and "invalid extension rule"
;
exten => t,1,Goto(#,1)			; If they take too long, give up
exten => i,1,Playback(invalid)		; "That's not valid, try again"

;
; Create an extension, 500, for dialing the
; Asterisk demo.
;
exten => 500,1,Playback(demo-abouttotry); Let them know what's going on
exten => 500,n,Dial(IAX2/guest@misery.digium.com/s@default)	; Call the Asterisk demo
exten => 500,n,Playback(demo-nogo)	; Couldn't connect to the demo site
exten => 500,n,Goto(s,6)		; Return to the start over message.

;
; Create an extension, 600, for evaulating echo latency.
;
exten => 600,1,Playback(demo-echotest)	; Let them know what's going on
exten => 600,n,Echo			; Do the echo test
exten => 600,n,Playback(demo-echodone)	; Let them know it's over
exten => 600,n,Goto(s,6)		; Start over

;
; Give voicemail at extension 8500
;
exten => 8500,1,VoicemailMain
exten => 8500,n,Goto(s,6)
;
; Here's what a phone entry would look like (IXJ for example)
;
;exten => 1265,1,Dial(Phone/phone0,15)
;exten => 1265,n,Goto(s,5)

;[mainmenu]
;
; Example "main menu" context with submenu
;
;exten => s,1,Answer
;exten => s,n,Background(thanks)		; "Thanks for calling press 1 for sales, 2 for support, ..."
;exten => s,n,WaitExten
;exten => 1,1,Goto(submenu,s,1)
;exten => 2,1,Hangup
;include => default
;
;[submenu]
;exten => s,1,Ringing					; Make them comfortable with 2 seconds of ringback
;exten => s,n,Wait,2
;exten => s,n,Background(submenuopts)	; "Thanks for calling the sales department.  Press 1 for steve, 2 for..."
;exten => s,n,WaitExten
;exten => 1,1,Goto(default,steve,1)
;exten => 2,1,Goto(default,mark,2)

[keysystem]
include => day|08:00-17:00|mon-fri|*|*
include => night


[day]
exten => s,1,Answer() ; Answer the line
exten => s,n,UserEvent(TAPI|TAPIEVENT: LINE_NEWCALL SIP/100&SIP/102&SIP/106&SIP/109&SIP/110&SIP/111)
exten => s,n,UserEvent(TAPI|TAPIEVENT: LINE_CALLSTATE LINECALLSTATE_OFFERING)
exten => s,n,UserEvent(TAPI|TAPIEVENT: SET CALLERID ${CALLERID(num)})
exten => s,n,UserEvent(TAPI|TAPIEVENT: LINE_CALLINFO LINECALLINFOSTATE_CALLERID)
exten => s,n,Dial(SIP/100&SIP/102&SIP/106&SIP/109&SIP/110&SIP/111,10,rtd) ; Ring the Phones
exten => s,n,Dial(SIP/100&SIP/101&SIP/102&SIP/103&SIP/104&SIP/105&SIP/106&SIP/109&SIP/110&SIP/111,15,rtd) ; Ring the Phones
exten => s,n,Voicemail(u6245)

;exten => 479242xxxx,1,Goto(s,1)
exten => 479242xxxx,1,Dial(SIP/105,20,rtd)
exten => 479478xxxx,1,Goto(s,1)
exten => 479646xxxx,1,Goto(fireball,s,1)

;exten => 9,1,DISA(726|default)
exten => *,1,Background(vm-enter-num-to-call)
exten => *,2,WaitExten()
exten => #,1,VoicemailMain(6245)

exten => h,1,UserEvent(TAPI|TAPIEVENT: LINE_CALLSTATE LINECALLSTATE_IDLE)

include => kirkham
include => fax

[night]
exten => s,1,Answer() ; Answer the line
exten => s,n,UserEvent(TAPI|TAPIEVENT: LINE_NEWCALL SIP/100&SIP/102&SIP/106&SIP/107&SIP/109&SIP/110&SIP/111)
exten => s,n,UserEvent(TAPI|TAPIEVENT: LINE_CALLSTATE LINECALLSTATE_OFFERING)
exten => s,n,UserEvent(TAPI|TAPIEVENT: SET CALLERID ${CALLERID(num)})
exten => s,n,UserEvent(TAPI|TAPIEVENT: LINE_CALLINFO LINECALLINFOSTATE_CALLERID)
exten => s,n,Set(CALLERID(num)=${CALLERIDNUM})
exten => s,n,Set(CALLERID(name)=${CALLERIDNAME})
exten => s,n,Dial(SIP/100&SIP/101&SIP/102&SIP/103&SIP/104&SIP/105&SIP/106&SIP/109&SIP/110&SIP/111${KIRKHAMIAXTRUNK}/14796520242,15,rtd) ; Ring the Phones
exten => s,n,Voicemail(u6245)

;exten => 479242xxxx,1,Goto(s,1)
exten => 479242xxxx,1,Dial(SIP/105,20,rtd)
exten => 479478xxxx,1,Goto(s,1)
exten => 479646xxxx,1,Goto(fireball,s,1)

;exten => 9,1,DISA(726|default)
exten => *,1,Playback(vm-enter-num-to-call)
exten => *,2,WaitExten()
exten => #,1,VoicemailMain(6245)

exten => h,1,UserEvent(TAPI|TAPIEVENT: LINE_CALLSTATE LINECALLSTATE_IDLE)

include => kirkham
include => fax


[fireball]
;exten => s,1,Answer() ; Answer the line
exten => s,1,Dial(SIP/300&SIP/301&SIP/302,25,rt) ; Ring the Phones
exten => s,n,Voicemail(u102)

exten => 479439xxxx,1,Goto(s,1)
exten => 479646xxxx,1,Goto(s,1)

include => kirkham


[macro-vm]
exten => s,1,Noop(${CALLERIDNUM})
exten => s,2,Noop(${ARG1})
exten => s,3,GotoIf($[${CALLERIDNUM} = ${ARG1}]?s-MSG|1) 
exten => s,4,Noop(${CALLERIDNUM:1:2})
exten => s,5,Noop(${ARG1:2:3})
exten => s,6,GotoIf($[${CALLERIDNUM:1:2} = ${ARG1:2:3}]?s-MSG2|1) 
exten => s-MSG,1,VoicemailMain(s${CALLERIDNUM}) 
exten => s-MSG2,1,VoicemailMain(s1${CALLERIDNUM:1:2}) 

[macro-vmexten]
exten => s,1,Noop(${ARG1})
exten => s,2,VoiceMail(u${ARG1})
exten => a,1,VoiceMailMain(${ARG1})

[macro-page]
; Paging macro:
; Check to see if SIP device is in use and DO NOT PAGE if they are
; ${ARG1} - Device to page
;
exten => s,1,ChanIsAvail(SIP/1${ARG1:1:3}|js) ; j is for dump and s is for ANY call
exten => s,2,Dial(SIP/4${ARG1:1:3}||)
exten => s,3,Hangup
exten => s,102,Hangup 

[macro-hunt-dial]
; ${ARG1} channel
; ${ARG2} Dialed Number

exten => s,1,SetGroup(${ARG1}) ; increment GROUPCOUNT
exten => s,2,GetGroupCount()
exten => s,3,NoOp(GROUPCOUNT:${GROUPCOUNT})
exten => s,4,GotoIf($["${GROUPCOUNT}" = "1"]?5:6) ; if GROUPCOUNT = 1, then it's free for dialing.
exten => s,5,Dial(SIP/${ARG2}@${ARG1}) ; use it to call out.
exten => s,6,NoOp(${ARG1} is inused)

[page]
exten => _X.,1,Macro(page,${EXTEN})

[kirkham]
exten => _21XX,1,Macro(vmexten,${EXTEN:1:4})
exten => _21XX,2,Hangup()
exten => _1XX,1,Macro(vm, ${EXTEN})
exten => _1XX,2,Macro(stdexten,${EXTEN},SIP/${EXTEN})
exten => _1XX,3,Hangup()
exten => _3XX,1,Macro(stdexten,${EXTEN},SIP/${EXTEN})
exten => _3XX,2,Hangup()
exten => 499,1,Page(LOCAL/100@page&LOCAL/101@page&LOCAL/102@page&LOCAL/104@page&LOCAL/105@page&LOCAL/106@page&LOCAL/110@page&LOCAL/111@page)
exten => 499,2,Hangup()
exten => _4XX,1,Macro(stdexten,${EXTEN},SIP/${EXTEN})
exten => _4XX,2,Hangup()

exten => _91NXXNXXXXXX,1,GotoIf($["${TRUNK}" = "Zap/G1"]?2:3)
exten => _91NXXNXXXXXX,2,Set(TRUNK=Zap/g2)
exten => _91NXXNXXXXXX,3,Goto(longdistance,${EXTEN},1)
exten => _9NXXNXXXXXX,1,GotoIf($["${TRUNK}" = "Zap/G1"]?2:3)
exten => _9NXXNXXXXXX,2,Set(TRUNK=Zap/g2)
exten => _9NXXNXXXXXX,3,Goto(local,${EXTEN},1)
exten => _9NXXXXXX,1,GotoIf($["${TRUNK}" = "Zap/G1"]?2:3)
exten => _9NXXXXXX,2,Set(TRUNK=Zap/g2)
exten => _9NXXXXXX,3,Goto(local,${EXTEN},1)


;dial out from 479-439-xxxx fayetteville, ar
exten => _621NXXNXXXXXX,1,Set(CALLERID(num)=479646xxxx)
exten => _621NXXNXXXXXX,2,Set(CALLERID(name)="KIRKHAM SYSTEMS")
exten => _621NXXNXXXXXX,3,Dial(IAX2/kirkhamsystems@teliax/${EXTEN:2},30,rt)

;dial out from sip provider 479-242-xxxx
exten => _63NXXXXXX,1,Set(CALLERID(num)=479242xxxx
exten => _63NXXXXXX,2,Set(CALLERID(name)="Kirkham Systems")
exten => _63NXXXXXX,3,Dial(newroadstrunk/${EXTEN:2},30,rt)

;dial out from 479-646-xxxx
exten => _64NXXXXXX,1,Dial(Zap/4/${EXTEN:2},30,rt)

exten => 6245,1,VoicemailMain(6245)

exten => 600,1,Playback(demo-echotest)	; Let them know what's going on
exten => 600,n,Echo			; Do the echo test
exten => 600,n,Playback(demo-echodone)	; Let them know it's over
exten => 600,n,Goto(s,6)		; Start over

exten => 601,1,ZapScan()

;exten => 602,1,Dial(IAX2/kirkhamsystems@teliax/14796521042, 30, rt)

;exten => 603,1,Set(CALLERID(num)="<479646xxxx>")
;exten => 603,2,Set(CALLERID(name)="KIRKHAM SYSTEMS")
;exten => 603,3,Dial(${KIRKHAMIAXTRUNK}/14796521042, 30, rt)

exten => 604,1,Answer()
exten => 604,2,MusicOnHold()
exten => 605,1,VoiceMail(u6245)
exten => 800,1,Meetme(800)


[kirkham-blf]
exten => 100,hint,SIP/100 ;tom
exten => 101,hint,SIP/101 ;brandan
exten => 102,hint,SIP/102 ;shayne
exten => 103,hint,SIP/103 ;Conference room
exten => 104,hint,SIP/104 ;Jake
exten => 105,hint,SIP/105 ;Granville
exten => 106,hint,SIP/106 ;Criag
exten => 107,hint,SIP/107 ;Wireless sip phone
exten => 108,hint,SIP/108 ;Joseph
exten => 109,hint,SIP/109 ;Front Counter
exten => 110,hint,SIP/110 ;Ashley
exten => 111,hint,SIP/111 ;Donovan

[from-fax]
;exten => _9.,1,Dial(SIP/${EXTEN:1}@newroads)

include => longdistance
include => local

[from-tapi]
;exten => _X.,1,GotoIf($[${LEN(${EXTEN})} >= 7]?kirkham,9${EXTEN},1:kirkham,${EXTEN},1)
exten => _X.,1,Goto(default,${EXTEN},1)

[fax]

exten => fax,1,Dial(Zap/1-1)

[default]
;
; By default we include the demo.  In a production system, you 
; probably don't want to have the demo there.
;
;include => keysystem
include => longdistance
include => local
include => kirkham
include => kirkham-blf

exten => 479646xxxx,1,Goto(fireball,s,1)
exten => 479478xxxx,1,Goto(keysystem,s,1)
exten => metaswitch,1,Goto(keysystem,s,1)
;exten => 479242xxxx,1,Goto(keysystem,s,1)

exten => h,1,UserEvent(TAPI|TAPIEVENT: LINE_CALLSTATE LINECALLSTATE_IDLE)




-----------------------------------------------------------------------------
sip.conf settings 
-----------------------------------------------------------------------------
[general]
realm=snom
port = 5060
bindaddr = 0.0.0.0
context = default
nat = yes
externip = 72.18.39.109
localnet = 192.168.1.0/255.255.255.0
disallow=all
allow=ulaw
allow=alaw
allow=gsm
subscribecontext=kirkham-blf
register => 4792422484@voip.myprovider.com

;ip based authentication, no need for username or secret
[myprovidertrunk]
type=peer
nat=yes
host=voip.mynewroads.com
dtmfmode=inband
insecure=very
context=keysystem


[105]
type=friend
context=default
username=105
callerid="Granville Raper"<105>
host=dynamic
nat=no
canreinvite=yes
port=5060
dtmfmode=rfc2833
callgroup=1
pickupgroup=1
mailbox=105