Accessing database variables from inside Dialplan

Status
Not open for further replies.

David Dunlap

New Member
Mar 16, 2017
9
0
1
62
What is the syntax to populate a fusionpbx dialplan variable with a data field in the advanced/defaults or advanced/variables tables?
Say we add a new variable to a domain - either in adv/def or adv/vars and want to use that in a dialplan.

Thanks in advance.

ddd
 

hfoster

Active Member
Jan 28, 2019
684
81
28
34
For the most part, set them in Variables and use them in the dialplan like ${variable_name}. You can also set them in channel:

<action application="set" data="var_name=var value"/>
<action application="log" data="INFO The value in the var_name chan var is ${var_name}"/>


Default settings is for PHP variables and the functioning of the website.

Never needs to do this myself, so I'll have to ask what's the intention?
 

markjcrane

Active Member
Staff member
Jul 22, 2018
499
177
43
49
If you want to add variables for a specific domain then you would add those variables to a dialplan that is now called domain-variables. It used to just be called variables however when I added a global variables dialplan it made sense to rename it to domain-variables. These are channel variables for a call.

Advanced -> Variables is primarily used with SIP profiles. Used to be applied to all calls but that changed at some point. The SIP profile interface is simple enough that advanced variables isn't that useful anymore unless making a variable that are likely to be changed. So we will likely rely less on Advanced -> Variables in the future. Considering adding it as a category in default settings.

Default Settings has many variables for provisioning for the theme and for various features in FusionPBX and these settings don't make sense to be channel variables for calls.
 

David Dunlap

New Member
Mar 16, 2017
9
0
1
62
I have a lua script that begins recording if 911 is called and after the call ends it emails the recorded call to some address.
We wanted the destination to: address to be a database variable so a user would not have to code an actual dialplan.
In building this we discovered the system caches database query results and does not always return the current database value.
Perhaps I am going about this the wrong way - the desired result is the 911 call recording being sent to staff at assisted living facility so they know the nature of the event before first responders arrive.
 

David Dunlap

New Member
Mar 16, 2017
9
0
1
62
If you want to add variables for a specific domain then you would add those variables to a dialplan that is now called domain-variables. It used to just be called variables however when I added a global variables dialplan it made sense to rename it to domain-variables. These are channel variables for a call.

Advanced -> Variables is primarily used with SIP profiles. Used to be applied to all calls but that changed at some point. The SIP profile interface is simple enough that advanced variables isn't that useful anymore unless making a variable that are likely to be changed. So we will likely rely less on Advanced -> Variables in the future. Considering adding it as a category in default settings.

Default Settings has many variables for provisioning for the theme and for various features in FusionPBX and these settings don't make sense to be channel variables for calls.
Thanks Mark, So what would be the best way to enable a site admin to manage the email destination used for 911 calls? I really do not wish to expose coding dialplans to anyone.
 

David Dunlap

New Member
Mar 16, 2017
9
0
1
62
Creating a new variable inside the dialplan "domain-variables" -> emergency_email_address=xxxx@xxx.com
Then referencing that variable in the 911 dialplan -> email_recordings_to=${emergency_email_address} did not return a value.
That does not help at all. Might as well hard code the address into the code and edit whenever they need to change it.
 

DigitalDaz

Administrator
Staff member
Sep 29, 2016
3,070
577
113
It may help you to call the application "info" in your dialplan for debugging purposes, this will dump all the vars available to you in the cli/log.
 

David Dunlap

New Member
Mar 16, 2017
9
0
1
62
It may help you to call the application "info" in your dialplan for debugging purposes, this will dump all the vars available to you in the cli/log.
Great tip! I was not aware of that application. It did show my custom variable. Thanks
 

DigitalDaz

Administrator
Staff member
Sep 29, 2016
3,070
577
113
That var should definitely be accessible at that point, you may need to export it to other legs to ensure it gets passed along
 

David Dunlap

New Member
Mar 16, 2017
9
0
1
62
OK, exporting a domain-variable is visible in the script. And changes to the variable are immediately reflected in next call. Does this solve my problem of asking a user to edit a dialplan? Can I expose just this variable to them without having them gain access to all other variables?
 
Last edited:
Status
Not open for further replies.