Yate Community Forum

Yate server => Other Yate server issues => Topic started by: arts111199 on June 09, 2014, 06:34:44 AM

Title: CID
Post by: arts111199 on June 09, 2014, 06:34:44 AM
Dear All

Please could you help me to change caller in random way in regexroute
For example
caller=? what should be here to generate random caller -id ?
Thank You in Advance
Title: Re: CID
Post by: marian on June 10, 2014, 12:58:14 AM
See the random function in regexroute. (explained in regexroute.conf.sample)
$(random,STRING)
Each ? char in STRING will be replaced with a random digit
E.g:
${caller}^100$=;caller=$(random,000???)
Title: Re: CID
Post by: arts111199 on June 10, 2014, 01:57:23 AM
Thank You Marian
It is working
Title: Re: CID
Post by: cc08 on September 03, 2015, 03:51:27 PM
Hi, Marian!

How to make a random choice from a given array of elements using the $(random) function?

For example:   $(random, STRING(1,2)(1,2,3))

The issue arose in connection with the fact that I need of random lines: trunk1, trunk2, trunk3.

Title: Re: CID
Post by: marian on September 07, 2015, 01:42:19 AM
Try this one:

${caller}^100$={
   .*=;choice=$(random,?)
   ${choice}^[0,1,2,3]$=callto_line_1
   ${choice}^[4,5,6]$=callto_line_2
   .....
}

Or you may use the index function (it will choose the target by incrementing a variable):

[$once]
line_index=1

[default]
${caller}^100$=line/123;line=$(index,$(line_index),line1,line2,line3)