[Freeswitch-users] How to force FS to execute?

Ben Langfeld ben at langfeld.co.uk
Thu Sep 20 13:42:44 MSD 2012


This sort of thing is trivial with Adhearsion:

class PINValidationController < Adhearsion::CallController
  def run
    menu 'conf-pin.wav', timeout: 10, terminator: '#' do
      match('1234') { speak 'Opening the pod bay doors' }

      timeout { speak 'You didn't enter anything!' }
      invalid do
        speak 'That's the wrong PIN'
        hangup
      end
    end
  end
end

Regards,
Ben Langfeld


On 19 September 2012 23:51, Michael Collins <msc at freeswitch.org> wrote:

> Don't we have a PIN validation routine in mod_voicemail? Alternatively,
> one could write a semi-generic PIN validation Lua script relatively easily.
> If no one does it prior to me getting to chapter 7 of the FS book re-write
> then I will consider doing it as an example script.
>
> -MC
>
>
> On Wed, Sep 19, 2012 at 2:12 PM, Ken Rice <krice at freeswitch.org> wrote:
>
>> If its extremely heavily loaded why not write an application to handle the
>> pin collection and validation
>>
>> K
>>
>>
>> On 9/19/12 3:31 PM, "Emrah" <lists at kavun.ch> wrote:
>>
>> > My example is far from being the best. Correct me if I am wrong, but
>> abusing
>> > of the logic I am using can heavily load the dialplan processing...
>> > MFC's idea to execute an extension sounds pretty sexy.
>> >
>> > Can my example have undesirable side effects? Obviously the var name
>> can be
>> > something more unique.
>> >
>> > Cheers
>> > On Sep 19, 2012, at 4:19 PM, Emrah <lists at kavun.ch> wrote:
>> >
>> >> You are correct indeed.
>> >> This was just to get an idea. If I want data from an external source,
>> there
>> >> are plenty of dialplan options, including ${api func()} to be a little
>> >> suicidal. :P
>> >> We can pretty much fall back on LUA, Perl, IVR, so on and so forth for
>> >> anything and everything.
>> >> For the purpose of my test case, my example seems to fit the bill and
>> does
>> >> the job.
>> >>
>> >> Cheers,
>> >> Emrah
>> >> On Sep 19, 2012, at 3:57 PM, Stanislav Sinyagin <ssinyagin at yahoo.com>
>> wrote:
>> >>
>> >>> Emrah, I think an IVR menu would be much easier to handle and to
>> maintain
>> >>> than what you;re trying to do.
>> >>> Or write a Lua script, then you're even more flexible in all the
>> checkups.
>> >>> You can also look up the PIN in some external database instead of
>> having it
>> >>> statically coded in XML
>> >>>
>> >>>
>> >>> From: Emrah <lists at kavun.ch>
>> >>> To: FreeSWITCH Users Help <freeswitch-users at lists.freeswitch.org>
>> >>> Sent: Wednesday, September 19, 2012 8:20 PM
>> >>> Subject: Re: [Freeswitch-users] How to force FS to execute?
>> >>>
>> >>> There is a valid case to me, and here it is Sir. :)
>> >>> <extension name="pin test">
>> >>> <condition field="${pin}" expression="^1234$" break="on-true">
>> >>> <action application="log" data="INFO Pin is ${pin}" />
>> >>> <action application="transfer" data="3000 XML local" />
>> >>> </condition>
>> >>> <condition field="${pin}" expression="^\d{4}" break="never">
>> >>> <action application="playback" data="conference/conf-bad-pin.wav" />
>> >>> <action application="unset" data="pin" />
>> >>> </condition>
>> >>> <condition field="destination_number" expression="^111$"
>> break="never">
>> >>> <action application="answer"/>
>> >>> <action application="sleep" data="1000"/>
>> >>> <action application="read" data="4 4 conference/conf-pin.wav pin
>> 10000 #,*"
>> >>> />
>> >>> <action application="transfer" data="111 XML local" />
>> >>> </condition>
>> >>> </extension>
>> >>>
>> >>> I think I'm starting to get the hang of this thing!
>> >>>
>> >>> E
>> >>>
>> >>> On Sep 19, 2012, at 12:22 PM, Michael Collins <msc at freeswitch.org>
>> wrote:
>> >>>
>> >>>> There is no valid case not to use transfer (or even
>> execute_extension) in
>> >>>> this scenario. Create a new file: conf/dialplan/check_pin.xml:
>> >>>>
>> >>>> <include>
>> >>>> <context name="utility">
>> >>>>   <extension name="Check PIN">
>> >>>>     <condition field="destination_number" expression="^check_pin$"/>
>> >>>>     <condition field="${pin}" expression="^1234$">
>> >>>>       <action application="transfer" data ="3000 XML local" />
>> >>>>       <anti-action application="hangup" data="Login Failed"/>
>> >>>>     </condition>
>> >>>>   </extension>
>> >>>> </context>
>> >>>> </include>
>> >>>>
>> >>>> Then just do this in your original extension that has the read app
>> (note I
>> >>>> changed the name of the extension for clarity):
>> >>>>
>> >>>> <extension name="Get PIN from caller">
>> >>>> <condition field="destination_number" expression="^111$"
>> break="never">
>> >>>>   <action application="answer"/>
>> >>>>   <action application="sleep" data="1000"/>
>> >>>>   <action application="read" data="4 4
>> >>>> $${base_dir}/sounds/en/us/callie/conference/8000/conf-pin.wav pin
>> 10000
>> >>>> #,*"/>
>> >>>>   <action application="log" data="INFO user entered '${pin}'"/>
>> >>>>   <action application="transfer" data="check_pin XML utility"/>
>> >>>> </condition>
>> >>>> </extension>
>> >>>>
>> >>>> That's all there is to it. If this method seems weird, or unusual, or
>> >>>> abstract then too bad! :) It's a great way to keep things relatively
>> simple
>> >>>> while ensuring a level of security.
>> >>>>
>> >>>> -MC
>> >>>>
>> >>>> On Wed, Sep 19, 2012 at 8:46 AM, Emrah <lists at kavun.ch> wrote:
>> >>>> Naming an extension won't help for my transfer purpose.
>> >>>> What I think  I will do is use the same 1 extension idea, but verify
>> the
>> >>>> existance of ${pin} before executing the read instruction.
>> >>>> This way if ${pin} exists, it will execute one set of instructions,
>> if it
>> >>>> doesn't, it will execute the read app. Following the read app would
>> just be
>> >>>> an action to transfer the user to the same context and
>> destination_number.
>> >>>>
>> >>>> I hope what I tried to explain makes sense.
>> >>>> On Sep 19, 2012, at 10:40 AM, Ken Rice <krice at freeswitch.org> wrote:
>> >>>>
>> >>>>> You can call an extension whatever you want... It doesn't have to
>> be a
>> >>>>> number... But using the separate context allows you to keep the
>> >>>>> destination
>> >>>>> number field in the CDR something same like that actual destination
>> >>>>> number...
>> >>>>>
>> >>>>>
>> >>>>> On 9/19/12 7:25 AM, "Emrah" <lists at kavun.ch> wrote:
>> >>>>>
>> >>>>>> Is there a way to address an extension without assigning it to a
>> >>>>>> destination_number? I don't want the extension to be reachable
>> directly
>> >>>>>> and
>> >>>>>> would gladly avoid creating a dedicated context.
>> >>>>>> Can I transfer a call to an extension that doesn't have a
>> >>>>>> destination_number?
>> >>>>>>
>> >>>>>> Best,
>> >>>>>> Emrah
>> >>>>>> On Sep 19, 2012, at 7:10 AM, Emrah <lists at kavun.ch> wrote:
>> >>>>>>
>> >>>>>>> Easy indeed, but I wanted to avoid it thinking there was some
>> other
>> >>>>>>> alternative.
>> >>>>>>> Thanks for your quick response, will use it.
>> >>>>>>>
>> >>>>>>> Cheers,
>> >>>>>>> Emrah
>> >>>>>>> On Sep 19, 2012, at 12:50 AM, Ken Rice <krice at freeswitch.org>
>> wrote:
>> >>>>>>>
>> >>>>>>>> This is easy to handle... Do it as 2 different extensions and
>> after you
>> >>>>>>>> collect the PIN, use the transfer application to transfer the
>> call to a
>> >>>>>>>> pin
>> >>>>>>>> validating extension... Problem fixed with a very simple solution
>> >>>>>>>>
>> >>>>>>>> On 9/18/12 11:42 PM, "Emrah" <lists at kavun.ch> wrote:
>> >>>>>>>>
>> >>>>>>>>> Please bypass the inline="true"Š A fantasy of mine.
>> >>>>>>>>> On Sep 19, 2012, at 12:32 AM, Emrah <lists at kavun.ch> wrote:
>> >>>>>>>>>
>> >>>>>>>>>> Hi all,
>> >>>>>>>>>>
>> >>>>>>>>>> My example below cannot work because FS does not store the
>> value of
>> >>>>>>>>>> ${pin}
>> >>>>>>>>>> until the call goes into execution state. While keeping it
>> simple,
>> >>>>>>>>>> what
>> >>>>>>>>>> would
>> >>>>>>>>>> be your take on this? Is there a way to instruct FS to start
>> >>>>>>>>>> executing at
>> >>>>>>>>>> some point and discovering the dialplan along the way?
>> >>>>>>>>>>
>> >>>>>>>>>> <extension name="pin test">
>> >>>>>>>>>> <condition field="destination_number" expression="^111$"
>> >>>>>>>>>> break="never">
>> >>>>>>>>>> <action application="answer"/>
>> >>>>>>>>>> <action application="sleep" data="1000"/>
>> >>>>>>>>>> <action application="read" data="4 4
>> >>>>>>>>>> $${base_dir}/sounds/en/us/callie/conference/8000/conf-pin.wav
>> pin
>> >>>>>>>>>> 10000
>> >>>>>>>>>> #,*"
>> >>>>>>>>>> inline="true" />
>> >>>>>>>>>> </condition>
>> >>>>>>>>>> <condition field="${pin}" expression="^1234$">
>> >>>>>>>>>> <action application="transfer" data ="3000 XML local" />
>> >>>>>>>>>> </condition>
>> >>>>>>>>>> <condition field="${pin}" expression="^\d{4}$">
>> >>>>>>>>>> <action application="hangup" />
>> >>>>>>>>>> </condition>
>> >>>>>>>>>> </extension>
>> >>>>>>>>>>
>> >>>>>>>>>> Thanks and all the best, as always.
>> >>>>>>>>>> Emrah
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> ______________________________________________________________________
>> >>>>>>>>> ___
>> >>>>>>>>> Professional FreeSWITCH Consulting Services:
>> >>>>>>>>> consulting at freeswitch.org
>> >>>>>>>>> http://www.freeswitchsolutions.com
>> >>>>>>>>>
>> >>>>>>>>> 
>> >>>>>>>>> 
>> >>>>>>>>>
>> >>>>>>>>> Official FreeSWITCH Sites
>> >>>>>>>>> http://www.freeswitch.org
>> >>>>>>>>> http://wiki.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-use
>> >>>>>>>>> rs
>> >>>>>>>>> http://www.freeswitch.org
>> >>>>>>>>
>> >>>>>>>> --
>> >>>>>>>> Ken
>> >>>>>>>> http://www.FreeSWITCH.org
>> >>>>>>>> http://www.ClueCon.com
>> >>>>>>>> http://www.OSTAG.org
>> >>>>>>>> irc.freenode.net #freeswitch
>> >>>>>>>>
>> >>>>>>>>
>> >>>>>>>>
>> >>>>>>>>
>> _______________________________________________________________________
>> >>>>>>>> __
>> >>>>>>>> Professional FreeSWITCH Consulting Services:
>> >>>>>>>> consulting at freeswitch.org
>> >>>>>>>> http://www.freeswitchsolutions.com
>> >>>>>>>>
>> >>>>>>>> 
>> >>>>>>>> 
>> >>>>>>>>
>> >>>>>>>> Official FreeSWITCH Sites
>> >>>>>>>> http://www.freeswitch.org
>> >>>>>>>> http://wiki.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-user
>> >>>>>>>>
>> s
>> >>>>>>>> http://www.freeswitch.org
>> >>>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> _________________________________________________________________________
>> >>>>>> Professional FreeSWITCH Consulting Services:
>> >>>>>> consulting at freeswitch.org
>> >>>>>> http://www.freeswitchsolutions.com
>> >>>>>>
>> >>>>>> 
>> >>>>>> 
>> >>>>>>
>> >>>>>> Official FreeSWITCH Sites
>> >>>>>> http://www.freeswitch.org
>> >>>>>> http://wiki.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
>> >>>>>
>> >>>>> --
>> >>>>> Ken
>> >>>>> http://www.FreeSWITCH.org
>> >>>>> http://www.ClueCon.com
>> >>>>> http://www.OSTAG.org
>> >>>>> irc.freenode.net #freeswitch
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>>>
>> _________________________________________________________________________
>> >>>>> Professional FreeSWITCH Consulting Services:
>> >>>>> consulting at freeswitch.org
>> >>>>> http://www.freeswitchsolutions.com
>> >>>>>
>> >>>>> 
>> >>>>> 
>> >>>>>
>> >>>>> Official FreeSWITCH Sites
>> >>>>> http://www.freeswitch.org
>> >>>>> http://wiki.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://wiki.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
>> >>>>
>> >>>>
>> >>>>
>> >>>> --
>> >>>> Michael S Collins
>> >>>> Twitter: @mercutioviz
>> >>>> http://www.FreeSWITCH.org
>> >>>> http://www.ClueCon.com
>> >>>> http://www.OSTAG.org
>> >>>>
>> >>>>
>> >>>>
>> _________________________________________________________________________
>> >>>> Professional FreeSWITCH Consulting Services:
>> >>>> consulting at freeswitch.org
>> >>>> http://www.freeswitchsolutions.com
>> >>>>
>> >>>> 
>> >>>> 
>> >>>>
>> >>>> Official FreeSWITCH Sites
>> >>>> http://www.freeswitch.org
>> >>>> http://wiki.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://wiki.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://wiki.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://wiki.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
>>
>> --
>> Ken
>> http://www.FreeSWITCH.org
>> http://www.ClueCon.com
>> http://www.OSTAG.org
>> irc.freenode.net #freeswitch
>>
>>
>>
>> _________________________________________________________________________
>> Professional FreeSWITCH Consulting Services:
>> consulting at freeswitch.org
>> http://www.freeswitchsolutions.com
>>
>> 
>> 
>>
>> Official FreeSWITCH Sites
>> http://www.freeswitch.org
>> http://wiki.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
>>
>
>
>
> --
> Michael S Collins
> Twitter: @mercutioviz
> http://www.FreeSWITCH.org
> http://www.ClueCon.com
> http://www.OSTAG.org
>
>
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> 
> 
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://wiki.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/20120920/e0fd8fe6/attachment-0001.html 


Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list