How do I access extension variables in the dialplan?

Status
Not open for further replies.

dv8inpp

Member
Jan 5, 2019
52
0
6
34
I am integrating cgrates with FusionPBX. I have added 3 new variable to the extension page, cgr_reqtype, cgr_subsystems and cgr_acd. I've added these to the database and they are being updated when the extension is updated. I am trying to use the Dialplan manager app to add these variables. (Dialplan | Dialplan Manager | Variables)

First to test this is the place to set the variable I did - action set cgr_reqtype=*prepaid and this created the correct record in Cgrate DB. So it's the right place.

Next I tried:

cgr_reqtype=${user_data ${destination_number}@${domain_name} var cgr_reqtype} . I get the result (cgr_reqtype=) in the FS_CLI console

To verify the syntax is correct and I can retrieve extension variables I tried:

cgr_reqtype=${user_data ${destination_number}@${domain_name} var extension_uuid} and see the result (cgr_reqtype=dbaae5da-6e08-4e41-88d2-cb4c1e4a7e59) which is correct.


How can I retrieve the cgr_reqtype variable?
 

DigitalDaz

Administrator
Staff member
Sep 29, 2016
3,044
565
113
Start by calling application info in the dialplan, you'll see all the variables then in the fs_cli log that are available in the channel.

Good luck, cgrates is a complex piece of kit :D
 

dv8inpp

Member
Jan 5, 2019
52
0
6
34
So in dialplan manager I need to create Action | Info ?do I need to specify something in the data area?
 

DigitalDaz

Administrator
Staff member
Sep 29, 2016
3,044
565
113
No, just do the action info and you should see a shed load of data in the fs_cli when you make a call.
 

DigitalDaz

Administrator
Staff member
Sep 29, 2016
3,044
565
113
I'm not sure though, how fusionpbx xml handler will be getting custom vars into the channel.
 

dv8inpp

Member
Jan 5, 2019
52
0
6
34
I did the action info bit under the variables category but didn't seem to get an channel vairable info.

As I dont see much business sense to have post paid and pre paid extenstions in the same PBX I think I can live with only being able to set it at PBX level.
 

DigitalDaz

Administrator
Staff member
Sep 29, 2016
3,044
565
113
What about cgr_category? Don't you want that at extension level.
 

DigitalDaz

Administrator
Staff member
Sep 29, 2016
3,044
565
113
Without looking too deeply, I think this is the file you want to modify:
Code:
/usr/share/freeswitch/scripts/app/xml_handler/resources/scripts/directory/directory.lua
 

dv8inpp

Member
Jan 5, 2019
52
0
6
34
I tried modifying the file using the following:

Line 355 cgr_reqtype = row.cgr_reqtype
;
Line 643 if (cgr_reqtype ~= nil) and (string.len(cgr_reqtype) > 0) then
Line 644 table.insert(xml, [[ <variable name="cgr_reqtype" value="]] .. cgr_reqtype .. [["/>]]);
Line 645 end
 

dv8inpp

Member
Jan 5, 2019
52
0
6
34
That was the secret suace. It's now getting the variable loaded using

cgr_reqtype=${user_data ${destination_number}@${domain_name} var cgr_reqtype} in the dial plan

Thanks for your guidance on this.
 
Status
Not open for further replies.