Checking extension registration status in a dialplan

Status
Not open for further replies.

neeek

New Member
Mar 12, 2021
27
4
3
40
Hi all

I'm trying to setup inbound calls to forward to a cellphone when a clients internet goes down (small client, does not own a UPS)
I know I can do this in the extension call routing settings, however this particular clients call flow is:
Inbound call >> time condition >> Ring group

I would like to be able to setup a dialplan that I can slot in between the time condition and the ring group that checks the registration
status of 3 extensions, and if all three are unregistered then it directs the calls to an extension setup specifically as a call forward
(we do it this way so that the client can log in to the web portal and change the forward number if needs be)

I've looked through existing dialplans, as well as posts on this forum hoping to find a variable I can use as a condition, but no luck so far
(actually a list of variables accessible in the dialplan would be fantastic, if there is one somewhere ?)

Any suggestions, pointers or links would be appreciated

Thanks in advance
neeek
 

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,417
377
83
There are probably many different ways you could achieve this. A .LUA script to query the FreeSWITCH Sqlite DB would probably be the most flexible for you. You can test this at the command line with:

Code:
root@testbox1:# /usr/bin/sqlite3 /var/lib/freeswitch/db/core.db "SELECT COUNT(reg_user) from registrations where reg_user = '<extn>' and realm = '<domain>';"

You may need to install sqllite3 if your system doesn't have it.

At the fs_cli you can issue:
sofia status profile internal reg or show registrations

Also, check out the .lua code in /usr/share/freeswitch/scripts/app/failure_handler As it's name suggests it handles call failures for local extensions and has a section that deals with extension not registered.
 
  • Like
Reactions: neeek

neeek

New Member
Mar 12, 2021
27
4
3
40
Thank you
Ah.. I had hoped to avoid scripting.. or rather having to learn LUA scripting ;) but might as well jump in the deep end :)

I did look through the failure_handler lua script, that should prove to be useful :)

Thanks
Nic
 

neeek

New Member
Mar 12, 2021
27
4
3
40
Thought I should update this - another user found the answer without me having to do any scripting and it is fairly easy

Here 9399 is is the destination I am using to test if 405, 203, 204, 208 & 210 are registered then transfer to 9300

<extension name="ring group" continue="" uuid="some-uuid"> <condition field="destination_number" expression="^9399$"/> <condition field='${sofia_contact 405@mycustomer.contoso.com}' expression='^error'/> <condition field='${sofia_contact 203@mycustomer.contoso.com}' expression='^error'/> <condition field='${sofia_contact 204@mycustomer.contoso.com}' expression='^error'/> <condition field='${sofia_contact 208@mycustomer.contoso.com}' expression='^error'/> <condition field='${sofia_contact 210@mycustomer.contoso.com}' expression='^error'> <action application="transfer" data="9300 XML mycustomer.contoso.com"/> <anti-action application="ring_ready" data=""/> <anti-action application="set" data="ring_group_uuid=some-uuid"/> <anti-action application="lua" data="app.lua ring_groups"/> </condition> </extension>
 
  • Like
Reactions: Adrian Fretwell
Status
Not open for further replies.