Dial hooks for offline extensions

[split from this thread - mod]

Hi Lorne,

I see that the predial hook does not work when the target extension is offline. Is there any predial hook that does capture these calls? I tried grepping ‘predial’ but it did not return anything.

Also, are there any variables that I can use in the dialplan to view all hangup handlers? (I know you can do so from cli core show hanguphandlers <channel>)

This VM I tested is a FreePBX 14, all modules are up to date as of today, with Asterisk 13.

Thank you

Hi Doctor @PitzKey

Interesting, I’ve not run into this before, but you’re right. I can’t think of a way of doing a pre-predial hook. What’s your goal, could you do this by modifying the extension dial string?

I probably can, but won’t be as easy and clean.

I challenged myself to build a missed call email notification over the weekend, so far it works great, I’m pulling the email address from the voicemail config and analyzing the call wether it was answered or not, as well if a voicemail was left through a hangup handler, so I don’t need to modify any GUI settings nor do I need to use any of the -custom includes in the current FreePBX dialplan.

As mentioned, it works great so far, tested internal, external and what not, until I bumped in to this issue.

For external incoming calls I can add the hangup handler through the Trunk, I’m stuck with an event when the extension is offline and there’s an internal call to that extension.

I plan on using the predial hook for several other projects including blocking extension to extension and be able to control it from the GUI using the accountcode field.

IMO it’s the cleanest way of doing easy/small integrations. But this limitation of offline extensions is something I’m not happy about… Is it “fixable”? Filing a feature request or bug report would help anything?

HI @PitzKey

I’ve done a bit of testing of calling local extensions that are unregistered:

  • dialing direct to an extension does call the hook
  • dialing a ring group that dials the extension calls the hook for chan_sip but not chan_pjsip

Can you confirm the above? My results be different due to having Zulu enabled on this system.

I don’t have Zulu installed, nor did I have the ChanSIP driver. I installed ChanSIP now for testing.

I tested now. When calling an offline PJSIP extension, it does not seem to call the hook.
When calling an offline ChanSIP extension, it does call the hook. No difference what tech the callee is.

I see this as well.

ICUMI: This VM is on Asterisk 13, FreePBX 14.

I installed Zulu now. Seems to have the same behavior. Perhaps Zulu needs to be licensed?

Here’s a call trace of a call to an offline PJSIP extension. https://pastebin.freepbx.org/view/raw/88d0ef12

As you can see, it does not call any hooks.

If you want, you can post a log as well, so we can try to compare…

Thanks

This has to do with how PJSIP contacts are handled. When it attempts to call the extension is looks for the dial string, that could be SIP/100 or PJSIP/100, when it’s SIP/100 it just takes that dial string and goes from there. When it’s PJSIP/100 it takes that dial string and looks for the existing contacts for the endpoint as there can be multiple. And since each contact stores information like UA details needed to set Auto Answer, etc headers it needs to know the contact information.

Now since there isn’t a registered contact, there’s no dial string for Asterisk to use and thus it never attempts to dial the extension and doesn’t get far enough in the dialplan to execute the hook you want to use. The flip side is since Chan_SIP doesn’t really have contacts it just checks for the state of that peer so it does return a dial string (and thus a contact) making it continue in the dialplan to the hook.

3 Likes

Just spit-balling, but would the “LOCAL/100” method work better/worse/differently? I haven’t looked closely, but I’m gonna guess that this performs similarly to the Chan-SIP method.

Nope. The Local would have to be Local/100@from-internal which will then process it back into the exact same issue when it goes to get the PJSIP contacts and there are none, it’s not going to continue to attempt the dial.

1 Like

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