[Freeswitch-users] move on from asterisk, the Random or rand function

Michael Collins msc at freeswitch.org
Thu Apr 8 16:29:23 PDT 2010


Good news, bad news:

The good news is that the XML dialplan is a very efficient way of handling
call routing. The bad news is that the XML dialplan is not a programming
language. There is no "rand" function, so you'll need to do something
different. One option is to use mod_distributor, however it is not "random"
so that may not work for you. The other option is to call Lua or system or
something and snag a random number.

-MC

On Thu, Apr 8, 2010 at 1:29 PM, Krzysztof Drewicz <
krzysztofdrewicz at gmail.com> wrote:

> Hi,
>
> i'm slowly, but constantly moving from asterisk to fs.
>
> Stuck on translating this into a freeswitch:
>
> exten => s,1,Random(90:s,3)
> exten => s,2,Noop(his is hit 10% times)
> exten => s,3,Dial(SIP/8000)
>
> What i need to do is put a bucket on some calling_number + destination
> numer
> with some random percent to a voiceguide and hangup.
>
> i've found that memcache is very convinent way to put data into
> dialplan logic in runtime, so i plan to do:
>
> <extension name="bucket_part_01" continue="true">
>        <condition field="${do_bucket}" expression=".+" break="on-true"/>
>        <condition field="caller_id_number" expression="^123456789$">
>        <action data="do_bucket=${memcache(get
> b_${caller_id_number})}" application="set"/>
>        <action data="bucket_part_02" application="transfer"/>
>        <action application="hangup"/>
>        </condition>
> </extension>
>
> So above i check for caller_id_number in the memchache b_123456789 with
> option 1
> Then i transfer to anoter extension:
>
>  <extension name="bucket_part_02">
>        <condition field="destination_number" expression="bucket_part_02"/>
>        <condition field="${czy_robic}" expression="^1$">
>                <action data="bypass_media=true" application="set"/>
>                <action data="hits=${memcache(increment
> hit_bucket_test)}" application="set"/>
>
> AND HERE I do need some logic that does if Random() > 50%
>
>                <action application="answer"/>
>                <action
> data="/usr/local/freeswitch/sounds/pc/weRbusyRightNow.wav"
> application="playback"/>
>                <action application="hangup"/>
>        </condition>
> </extension>
>
>
> any cleaner approach or someone has done it better?
> note: don't want to use any lua, api or sth, just plain xml dialplan logic.
>
> _______________________________________________
> 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/20100408/2f95f558/attachment.html 


More information about the FreeSWITCH-users mailing list