Contexts in spracket
--------------------
	from-sip		in sip.conf[general]

	from-internal		in sip.conf[01 .. 06]

	from-pstn		in sip.conf[mt-1204]

	from-peer		in sip.conf[iptel, mci]

	from-teetot		in iax.conf[teetot]

	from-iax		in iax.conf[hardline]

	from-iaxtel		in iax.conf[iaxtel]
	

Contexts in loligo
------------------
	inbound-analog		from zapata.conf

	from-sip		from sip.conf[general]

	coloco			from sip.conf[coloco]

	intern			from sip.conf[2203 .. 2207]
				from iax.conf[sjc1, hmb1, bwi1, bwi2]
		calls intern-post

	intern-post
		includes operator
		includes e911
		includes forced analog
		includes inoc-dba-out
		includes fwd-out
		includes iconnect-forced
		includes coloco-forced
		includes information
		includes iptel-forced
		includes iax-outbound
		includes local
		includes pstn-local
		includes pstn-local-toll
		includes pstn-free
		includes coloco-local
		includes iaxtel

	operator
		just calls 70 on the analog line

	e911
		

	from-iaxtel		from iax.conf[guest, iaxtel]

	NANPA			from iax.conf[nufone]

	

Contexts in drunkcoder
----------------------

	default			from zapata.conf[general]
		send people directly into voicemail

	local			in extensions.conf
		includes default


Contexts in fnord
-----------------
	INVALID			from sip.conf[general], iax.conf[general]

	incoming		from iax.conf[nufone]
				from zapata.conf[X100P plugged into PSTN]

	local-access		from sip.conf[21]
		includes extensions
		includes local-trunks

	toll-access		from zapata.conf[TDM200B Ports to phone/fax]
		includes local-access
		includes toll-trunks

	extensions		in extensions.conf
		echo, milliwatt, record, playback, date, time,
		voicemaik, zap-phones with voicemail

	incoming		in extensions.conf
		starts with a voice-menu
		includes extensions

	toll-trunks		in extensions.conf

	local-trunks		in extensions.conf




Contexts in sbuehl
------------------
	sip-in			from sip.conf[sipgate-1,sipgate-2,freenet-muc]
		calls isdn phones

	sip-out			in extensions.conf
		calls sipgate and freenet accounts, allows IP dialling with
		prefix 9

	misdn			from misdn.conf[general]

	out			from misdn.conf[intern]
		bogus?


Contexts in capi4linux
----------------------

	out			from zapata.conf, sip.conf[2112]
				in accesslevels.inc
		calls acl with CALLERIDNUM

	acl			in extensions.conf
		calls out-international, out-national, out-local

	out-international	in accesslevels.inc
		includes out-national
		includes trunk-international

	out-national		in accesslevels.inc
		includes out-local
		includes trunk-deny-call-by-call
		includes trunk-deny-service-innovative
		includes trunk-deny-service-0137
		includes trunk-deny-wirelessmultiplex
		includes trunk-deny-service-0180
		includes trunk-deny-ivpn
		includes trunk-deny-usergroups
		includes trunk-deny-service-0900
		includes trunk-deny-service-09009
		includes trunk-deny-service-019Z
		includes trunk-deny-unregulated
		includes trunk-national

	out-local		in accesslevels.inc
		includes out-intern
		includes trunk-deny-infoprovider
		includes trunk-sip
		includes trunk-local

	out-intern		in accesslevels.inc
		includes emergency
		includes parkedcalls
		includes sservices
		includes extensions-zap
		includes extensions-sip
		includes trunk-tollfree

	parkedcalls		in parking.conf

	pstn			from capi.conf
		from incoming ISDN calls based on MSN to to extension-zap,
			sservices etc

	psin			from sip.conf[general,sipgate,fwd]
		routes incoming sipgate/fwd calls to extensions

	sservices		in sservices.inc
		voicemail, zapbarge, meetme, echo etc

	trunk-deny-*		in denylist.inc
		deny various things, e.g. tollnumber, toll services ...

	trunk-international	in trunks.inc
	trunk-national
	trunk-local
	trunk-tollfree
	trunk-sip
		calls various numbers

	emergency		in emergency.inc
		calls 110,112,911 via capi

	extensions-zip		in extensions.conf
		calls local SIP phones

	extensions-zap		in extensions.conf
		calls local ZAP phones


	


Service numbers
---------------
	*0	Send hook flash
	*67	Disabling Caller*ID
	*69	say last callerid
	*70	Disable call waiting
	*72	enable CFIM
	*73	disable CFIM
	*78	enable DND
	*79	disable DND
	*80	add callerid to black list
	*82	enable Caller*ID
	? 700	Parking call
	? *8	call pickup



Call-macro
----------
	1. test for CFIM (Call Forwarding Immediate)
		-> Call other extension
	2. test for DND  (do not disturb)
		2.1. Test for Voicemail
			-> Voice Mail unavailable
		2.2. Busy
	3. Dial for N seconds
		3.1. Test for CFBS (Call forwarding if busy)
			-> Call other extension
		3.2. Test for Voicemail
			-> Voicemail if busy




Call Forwarding:
----------------
21*<number> for immediate redirect		CFIM
*61*<number> for delayed (busy) redirect	CFBS
#21# or #61# to cancel the setting

	[macro-stdexten] 
	; 
	; Standard extension macro (with call forwarding): 
	; ${ARG1} - Device(s) to ring 
	; 
	exten=s,1,DBget(temp=CFIM/${MACRO_EXTEN}) ; Get CFIM key, if not existing, goto 102 
	exten=s,2,Dial(Local/${temp}@pbx/n)   ; Unconditional forward 
	exten=s,3,Dial(${ARG1},20) ; 20sec timeout 
	exten=s,4,DBget(temp=CFBS/${MACRO_EXTEN})  ; Get CFBS key, if not existing, goto 105 
	exten=s,5,Dial(Local/${temp}@pbx/n) ; Forward on busy or unavailable 
 
	; No CFIM key 
	exten=s,102,Goto(s,3) 
 
	; No CFBS key - voicemail ? 
	exten=s,105,Busy 


	[apps] 
	; Unconditional Call Forward 
	exten => _*21*X.,1,DBput(CFIM/${CALLERIDNUM}=${EXTEN:4}) 
	exten => _*21*X.,2,Hangup 
	exten => #21#,1,DBdel(CFIM/${CALLERIDNUM}) 
	exten => #21#,2,Hangup 
 
	; Call Forward on Busy or Unavailable 
	exten => _*61*X.,1,DBput(CFBS/${CALLERIDNUM}=${EXTEN:4}) 
	exten => _*61*X.,2,Hangup 
	exten => #61#,1,DBdel(CFBS/${CALLERIDNUM}) 
	exten => #61#,2,Hangup 
 

	; confirm with an audio prompt
	[pbx] 
	exten=7000,1,Macro(stdexten,7000,MGCP/aaln/1@<myphone>)   ; IP10S 
	exten=7001,1,Macro(stdexten,7001,SIP/oej)   ; SIP connection 



SIP problems
------------
	modprobe ipt_REDIRECT
	iptables -t nat -A PREROUTING -p udp \
		-i eth0 --dport 0 -j REDIRECT --to-port 5060


German sounds
-------------
	http://www.stadt-pforzheim.de/asterisk/vprompts.html
	http://www.karl.aegee.org/asterisk.nsf/HT/sound-de


Better answer
-------------
Instead of


	Answer
	Wait(2)

use something like

	Answer
	Background/Playback




110/112:
--------

Tested:
	exten => 911,1,ChanIsAvail(Zap/1) 
	exten => 911,2,Dial(${AVAILCHAN}/911) 
	exten => 911,3,Hangup() 
	exten => 911,102,SoftHangup(Zap/1-1) 
	exten => 911,103,Wait(1) 
	exten => 911,104,Goto(1)

Untested:
	exten => 911,1,ChanIsAvail(Zap/1) 
	exten => 911,2,Setvar(emergInProgress=1) 
	exten => 911,3,Dial(${AVAILCHAN}/911) 
	exten => 911,4,Setvar(emergInProgress=0) 
	exten => 911,5,Hangup() 
	exten => 911,102,GotoIf($[${emergInProgress} = 1]?999) 
	exten => 911,103,SoftHangup(Zap/1-1) 
	exten => 911,104,Wait(1) 
	exten => 911,105,Goto(1) 
	exten => 911,999,Congestion()




Quick redial:
-------------
Step 1: Separate the dialling context for phones/users

	[pbx] 
	include = apps 
	include = dialpbx 
 
	[dialpbx] 
	exten = _X.,1,Macro(dial) 
 
	[router] 
	include = local 
	include = apps 
	include = outbound 
 
	exten = t,1,Busy 

Step 2: Route all dialling (except for applications/vertical service codes) through a Macro:

	[macro-dial] 
	exten = s,1,DBput(RepeatDial/${CALLERIDNUM}=${MACRO_EXTEN}) 
	exten = s,2,Dial(Local/${MACRO_EXTEN}@router) 
	exten = s,3,Busy


Step 3: Adding the redial shortcode:

	[apps] 
	; Repeat last dialled number 
	exten = *5,1,DBget(temp=RepeatDial/${CALLERIDNUM}) 
	exten = *5,2,Dial(Local/${temp}@router) ; Last known 
 
	; No RepeatDial key 
	exten = *5,102,Congestion



Auto-Attendant:
---------------
Login with *801, log out with *802 
	exten => *801,1,DBPut(auto/attendant=1) 
	 exten => *802,1,DBPut(auto/attendant=0) 
  
	;Incoming calls- check if autoattendant is logged in, otherwise goto "auto" 
	exten => s,1,DBGet(autoattendant=auto/attendant) 
	exten => s,2,GotoIf($${autoattendant} = "1"?auto|1) 
	exten => s,3,Dial(Zap/23,30,t) 
	exten => s,4,Goto(auto|1)




Record files:
-------------
	; Record voice file to /tmp directory 
	exten => 205,1,Wait(2) ; Call 205 to Record new Sound Files 
	exten => 205,2,Record(/tmp/asterisk-recording:gsm) 
	exten => 205,3,Wait(2) 
	exten => 205,4,Playback(/tmp/asterisk-recording) 
	exten => 205,5,wait(2) 
	exten => 205,6,Hangup 



WAV to GSM:
-----------
	sox foo.wav -r 8000 foo.gsm resample -ql



Debugging with NoOp:
--------------------
	exten => s,1,Answer 
	exten => s,2,NoOp,Debug text: ${CALLERID}



Reverse hold
------------
	Like most people, I'm very busy, so when I call other companies,
	sitting on hold really sucks. If you have speaker phone, its not so
	bad, but then you have to sit there and listen to the company's
	horrible choice in music.

	The solution: Reverse Hold.

	When your on hold, blind transfer the call to the special extension. 
	This extension repeats "Press 1 to be connected to the caller, do
	not hangup" constantly. Once the remote party presses 1, the
	original extension is dialed back. No more listening to hold music,
	or having a phone stuck to your ear forever! ;)

	It confuses people at first, but for the most part it works great.

	This will definitely need some tweaking to fit in to your own setup.

	Extensions.conf
	------------------------
	;This is used in case you manually set the callerid 
	;in your extensions.conf, ie: Nufone
	;It saves the originating EXT for use later on.
	;I tried getting the src channel, and just dialing it back,
	;but it didn't work out so well.
	[macro-set-callerid]
	exten => s,1,setGlobalVar(SRC_EXT=${CALLERIDNUM})
	exten => s,2,SetCallerID(${ARG1})
	exten => s,3,SetCIDName(${ARG2})

	[reverse-hold]
	exten => s,1,GotoIf($["${SRC_EXT}" = ""]?99:2)
	exten => s,2,NoOp(Reverse Hold from: ${SRC_EXT})
	exten => s,3,AbsoluteTimeout,600  ;10 mins, then force a callback to the
	originating ext as a reminder the call is still on hold

	exten => s,4,Wait,2
	exten => s,5,Background(reverse-hold-repeat)
	exten => s,6,Goto(s,4)                                  ;Loop

	exten => s,99,Macro(set-callerid,5555555555,Foo Company) ;If SRC_EXT
	isn't set already, this will set it

	exten => i,1,Goto(s,4) ; Keep repeating if they don't press 1
	exten => t,1,Goto(s,4)

	exten => 1,1,NoOp(Reverse Hold party dialed 1, calling back: ${SRC_EXT})
	exten => 1,2,Goto(reverse-hold,999,1)

	exten => T,1,NoOp(Reverse Hold timeout, calling back: ${SRC_EXT})
	exten => T,2,Goto(reverse-hold,999,1)

	exten => 999,1,SetCallerID(${EXTEN})
	exten => 999,2,SetCIDName(Reverse-Hold)
	exten => 999,3,AbsoluteTimeout,0
	exten => 999,4,Goto(extensions,${SRC_EXT},1)
	exten => 999,5,Goto(s,4)

	exten => 899,1,Goto(reverse-hold,s,1)


	Ideally something like this would become its own application, or
	tied in to something like parkedcalls. But for now, the above works
	relatively well. The biggest drawback is there is no way to get back
	to call on hold until it times out.
