User Rating: 4 / 5

Star Active Star Active Star Active Star Active Star Inactive
 
freeswitch-logo-blue.png

So one of my customers is creating a calling card service to call abroad. Without entering in many details, the big challenge here is setting a variable after leg B has been answered. It took me a while to figure out how; I can tell you now that exporting variables locally or non-locally (nolocal:) doesn't work. But then, I found the right way.

LUA is FreeSWITH's Best Friend

I have found no way to do it directly in the dialplans. The tricky part here is that you need to assign the post-bridge variable when leg B is answered, but before it is destroyed. Then, LUA is the right way to do it.

I did the following:

  • add this direction in your dialplan before the bridge statement: export nolocal:execute_on_answer=lua script.lua ${uuid}
  • create a Lua script like this:
    if ( session:ready() ) then
           local uuid = argv[1]
           api = freeswitch.API();
           reply = api:executeString("uuid_setvar "..uuid.." post_bridge_variable 000");
    end

This little script will create a variable named "post_bridge_variable" and it will be assigned "000" as its value. You can verify it when you review your CDR variables.

Use Case

When you are doing a DISA, you may want to log in the CDR when leg B is answered. This is the way to do it.

Good luck!

blog comments powered by Disqus

About

Read about IT, Migration, Business, Money, Marketing and other subjects.

Some subjects: FusionPBX, FreeSWITCH, Linux, Security, Canada, Cryptocurrency, Trading.