From-internal pass to extension while server-side DND enabled

Running PIAF 2.0.6.4; asterisk 1.8, freepbx2.10.

Is there a way I can build out a dialplan in the from-internal context in /etc/asterisk/extensions_custom.conf to allow internal users to call an extension that has server-side dnd enabled using the feature code (*76), but still block from-trunk?

To elaborate, if the users want to block all calls, they’ll enable it on the phone. If they want to block all outside calls, but still allow their co-workers to call them, then they’ll enable dnd with the feature code.

I wrote something like this sometime back…might help you:

Very clever and very simple. I have been looking for something like this for a while. For later versions of Asterisk (11?) a hangup handler would work better for resetting the DND status back.

This could even be turned into a FreePBX module that provides GUI destinations for each extension that ignores DND.

Sanjay, I’ve used your blog numerous times. Great stuff. This is exactly what I need, thanks so much!

I like the idea of a fpbx module, that would be useful tool, I could see extra functionality with something like that. Somewhat similar to the extension-routes module.

I haven’t looked at the code but I think it would be as easy as adding some sort of source context check. Maybe have entry’s in asterisk
Act as it does today

/DND/2000 : YES

As it does today and block internals too

/DND/ALL/2000 : YES

Would probably need to factor in/decide if external includes transfers

Could be a good feature request in http://issues.freepbx.org or patch/PR to https://github.com/FreePBX/donotdisturb

Hey jfin, I don’t have any experience with this (a source context check), could you give me some pointers?

Doesn’t seem to be getting beyond the first line, any idea what I did wrong?

[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [122@from-internal:1] NoOp(“SIP/121-00000019”, “This context overrides DND”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [122@from-internal:2] Macro(“SIP/121-00000019”, “exten-vm,122,122,0,0,0”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-exten-vm:1] Macro(“SIP/121-00000019”, “user-callerid,”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-user-callerid:1] Set(“SIP/121-00000019”, “AMPUSER=121”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-user-callerid:2] GotoIf(“SIP/121-00000019”, “0?report”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-user-callerid:3] ExecIf(“SIP/121-00000019”, “1?Set(REALCALLERIDNUM=121)”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-user-callerid:4] Set(“SIP/121-00000019”, “AMPUSER=121”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-user-callerid:5] Set(“SIP/121-00000019”, “AMPUSERCIDNAME=Bria Test”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-user-callerid:6] GotoIf(“SIP/121-00000019”, “0?report”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-user-callerid:7] Set(“SIP/121-00000019”, “AMPUSERCID=121”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-user-callerid:8] Set(“SIP/121-00000019”, “CALLERID(all)=“Bria Test” <121>”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-user-callerid:9] GotoIf(“SIP/121-00000019”, “0?limit”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-user-callerid:10] ExecIf(“SIP/121-00000019”, “0?Set(GROUP(concurrency_limit)=121)”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-user-callerid:11] ExecIf(“SIP/121-00000019”, “0?Set(CHANNEL(language)=)”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-user-callerid:12] GosubIf(“SIP/121-00000019”, “7?sub-ccss,s,1(macro-exten-vm,122)”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@sub-ccss:1] ExecIf(“SIP/121-00000019”, “0?Return()”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@sub-ccss:2] Set(“SIP/121-00000019”, “CCSS_SETUP=TRUE”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@sub-ccss:3] GosubIf(“SIP/121-00000019”, “0?monitor_config,1(macro-exten-vm,122):monitor_default,1(macro-exten-vm,122)”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [monitor_default@sub-ccss:1] GotoIf(“SIP/121-00000019”, “1?is_exten”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Goto (sub-ccss,monitor_default,4)
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [monitor_default@sub-ccss:4] Set(“SIP/121-00000019”, “CALLCOMPLETION(cc_monitor_policy)=generic”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [monitor_default@sub-ccss:5] Set(“SIP/121-00000019”, “CALLCOMPLETION(cc_max_monitors)=5”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [monitor_default@sub-ccss:6] Return(“SIP/121-00000019”, “TRUE”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@sub-ccss:4] GosubIf(“SIP/121-00000019”, “7?agent_config,1():agent_default,1()”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [agent_config@sub-ccss:1] Set(“SIP/121-00000019”, “CALLCOMPLETION(cc_agent_policy)=generic”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [agent_config@sub-ccss:2] Set(“SIP/121-00000019”, “CALLCOMPLETION(cc_offer_timer)=30”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [agent_config@sub-ccss:3] Set(“SIP/121-00000019”, “CALLCOMPLETION(ccbs_available_timer)=”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [agent_config@sub-ccss:4] Set(“SIP/121-00000019”, “CALLCOMPLETION(ccnr_available_timer)=”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [agent_config@sub-ccss:5] Set(“SIP/121-00000019”, “CALLCOMPLETION(cc_callback_macro)=ccss-default”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [agent_config@sub-ccss:6] ExecIf(“SIP/121-00000019”, “1?Set(CALLCOMPLETION(cc_recall_timer)=)”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [agent_config@sub-ccss:7] ExecIf(“SIP/121-00000019”, “1?Set(CALLCOMPLETION(cc_max_agents)=)”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [agent_config@sub-ccss:8] ExecIf(“SIP/121-00000019”, “0?Set(CALLCOMPLETION(cc_agent_dialstring)=Local/121_122@from-ccss-)”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [agent_config@sub-ccss:9] Set(“SIP/121-00000019”, “CALLCOMPLETION(cc_callback_macro)=ccss-default”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [agent_config@sub-ccss:10] Return(“SIP/121-00000019”, “”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@sub-ccss:5] Set(“SIP/121-00000019”, “DB(AMPUSER/121/ccss/last_number)=122”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@sub-ccss:6] Return(“SIP/121-00000019”, “”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-user-callerid:13] GotoIf(“SIP/121-00000019”, “0?continue”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-user-callerid:14] Set(“SIP/121-00000019”, “__TTL=64”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-user-callerid:15] GotoIf(“SIP/121-00000019”, “1?continue”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Goto (macro-user-callerid,s,26)
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-user-callerid:26] Set(“SIP/121-00000019”, “CALLERID(number)=121”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-user-callerid:27] Set(“SIP/121-00000019”, “CALLERID(name)=Bria Test”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-user-callerid:28] Set(“SIP/121-00000019”, “CHANNEL(language)=en”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-exten-vm:2] Set(“SIP/121-00000019”, “RingGroupMethod=none”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-exten-vm:3] Set(“SIP/121-00000019”, “__EXTTOCALL=122”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-exten-vm:4] Set(“SIP/121-00000019”, “__PICKUPMARK=122”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-exten-vm:5] Set(“SIP/121-00000019”, “RT=”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-exten-vm:6] Gosub(“SIP/121-00000019”, “sub-record-check,s,1(exten,122,)”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@sub-record-check:1] GotoIf(“SIP/121-00000019”, “1?check”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Goto (sub-record-check,s,3)
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@sub-record-check:3] Set(“SIP/121-00000019”, “MON_FMT=wav”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@sub-record-check:4] GotoIf(“SIP/121-00000019”, “1?next”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Goto (sub-record-check,s,7)
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@sub-record-check:7] ExecIf(“SIP/121-00000019”, “0?Return()”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@sub-record-check:8] GotoIf(“SIP/121-00000019”, “0?exten,1”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@sub-record-check:9] Set(“SIP/121-00000019”, “__REC_STATUS=INITIALIZED”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@sub-record-check:10] ExecIf(“SIP/121-00000019”, “0?Set(__REC_POLICY_MODE=)”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@sub-record-check:11] Set(“SIP/121-00000019”, “NOW=1401903164”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@sub-record-check:12] Set(“SIP/121-00000019”, “__DAY=04”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@sub-record-check:13] Set(“SIP/121-00000019”, “__MONTH=06”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@sub-record-check:14] Set(“SIP/121-00000019”, “__YEAR=2014”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@sub-record-check:15] Set(“SIP/121-00000019”, “__TIMESTR=20140604-123244”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@sub-record-check:16] Set(“SIP/121-00000019”, “__FROMEXTEN=121”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@sub-record-check:17] Set(“SIP/121-00000019”, “__CALLFILENAME=exten-122-121-20140604-123244-1401903164.25”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@sub-record-check:18] Goto(“SIP/121-00000019”, “exten,1”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Goto (sub-record-check,exten,1)
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [exten@sub-record-check:1] GotoIf(“SIP/121-00000019”, “0?callee”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [exten@sub-record-check:2] Set(“SIP/121-00000019”, “__REC_POLICY_MODE=dontcare”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [exten@sub-record-check:3] GotoIf(“SIP/121-00000019”, “1?caller”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Goto (sub-record-check,exten,10)
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [exten@sub-record-check:10] Set(“SIP/121-00000019”, “REC_POLICY_MODE=dontcare”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [exten@sub-record-check:11] GosubIf(“SIP/121-00000019”, “0?record,1(exten,122,121)”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [exten@sub-record-check:12] Return(“SIP/121-00000019”, “”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-exten-vm:7] Macro(“SIP/121-00000019”, “dial-one,tr,122”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-dial-one:1] Set(“SIP/121-00000019”, “DEXTEN=122”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-dial-one:2] Set(“SIP/121-00000019”, “DIALSTATUS_CW=”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-dial-one:3] GosubIf(“SIP/121-00000019”, “0?screen,1()”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-dial-one:4] GosubIf(“SIP/121-00000019”, “0?cf,1()”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-dial-one:5] GotoIf(“SIP/121-00000019”, “0?skip1”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-dial-one:6] Set(“SIP/121-00000019”, “DEXTEN=”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-dial-one:7] Set(“SIP/121-00000019”, “DIALSTATUS=BUSY”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-dial-one:8] GotoIf(“SIP/121-00000019”, “1?nodial”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Goto (macro-dial-one,s,46)
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-dial-one:46] ExecIf(“SIP/121-00000019”, “0?Set(DIALSTATUS=NOANSWER)”) in new stack
[2014-06-04 12:32:44] VERBOSE[26436] pbx.c: – Executing [s@macro-dial-one:47] NoOp(“SIP/121-00000019”, “Returned from dial-one with nothing to call and DIALSTATUS: BUSY”) in new stack

what asterisk version are you using? Looks like it doesn’t support same =>
try replacing same => n, to
exten => _X.,n

It looks like it only runs the 1st line.

It’s 1.8.23.0, and I’ve also tried it on 1.8.26.1.

Hmm, I’ll debug it in the morning, but it doesn’t seem to be working :\

[from-internal-custom]
exten => 1234,1,Playback(demo-congrats)         ; extensions can dial 1234
exten => 1234,2,Hangup()
exten => h,1,Hangup()
include => custom-recordme                      ; extensions can also dial 5678
include => dnd-override

[dnd-override]
exten => _X.,1,NoOp(This context overrides DND)
exten => _X.,n,Set(IFDNDENABLED=${DB(DND/${EXTEN})})
exten => _X.,n,ExecIf($["${IFDNDENABLED}"="YES"]?Noop(Deleting: DND/${EXTEN} ${DB_DELETE(DND/${EXTEN})}))
exten => _X.,n,Goto(from-internal,${EXTEN},1)
exten => _X.,n,Hangup()
;
exten => h,1,NoOp(Adding back DND status if that existed for user ${CONNECTEDLINE(num)})
exten => h,n,ExecIf($["${IFDNDENABLED}"="YES"]?Set(DB(DND/${CONNECTEDLINE(num)})=YES))
exten => h,n,Hangup

Does that look off at all?