[Freeswitch-users] bind_digit_action for lua

Aqs Younas aqsyounas at gmail.com
Mon May 11 22:22:11 MSD 2015


Many thanks for your answer.

On 8 May 2015 at 13:43, Oleg Stolyar <olegstolyar at gmail.com> wrote:

> There are several ways.  One is to use a regex to match any digit and
> execute a lua script.  Inside the script check the last_matching_digits
> session variable.
>
> I have not tried it myself, so not sure how well it will work (regex and
> the variable).  If for some reason it does not, you can still use separate
> bindings for each digit, call the same lua script from each and pass the
> digit in as a parameter like this:
>
> <action application="bind_digit_action" data="my_digits,0,exec:lua,
> your_script.lua,0"/>
> <action application="bind_digit_action" data="my_digits,1,exec:lua,
> your_script.lua,1"/>
> <action application="bind_digit_action" data="my_digits,2,exec:lua,
> your_script.lua,2"/>
>
>
> On Fri, May 8, 2015 at 1:35 PM, Aqs Younas <aqsyounas at gmail.com> wrote:
>
>> Thanks for your reply.
>>
>> I think i didn't explain my question well. I don't want to execute a
>> separate lua script upon each regex match.
>> I want a single script with different functions for corresponding inputs.
>>
>> <include>
>>   <context name="default">
>>    <extension name="radio">
>>         <condition>
>>                 <action application="answer"/>
>>                 <action application="lua" data="main.lua"/>
>>   </condition>
>>   </extension>
>> </context>
>>
>>
>> --main.lua
>> function next()
>>   logic
>> end
>> function previous()
>>  logic
>> end
>>
>>
>> *logic for calling above functions goes here.  *
>> Is it possible to right above dialplan in a single script with different
>> fucntions?
>>
>> Thanks.
>>
>>
>> On 8 May 2015 at 13:11, Oleg Stolyar <olegstolyar at gmail.com> wrote:
>>
>>> I just finished playing with it.  You can just do this:
>>>
>>> <action application="bind_digit_action"
>>> data="my_digits,0,exec:lua,your_script.lua,param1 param2 param3"/>
>>>
>>>
>>>
>>> On Fri, May 8, 2015 at 1:05 PM, Aqs Younas <aqsyounas at gmail.com> wrote:
>>>
>>>> Hi, users.
>>>>
>>>> Below is my default.xml snippet. I am using bind_digit_action for
>>>> different inputs bindings and moves the call to that context upon regex
>>>> match.
>>>>
>>>> <condition>
>>>> <action application="bind_digit_action"
>>>> data="moderator,~\*,exec:execute_extension,previous XML Previous"/>
>>>>         <action application="bind_digit_action"
>>>> data="moderator,~\#,exec:execute_extension,next XML Next"/>
>>>>         <action application="bind_digit_action"
>>>> data="moderator,~^\d$,exec:execute_extension,exten XML Exten"/>
>>>>                 <action application="digit_action_set_realm"
>>>> data="moderator"/>
>>>>         <action application="answer"/>
>>>>         <action application="playback" data="shout://127.0.0.1/radio"/>
>>>> </condition>
>>>>
>>>> Now I want to write my dialplan in lua which I think is more handy than
>>>> xml.
>>>> Upon regex match call to be executed in corresponding functions.
>>>>
>>>> Like, for *
>>>> *function next()*
>>>> for #,
>>>> *function previous()*
>>>>
>>>>
>>>>
>>>> I know there is a application
>>>> *session.setHangupHook(hangup_function_name)*;
>>>> Which executes the function(hangup_function_name) upon call hangup.
>>>>
>>>> Is there anything available in lua witch executes functions upon regex
>>>> match.
>>>> Or any other way for doing this.
>>>>
>>>> Any pointer would be much appreciated.
>>>>
>>>> Thanks.
>>>>
>>>>
>>>>
>>>>
>>>> _________________________________________________________________________
>>>> Professional FreeSWITCH Consulting Services:
>>>> consulting at freeswitch.org
>>>> http://www.freeswitchsolutions.com
>>>>
>>>> Official FreeSWITCH Sites
>>>> http://www.freeswitch.org
>>>> http://confluence.freeswitch.org
>>>> http://www.cluecon.com
>>>>
>>>> FreeSWITCH-users mailing list
>>>> FreeSWITCH-users at lists.freeswitch.org
>>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>>> UNSUBSCRIBE:
>>>> http://lists.freeswitch.org/mailman/options/freeswitch-users
>>>> http://www.freeswitch.org
>>>>
>>>
>>>
>>> _________________________________________________________________________
>>> Professional FreeSWITCH Consulting Services:
>>> consulting at freeswitch.org
>>> http://www.freeswitchsolutions.com
>>>
>>> Official FreeSWITCH Sites
>>> http://www.freeswitch.org
>>> http://confluence.freeswitch.org
>>> http://www.cluecon.com
>>>
>>> FreeSWITCH-users mailing list
>>> FreeSWITCH-users at lists.freeswitch.org
>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>>> http://www.freeswitch.org
>>>
>>
>>
>> _________________________________________________________________________
>> Professional FreeSWITCH Consulting Services:
>> consulting at freeswitch.org
>> http://www.freeswitchsolutions.com
>>
>> Official FreeSWITCH Sites
>> http://www.freeswitch.org
>> http://confluence.freeswitch.org
>> http://www.cluecon.com
>>
>> FreeSWITCH-users mailing list
>> FreeSWITCH-users at lists.freeswitch.org
>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>> http://www.freeswitch.org
>>
>
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://confluence.freeswitch.org
> http://www.cluecon.com
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20150511/20559491/attachment-0001.html 


Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list