How to let users turn on or turn off follow me feature using an extension

Hello all,
I am running asterisk version 11.2.1 at the moment and My CEO has made a request that she would like to be able to dial an ext from her phone and have all of her calls routed to her Cell phone. I know i can do this automatically using the follow me feature. However she is very explicit that she does not want it to happen all the time. I have been reading that there is a way to do it in the features.conf file but I am not sure how to set that up. Does anyone have any experience with doing this?

Use the ASTDB and store if she want’s her calls forwarded or not and check that value when dialing her extension.

exten => 100,1,NoOP()
same => n,ExecIf($[${DB(forward/ceo)} = 1]?Dial(LOCAL/CEONUMBER@pstn-local)) ; Dial the cell if forward is enabled
same => n,Dial(SIP/100) ; Dial the SIP phone

Thats not a bad Idea at all. I should be able to add an extension to update the DB to a 1 (call forwarding enabled) or 0 Call forwarding disabled depending what is currently in there. We use a hotdesking type dialplan so i think i will have to do some comparisons at the beginning of that section of the dialplan to see if the dialed her extension and where to forward it.

ok well that didn’t quite work due to a 503 error with my phone company. So i am trying to forward it to my outbound dial sub routine, However when i set the forward counter to 1 (on) it disables all calls to all extension. I am not sure what the heck is the problem. anyone have nay ideas?

exten => _[12345]XX,1,Verbose(5,Internal user - ${EXTEN})
same => n,Set(E=${EXTEN})
;testing call forwarding

same => n,GotoIf($[${E}=125]?CFTest)
same =>n(CFTest),GosubIf($[${DB(callforward/Ruth)}=1]?CallForwardRuth,Start,1)

First off,

Since this forward only applies to a single user it might be best to put it just in their extension instead of in a pattern match.

Secondly can you show some console output when you place a call to Ruth? How is your GosubIf evaluating?

Give me a second and I’ll get you the console info. I am planning on having it for about 5 users to start but could be as many as 30 by the end of this. only using 1 user as the test to be honest. So I want to have it evaluate in the pattern match if possible.

Executing [125@hotdesk:1] NoOp(“SIP/649ef378f323-0008429d”, “”) in new stack
– Executing [125@hotdesk:2] Set(“SIP/649ef378f323-0008429d”, “LOCATION=649ef378f323-0008429d”) in new stack
– Executing [125@hotdesk:3] Set(“SIP/649ef378f323-0008429d”, “LOCATION=649ef378f323”) in new stack
– Executing [125@hotdesk:4] Set(“SIP/649ef378f323-0008429d”, “WHO=132”) in new stack
– Executing [125@hotdesk:5] GotoIf(“SIP/649ef378f323-0008429d”, “0?internal,125,1”) in new stack
– Executing [125@hotdesk:6] Set(“SIP/649ef378f323-0008429d”, “132_CID_NAME=Brenda Slatman”) in new stack
– Executing [125@hotdesk:7] Set(“SIP/649ef378f323-0008429d”, “132_CID_NUMBER=132”) in new stack
– Executing [125@hotdesk:8] Set(“SIP/649ef378f323-0008429d”, “132_OUTBOUND_PERMISSION=longdistance”) in new stack
– Executing [125@hotdesk:9] Gosub(“SIP/649ef378f323-0008429d”, “blf-begincall,s,1(132,INUSE)”) in new stack
– Executing [s@blf-begincall:1] Verbose(“SIP/649ef378f323-0008429d”, ““Beginning of Call - set BLF Custom Device state””) in new stack
Beginning of Call - set BLF Custom Device state
– Executing [s@blf-begincall:2] Verbose(“SIP/649ef378f323-0008429d”, “Updating: 132 Calls: 0 Status: INUSE”) in new stack
Updating: 132 Calls: 0 Status: INUSE
– Executing [s@blf-begincall:3] ExecIf(“SIP/649ef378f323-0008429d”, “0?ExecIf(0?Set(DEVICE_STATE(Custom:132)=RINGINUSE):Set(DEVICE_STATE(Custom:132)=RINGING)):Set(DEVICE_STATE(Custom:132)=INUSE)”) in new stack
– Executing [s@blf-begincall:4] Set(“SIP/649ef378f323-0008429d”, “GROUP(activecalls)=132”) in new stack
– Executing [s@blf-begincall:5] Set(“SIP/649ef378f323-0008429d”, “CHANNEL(hangup_handler_wipe)=blf-endcall,s,1(132)”) in new stack
– Executing [s@blf-begincall:6] Return(“SIP/649ef378f323-0008429d”, “”) in new stack
– Executing [125@hotdesk:10] Set(“SIP/649ef378f323-0008429d”, “CALLERID(name)=Brenda Slatman”) in new stack
– Executing [125@hotdesk:11] Set(“SIP/649ef378f323-0008429d”, “CALLERID(num)=132”) in new stack
– Executing [125@hotdesk:12] Goto(“SIP/649ef378f323-0008429d”, “users,125,1”) in new stack
– Goto (users,125,1)
– Executing [125@users:1] Verbose(“SIP/649ef378f323-0008429d”, “5,Internal user - 125”) in new stack
– Executing [125@users:2] Set(“SIP/649ef378f323-0008429d”, “E=125”) in new stack
– Executing [125@users:3] NoOp(“SIP/649ef378f323-0008429d”, “125”) in new stack
– Executing [125@users:4] GotoIf(“SIP/649ef378f323-0008429d”, “1?CFTest”) in new stack
– Goto (users,125,5)
– Executing [125@users:5] GosubIf(“SIP/649ef378f323-0008429d”, “1?CallForwardRuth,Start,1”) in new stack
[May 18 15:11:47] ERROR[20222][C-0003f74a]: app_stack.c:566 gosub_exec: Attempt to reach a non-existent destination for Gosub: (Context:CallForwardRuth, Extension:Start, Priority:1)
== Spawn extension (users, 125, 5) exited non-zero on ‘SIP/649ef378f323-0008429d’
– SIP/649ef378f323-0008429d Internal Gosub(blf-endcall,s,1(132)) start
– Executing [s@blf-endcall:1] Verbose(“SIP/649ef378f323-0008429d”, ““End of Call - reset BLF Custom Device state””) in new stack
End of Call - reset BLF Custom Device state
– Executing [s@blf-endcall:2] Verbose(“SIP/649ef378f323-0008429d”, “Updating: 132 Calls: 1”) in new stack
Updating: 132 Calls: 1
– Executing [s@blf-endcall:3] ExecIf(“SIP/649ef378f323-0008429d”, “0?Set(DEVICE_STATE(Custom:132)=INUSE):Set(DEVICE_STATE(Custom:132)=NOT_INUSE)”) in new stack
– Executing [s@blf-endcall:4] Return(“SIP/649ef378f323-0008429d”, “”) in new stack
== Spawn extension (users, 125, 5) exited non-zero on ‘SIP/649ef378f323-0008429d’
– SIP/649ef378f323-0008429d Internal Gosub(blf-endcall,s,1(132)) complete GOSUB_RETVAL=
– SIP/ccef485e29d3-00084292 Internal Gosub(blf-endcall,s,1(505)) start
– Executing [s@blf-endcall:1] Verbose(“SIP/ccef485e29d3-00084292”, ““End of Call - reset BLF Custom Device state””) in new s

OK, So it’s evaluating as True, That means you do have it set correctly in the database.

Do you have a context CallForwardRuth extension Start priority 1 to jump to?

Yes I do.
[CallForwardRuth]
exten => Start,1,Verbose(5,set call id varable)
same => n,set(OUT_E=4194393490)
same => n,Goto(outbound-dial,s,1)
same => n,Return()

[outbound-dial]
exten => s,1,Verbose(NXXNXX ${OUT_E:0:6})
same => n,Set(IS_LOCAL_CALL=${OUTBOUND_LOCAL_CALL(${OUT_E:0:6},${OFFICE})})
same => n,ExecIf($[${IS_LOCAL_CALL} = 0]?ExecIf($[${LD_PERMITTED} = 0]?Goto(no_ld_permission,1):Set(OUT_E=1${OUT_E})))
same => n,Goto(${OFFICE},1)

exten => defiance,1,Verbose(5,“Outbound from Defiance office”)
; Pass this gosub an argument value of 1 to override caller ID (from phones). Pass an argument value of 0 to not override caller ID (from faxes).
same => n,ExecIf($[${ARG1} = 1]?Set(CALLERID(all)=“Recovery Services” <4197829920>))
same => n,Dial(SIP/fivecounty-voice/${OUT_E})
same => n,Return(“Congestion”)

Ya i just tired to post what it is doing and they blocked it

Can you do a ‘dialplan show CallFowardRuth’ ? Maybe there is an error in your extensions.conf that is keeping it from fully loading.

It looks good to me

[ Context ‘CallForwardRuth’ created by ‘pbx_config’ ]
‘Start’ => 1. Verbose(5,set call id varable) [pbx_config]
2. set(OUT_E=4194393490) [pbx_config]
3. Goto(outbound-dial,s,1) [pbx_config]
4. Return() [pbx_config]

-= 1 extension (4 priorities) in 1 context. =-

my other concern is that it looks like if i dial any other extension besides 125 the GotoIf still evaluates to true and trys to go to the GosubIf

That’s because you don’t skip over that logic with your extension test.

Your ‘CFTest’ label is the next line after your GotoIf, so if it fails the test the next step will execute anyway.

You can add another label after the CFTest label and jump to that if the extension is not 125 or you could change your GotoIf to be an ExecIf.

exten => _[12345]XX,1,Verbose(5,Internal user - ${EXTEN})
same => n,Set(E=${EXTEN})
same => n,GotoIf($[${EXTEN}=125]?CFTest:SKIP)
same => n(CFTest),GosubIf($[${DB(callforward/Ruth)}=1]?CallForwardRuth,Start,1)
same => n(SKIP),NoOP()
same => n,NoOP(Dialplan should continue here)

haha! that was the ticket, I cant believe I didn’t see that. Thank you. Now to just get it to pass the Caller ID to the Cellphone and it should work. Next step would be to start adding fields to the external MySQL database and use func_odbc to affect it there instead of making a huge amount of rules in the dial plan. Any thoughts on that process?

func_odbc is a great feature! I wrote my own hotdesking around it based off the example hotdesking from the Asterisk book.

As for the callerID you could try using the ‘o’ option to your Dial to force the callerid to be the callerid present on the calling channel.

pretty much what I did as well