How do I access extension variables in the dialplan?

Status
Not open for further replies.

dv8inpp

Member
Jan 5, 2019
52
0
6
35
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?
 
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
 
So in dialplan manager I need to create Action | Info ?do I need to specify something in the data area?
 
No, just do the action info and you should see a shed load of data in the fs_cli when you make a call.
 
I'm not sure though, how fusionpbx xml handler will be getting custom vars into the channel.
 
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.
 
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
 
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
 
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.