External dial in, activate follow me

I think I have the same question as this user.

But I’m new to FreePBX so don’t understand the answer.

We have users that we want to give them the capability of dialing into our PBX from external (cell phones, etc) and allow them to activate/deactivate their personal follow me. This isn’t related to setting up the number they want to forward to, this is strictly the ability to toggle the enabled/disabled state of the feature via dialing into the PBX externally.

We know about the webUI to do this, and we know users can do it from their desk phone by dialing *21. But we want to give users the ability to do this by calling in from an external phone.

How might we go about setting this up?

While I’m not sure what parts you don’t understand, let me try to help you with a framework that might get you closer.

Step 1 is to understand how contexts work. A context is a bit of (broad sense) code that gives your call ways to do things. It isn’t just a program: its more, but it doesn’t hurt to think of it as a program. Like most programs, it’s set up to do things based on input from your phone and other sources of data. Different contexts to different things and affect the security of your system, so (like with most programs) it’s important to understand what they do and why they do it.

For this “dialing in to set a feature code” thing to happen, you have to be on a call that can access your internal feature codes. The “normal” way that happens is through a context called “from-internal”. This is the context in which stuff that you need to be on the local network to do is processed. For example, “from-pstn” (a different context) is a common context for incoming calls. These calls can basically only do a few specific things (like call a local extension). The “from-internal” context allows you to toggle feature codes and call out.

The “normal” (being a relative term) way to do this is through an interface like “DISA” or through external extensions. In DISA, you call a special number, put in an access code, and get a dial-tone on the PBX. From there, you can do anything you would do from a local phone. In an external extension, your phone is already in the local network (logically) because it’s an extension.

So, once you’re in the right context (through DISA or through setting up local extensions) you can toggle the feature code on and off at will.

The next bit of business you need to figure out is which solution is best for your situation. I’ve done this for a couple of places that want their technicians to call out with the company’s Caller ID. For them, the easiest solution was to have them dial in to a special number that asked for their n-digit PIN to proceed. Combined with white-listing the Caller ID from their cell phones, this provides a very secure way to give them a line in the local network without having to mess around with the firewall.

Now, having said that, I’ve set up my own system so that my cell phone is a local extension on my main system. When I call with Zoiper, the outbound caller ID is my main PBX number. Same result, just another way to make it happen.

Now, there are probably another three or four ways to make this happen, including setting up special custom contexts associated with inbound Caller ID from cell phones or connections through an IVR, but the result is always the same. At some point, in order to make this work, you have to be in a context that allows you to override the CFW settings.

DISA combined with this custom feature code: Prefix *22 that you can dial in front of a valid system extension to toggle the Follow Me

1 Like

All great information.
@cynjut, once we decide how we want to allow users to access this feature.
(for right now, let’s assume from-pstn DISA)

how do we allow the phone system to know what extension we want the user to be able to toggle the follow me. If you call from an internal phone it assumes the extension you want to toggle is the phone extension you’re calling from.
In the case of dialing in from external via a cell phone, how do we pass the extension we wish to toggle? Can it be something like the following.

  1. Call special DID
  2. PBX receives call and sends to special DISA
  3. DISA asks for pin code
  4. User inputs generic pin code that we will give to everyone (let’s say 1234)
  5. DISA asks user for extension
  6. User inputs extension 4303
  7. PBX toggles follow me on/off for extension 4303

You were good to here.

At this point, you have a dial-tone, as if you were sitting on an extension in the office with the phone off hook. So, at this point, if you enter *21, it will try to toggle your “extension’s” FMFM, which is completely not what you want.

If you want to make the rest of your recipe work, you’ll need a Feature Code that calls a new context. In that context (remember, it’s more or less a program), you will ask for the user’s extension, and your new context will toggle the FMFM. You could even write the new context that uses “*294303” and pull the extension number out of the dial string. That would be about three lines of code and would solve your problem. It would also give you a lot of flexibility, in that anyone that can call in can toggle anyone’s FMFM.

Now, having said that - I’m not sure this part isn’t done for you. I can’t find anything that says that *21 doesn’t take an argument. If it does, you’re golden. If it doesn’t, it’s a simple bit of code to write. Once you’re done, you connect it to your system through MiscApps (IIRC).

we’ve done some internal testing on the *21 feature code and we’ve not been able to get it to pass additional digits for an extension. it just ignores it.

What might some examples of the code needed look like that you mention we need to pass to an additional arguments in the new context.

In the code for feature code *22 where it says:
exten => _*22X.,1,Noop(Entering context from-internal-custom in extensions_custom.conf)
…does the part in the parenthesis go in verbatim, or is this supposed to be replaced with information from something else?

Verbatim is fine.

If you call in the toggle of app-fmf-toggle needs a valid ${AMPUSER} but there isn’t one , a quick cut and paste gives adding to /etc/asterisk/extensions_custom.conf in the [from-internal-custom] context

exten => *22,1,Read(AMPER,zombies,4,1,1)
exten => *22,n,SayDigits(${AMPER})
exten => *22,n,GotoIf($["${DB(AMPUSER/${AMPER}/followme/ddial)}" = "EXTENSION"]?activate)
exten => *22,n,GotoIf($["${DB(AMPUSER/${AMPER}/followme/ddial)}" = "DIRECT"]?deactivate:end)
exten => *22,n(deactivate),Set(DB(AMPUSER/${AMPER}/followme/ddial)=EXTENSION)
exten => *22,n,Set(STATE=NOT_INUSE)
exten => *22,n(hook_off),Playback(followme&de-activated)
exten => *22,n(end),Macro(hangupcall,)
exten => *22,n(activate),Set(DB(AMPUSER/${AMPER}/followme/ddial)=DIRECT)
exten => *22,n,Set(STATE=INUSE)
exten => *22,n(hook_on),Playback(followme&activated)
exten => *22,n,Macro(hangupcall)

change *22 to whatever works for you,replace your zombies with something rational, it assumes 4 digit extensions and does nothing if you enter an invalid extension. But you can add that logic if you want .

(Caveate emptor, I have not well tested this !)

So after setting up “extensions_custom.conf”, we need to make a special DISA and set the “Context” field on it to “from-internal-custom”? Is this correct? Or will the *22 code work from any internal line?

If you used “from-internal-custom” as the name of your custom context, you should be able to use “from-internal” as the context. The context “from-internal-custom” is included in “from-internal” automatically.

I was able to set this up and it works perfectly from an internal phone… but does not work from a DISA. It just goes back to a dial tone, or if I turn off “Allow Hangup” on the DISA, it hangs up.

I am dialing *224326 to toggle “follow me” for extension 4326. Again, this does work from an internal phone.

We’re using FreePBX 14, BTW, if this helps at all or changes anything, and I’m using the code from [Prefix *22 that you can dial in front of a valid system extension to toggle the Follow Me]

Need a call trace

https://wiki.freepbx.org/display/SUP/Providing+Great+Debug#ProvidingGreatDebug-AsteriskLogs-PartII

From an internal extension, ${AMPUSER} is defined, from an external call it is not, so you need to do something like my post suggests to toggle FMFM for a pre-defined extension’s followme/ddial it is all about setting the sqlite3 key and data where the ‘data’ is either EXTENSION or DIRECT

rasterisk -x ' database show'|grep "followme/ddial"

try it :slight_smile:

for example

 rasterisk -x ' database put AMPUSER/9800/followme ddial EXTENSION'

or

 rasterisk -x ' database put AMPUSER/9800/followme ddial  DIRECT'

would change the behavior of 9800’s followme but you need to know what 9800 should be, so you have to glean it when calling in from a DID

Pretty sure @lgaetz will come up with a more elegant solution if you just wait :slight_smile:

It shouldn’t. The exten pattern on the code is “*22”. To include the extension number (to match) you’d need “*22_” which will match the *22 and whatever you dial after that.

Off the top of my head (IOW, guaranteed to not work OOTB) You can then using something like "*22_,n,“Set(${AMPER}=$EXTEN,3,4)” instead of the SayDigits line to cut the extension out of the extension number. Remember, this is just a design, the actual code will of course be different and will work.

You could them check to see if “${AMPER}” is set, and if it isn’t, use a “Say” and “Read” to get it (like the current start of the context).

There are 2 system ID events in the CDR (that are identical to each other) and this one line is all that greps in the logs:
/var/log/asterisk/full:[2019-07-11 10:13:32] VERBOSE[13613][C-00000111] pbx.c: Executing [s@macro-user-callerid:1] Set(“Local/*224326@from-internal-0000003c;2”, “TOUCH_MONITOR=1562865211.3569”) in new stack

Here is the CDR, actual phone numbers are redacted to descriptions):

Time Event CNAM CNUM ANI DID AMA exten context App channel UserDefType EventExtra CEL Table
Thu, 11 Jul 2019 10:13 CHAN_START ALEXANDER,ROBER (cell phone) DEFAULT (dial in DID) from-trunk SIP/xxxxxxxxxxGW2-000000dd
Thu, 11 Jul 2019 10:13 ANSWER ALEXANDER,ROBER (cell phone) (cell phone) (dial in DID) DEFAULT s ivr-23 Answer SIP/xxxxxxxxxxGW2-000000dd
Thu, 11 Jul 2019 10:13 CHAN_START DEFAULT *224326 from-internal Local/*224326@from-internal-0000003c;1
Thu, 11 Jul 2019 10:13 CHAN_START DEFAULT *224326 from-internal Local/*224326@from-internal-0000003c;2
Thu, 11 Jul 2019 10:13 ANSWER *224326 DEFAULT *224326 from-internal AppDial Local/*224326@from-internal-0000003c;1
Thu, 11 Jul 2019 10:13 ANSWER Robert Alexander 4326 (cell phone) DEFAULT s app-fmf-toggle Answer Local/*224326@from-internal-0000003c;2
Thu, 11 Jul 2019 10:13 BRIDGE_ENTER *224326 DEFAULT from-internal AppDial Local/*224326@from-internal-0000003c;1
Thu, 11 Jul 2019 10:13 BRIDGE_ENTER Robert Alexander (ext 4326 DID) (cell phone) (dial in DID) DEFAULT *224326 disa-dial Dial SIP/xxxxxxxxxxGW2-000000dd
Thu, 11 Jul 2019 10:13 BRIDGE_EXIT *224326 DEFAULT from-internal AppDial Local/*224326@from-internal-0000003c;1
Thu, 11 Jul 2019 10:13 HANGUP *224326 DEFAULT from-internal AppDial Local/*224326@from-internal-0000003c;1
Thu, 11 Jul 2019 10:13 CHAN_END *224326 DEFAULT from-internal AppDial Local/*224326@from-internal-0000003c;1
Thu, 11 Jul 2019 10:13 HANGUP Robert Alexander 4326 (cell phone) DEFAULT s app-fmf-toggle Local/*224326@from-internal-0000003c;2
Thu, 11 Jul 2019 10:13 CHAN_END Robert Alexander 4326 (cell phone) DEFAULT s app-fmf-toggle Local/*224326@from-internal-0000003c;2
Thu, 11 Jul 2019 10:13 BRIDGE_EXIT Robert Alexander (ext 4326 DID) (cell phone) (dial in DID) DEFAULT *224326 disa-dial Dial SIP/xxxxxxxxxxGW2-000000dd
Thu, 11 Jul 2019 10:13 HANGUP Robert Alexander (ext 4326 DID) (cell phone) (dial in DID) DEFAULT 1 disa SIP/xxxxxxxxxxGW2-000000dd
Thu, 11 Jul 2019 10:13 CHAN_END Robert Alexander (ext 4326 DID) (cell phone) (dial in DID) DEFAULT 1 disa SIP/xxxxxxxxxxGW2-000000dd
Thu, 11 Jul 2019 10:13 LINKEDID_END Robert Alexander (ext 4326 DID) (cell phone) (dial in DID) DEFAULT 1 disa SIP/xxxxxxxxxxGW2-000000dd

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.