B.90. Random()

Jumps to a priority randomly.
Random([probability]:[[context,]extension,]priority)
Jumps to the specified priority, extension and context based on the probability provided, which must be a whole number between 1 and 100; in probability percent of cases, the call will jump to the specified priority.
; Game of chance with 20% chance of winning:
exten => 123,1,Random(20:won,1)
exten => 123,n,Goto(lost,1)

exten => won,1,Playback(hooray)
exten => won,n,Goto(123,1)

exten => lost,1,Playback(sorry)
exten => lost,n,Goto(123,1)

Important

This application is deprecated as of 1.4; use the Asterisk function RAND() instead.

Note

Internal help for this application in Asterisk 1.4:
  -= Info about application 'Random' =- 

[Synopsis]
Conditionally branches, based upon a probability

[Description]
Random([probability]:[[context|]extension|]priority)
  probability := INTEGER in the range 1 to 100
DEPRECATED: Use GotoIf($[${RAND(1,100)} > <number>]?<label>)
diff output to internal help in Asterisk 1.2:
10d9
< DEPRECATED: Use GotoIf($[${RAND(1,100)} > <number>]?<label>)