macro std-exten( ext, dev ) { Dial(${dev}/${ext},20,t); // the t option allows parking switch(${DIALSTATUS}) { case BUSY: Voicemail(b${ext}); break; default: voicemail(u${ext}); }; catch a { VoiceMailMain(${ext}); return; }; }; context default { includes { staff-external; } }; context staff { includes { staff-external; internal; } }; context staff-external { _1XX => &std-exten(${EXTEN},"SIP"); // This used to be a lot bigger, mapping extensions to specific devices and // doing some logic to check if the line was active. Asterisk is better about // handling this now, it shouldn't be needed anymore. // This was used to make the dialplan cleaner looking even though it adds // unnecessary jumps. AEL doesn't easily allow for the method we used // (jumping to a step number), so everywhere you would have a staff-HQ jump, // put this instead (and it will call directly) // // &std-exten-(${EXTEN},"SIP"); // // where ${EXTEN} is the extension number. Note the lack of space after // the comma, it is important there be no white space there for some reason. }; context internal { includes { intra-company; staff; parkedcalls; queues-loginout; queues-manip; } _341X => goto conference|${EXTEN}|1; // join a conference room // Voicemail 8500 => { Set(TIMEOUT(absolute)=600); if ( "${CALLERID(num)}" != "" ) { goto havebox; } else { VoicemailMain(); // prompts for mailbox Hangup(); } havebox: Wait(1); VoicemailMain(${CALLERID(num)}); // got mailbox from CID Hangup(); } 8501 => { VoicemailMain(); // prompts for mailbox Hangup(); } // Play hold music from any phone 8888 => { Answer(); Dial(Local/moh@internal/n); } moh => MusicOnHold(); context queues-loginout { s => Set(queue-announce-success=0); // the extensions to dial to log in and out of the support queue. // hands off to the queues-manip context, which does the actual work. 8001 => { // This uses the caller id to set the agent number // for the speed dial buttons on cisco phones Answer(); Set(AGENT_NUMBER=${CALLERID(num)}); Set(AGENT_EXT=${CALLERID(num)}); Set(queue-announce-success=1); goto queues-manip,I${AGENT_NUMBER},1; } 8002 => { // logs in, prompts for an agent number Answer(); Read(AGENT_NUMBER,agent-user); Read(AGENT_EXT,agent-newlocation); Set(queue-announce-success=1); goto queues-manip,I${AGENT_NUMBER},1; } 8003 => { // Logs out using caller id as agent number // for speed dial on cisco phones Answer(); Set(AGENT_NUMBER=${CALLERID(num)}); Set(AGENT_EXT=${CALLERID(num)}); Set(queue-announce-success=1); goto queues-manip,O${AGENT_NUMBER},1; } 8004 => { // Logs out prompting for agent number Answer(); Read(AGENT_NUMBER,agent-user); Set(queue-announce-success=1); goto queues-manip,O${AGENT_NUMBER},1; } }; context queues-manip { // determines which agent is doing what. _[IO]100 => { &queue-addremove(supportq,10); &queue-success(); } _[IO]102 => { &queue-addremove(supportq,10); &queue-success(); } _[IO]103 => { &queue-addremove(supportq,10); &queue-success(); } _[IO]104 => { &queue-addremove(supportq,10); &queue-success(); } _[IO]105 => { &queue-addremove(supportq,10); &queue-success(); } _[IO]106 => { &queue-addremove(supportq,10); &queue-success(); } }; macro queue-success() { if(${queue-announce-success} > 0) { switch(${MACRO_EXTEN:0:1}) { case I: Playback(agent-loginok); Playback(vm-goodbye); Hangup(); case O: Playback(agent-loggedoff); Playback(vm-goodbye); Hangup(); } } }; macro queue-addremove(queuename,penalty) { switch(${MACRO_EXTEN:0:1}) { case I: { // AddQueueMember(${queuename},Local/${MACRO_EXTEN:1}@staff,${penalty}); AddQueueMember(${queuename},Local/${AGENT_EXT}@staff,${penalty}); break; } case O: { // RemoveQueueMember(${queuename},Local/${MACRO_EXTEN:1}@staff); RemoveQueueMember(${queuename},Local/${AGENT_EXT}@staff,${penalty}); break; } default: { Playback(invalid); break; } } }; // Outbound contexts, I think this is what queue callers get put in context salesqout { 1 => { Voicemail(190); Hangup(); } # => { Playback(vm-goodbye); Wait(1); Hangup(); } }; context supportqout { 1 => { Voicemail(191); Hangup(); } # => { Playback(vm-goodbye); Wait(1); Hangup(); } * => goto support|s|1; }; macro gotosupportq() { // sends callers to the support queue // macroized since it is called from several places Set(CALLERID(name)=Support Queue); // set CID to support queue Playback(NetPBX/press-1-leave-voicemail); Queue(supportq|t|||2700|); // timeout 45 minutes Voicemail(191); // send to voicemail after timeout Hangup(); }; context support { 0 => &gotosupportq(); 2 => goto server-settings|s|1; 3 => &gotosupportq(); * => goto mainmenu|s|1; # => goto s|repeat; s => { Answer(); Background(silence/1); repeat: Background(NetPBX/3rd-menu); Background(previous-menu-press-star); Background(menu-again-press-pound); WaitExten(5); } t => &gotosupportq(); i => { Playback(NetPBX/invalid-extension); Wait(2); goto s|repeat; } };