[Freeswitch-users] LUA and return variables

Michael Collins msc at freeswitch.org
Fri Dec 18 10:18:33 PST 2009


On Fri, Dec 18, 2009 at 2:21 AM, Robin Vleij <viper at fx-services.com> wrote:

> Hi guys (and girls)!
>
> I'm working on a little bit of ENUM trickery and I tried doing some
> (illegal) nested conditions. :-)
>
> What I want to do is to first check enum with the ENUM application,
> then depending on the answer do some stuff. Say that the domain part
> of the ENUM answer is robin.nl, then I want to do action X instead of
> just briding the enum answer directly as I see in most examples.
>
> But I remembered that it wasn't allowed to do nested conditions. So
> what I did was stacked conditions. After that I read the dialplan wiki
> pages again and figured that my regexp never matches because variables
> I "set" during some phase of the extension I can't use in the same
> "go" as another condition. So, now my plan is to use LUA to do the
> regexp.
>
> I'll pass the enum answer to a lua script which will split the answer
> in a user and domain part and return those two to the main app. Then
> based on those two vars I'll do routing or other actions (like, prefix
> and then route).
>
> Is this how I'm supposed to do it? I can't find many examples on
> manipulating ENUM answers, other than bridging them directly. I can't
> change the way I do stuff to ENUM answers, because in most cases I'll
> just route them out the standard way.
>
> Anyone with experience on fiddling with ENUM answers?
>

One thing you can do is create an extension that does the enum look up and
then transfers the call back into the dialplan. You could set up a separate
context that handles just the enum checking. Your condition would just need
to match whatever var you put the enum return val in. So if your var name is
"enum_res" then you can transfer like this after your enum lookup:

<action application="transfer" data="${enum_res} XML my_enum_context"/>

Then create a context named "my_enum_context" and match for the condition(s)
you need, like:
<condition field="${enum_res}" expression="robin\.nl">
 do stuff
</condition>

Then have a different extension for other values of enum_res...

This is just one way to do it without using a scripting lang. you can by all
means use Lua as well.
-MC
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20091218/a971d7d1/attachment-0002.html 


More information about the FreeSWITCH-users mailing list