[sip] exten => 1001,1,ringing exten => 1001,2,wait(2) exten => 1001,3,Answer exten => 1001,4,Echo exten => 1002,1,SetCallerID(${CALLERID}) exten => 1002,2,Macro(exten,SIP/andy,${EXTEN},${CALLERIDNUM}) ; call the macro passing params - generic macro for all extens. exten => 1003,1,SetCallerID(${CALLERID}) exten => 1003,2,Macro(exten,IAX2/1003,${EXTEN},${CALLERIDNUM}) ; call the macro passing params - generic macro for all extens. ; this checks to see if anyone called then calls them first ; when they pick up me back - you might want to check that it's ; a valid internal exten - otherwise the call to a zap chan would ; be at your cost. exten => h,1,Set(CB=0) ; Set default value for CB (CB =1 callback active) exten => h,2,DBGet(CB=CALLBACK/${CALLERIDNUM}) ; Get CB exten => h,3,DBGet(CB2=CALLBACK2/${CALLERIDNUM}) ; Get Who called exten => h,4,NOOP(${CB}) ; Display CB (not really required) exten => h,5,GotoIf($["${CB}" = "1"]?6:99) ; Check if CB=1 if it does to the callback stuff at 6 else jump to 99 exten => h,6,NOOP ;Wait(2) exten => h,7,DBPut(CALLBACK/${CALLERIDNUM}=0) ; set CB to 0 cos we don;t want a loop. exten => h,8,System(echo "Channel: Local/${CB2}@sip" >/var/spool/asterisk/outgoing/${UNIQUEID}.callback) ; fill the exten => h,9,System(echo "Context: sip" >>/var/spool/asterisk/outgoing/${UNIQUEID}.callback) ; call file exten => h,10,System(echo "Extension: ${CALLERIDNUM}" >>/var/spool/asterisk/outgoing/${UNIQUEID}.callback) ;with data exten => h,11,System(echo "CallerID: ${CB2}" >>/var/spool/asterisk/outgoing/${UNIQUEID}.callback) exten => h,99,NoOp [macro-exten] exten => s,1,Dial(${ARG1}) exten => s,2,Goto(s,102) ; you might want to play with timeouts, and perhaps use waitexten... exten => s,102,Set(CB=0) ; Set default value for CB (CB =1 callback active) exten => s,103,DBGet(CB=CALLBACK/${CALLERIDNUM}) ; Get CB exten => s,104,GotoIf($["${CB}" = "1"]?99:105) ; Check if CB=1 if it does tell them they can't else jump to 99 exten => s,105,ResponseTimeout(3) exten => s,106,Set(SCB=${ARG2},SCB2=${ARG3}) ;we need to set these because you might exit the macro and we need the values. exten => s,107,Background(vm-tocallback,,,callback-activate) ; play sound jump to callback-activate if key pressed exten => s,99,Playback(you-cant-do-this-there-is-a-callback-already) exten => s,100,Hangup ; Catch dross exten => i,1,goto(h,1) exten => t,1,goto(h,1) exten => h,1,NoOP [callback-activate] exten => 1,1,DBPut(CALLBACK/${SCB}=1) ; put 1 into this exten callback to indicate active exten => 1,2,DBPut(CALLBACK2/${SCB}=${SCB2}) ; put who is was that called exten => 1,3,Playback(conf-muted) ; play some sound to tell the user callback is active exten => 1,4,Hangup ; this checks to see if anyone called then calls them first ; when they pick up me back - you might want to check that it's ; a valid internal exten - otherwise the call to a zap chan would ; be at your cost. ; we repeat it here just in case we were calling someone too... exten => h,1,Set(CB=0) ; Set default value for CB (CB =1 callback active) exten => h,2,DBGet(CB=CALLBACK/${CALLERIDNUM}) ; Get CB exten => h,3,DBGet(CB2=CALLBACK2/${CALLERIDNUM}) ; Get Who called exten => h,4,NOOP(${CB}) ; Display CB (not really required) exten => h,5,GotoIf($["${CB}" = "1"]?6:99) ; Check if CB=1 if it does to the callback stuff at 6 else jump to 99 exten => h,6,NOOP ;Wait(2) exten => h,7,DBPut(CALLBACK/${CALLERIDNUM}=0) ; set CB to 0 cos we don;t want a loop. exten => h,8,System(echo "Channel: Local/${CB2}@sip" >/var/spool/asterisk/outgoing/${UNIQUEID}.callback) ; fill the exten => h,9,System(echo "Context: sip" >>/var/spool/asterisk/outgoing/${UNIQUEID}.callback) ; call file exten => h,10,System(echo "Extension: ${CALLERIDNUM}" >>/var/spool/asterisk/outgoing/${UNIQUEID}.callback) ;with data exten => h,11,System(echo "CallerID: ${CB2}" >>/var/spool/asterisk/outgoing/${UNIQUEID}.callback) exten => h,99,NoOp