Random selection of IVR does not work

freepbx
asterisk
extensions
Tags: #<Tag:0x00007f702c8bff58> #<Tag:0x00007f702c8bfb98> #<Tag:0x00007f702c8bf878>

(Jeroen) #1

Followed the instructions mentioned here: https://community.freepbx.org/t/ivr-random-play-announcement/55312

Just small changes, we only have 2 different IVR’s that need to be randomized. We have an IVR that starts in Dutch and then French and an IVR that starts in French and then Dutch. We want to randomize which language will be heard first. This is a dual language country (Belgium).

We also created these different IVR for opening hours and closing hours. So in total 4 different IVR, 2 for closed hours message and 2 for opening hours. These need to be randomized.

The code in extensions_custom.conf:

[set-random-open]
exten => s,1,Answer
exten => s,n,Goto(ivr-list-op,s,${RAND(1-2)},1)

[ivr-list-op]
exten => s,1,Goto(ivr-5,s,1)
exten => s,2,Goto(ivr-6,s,1)

[set-random-closed]
exten => s,1,Answer
exten => s,n,Goto(ivr-list-cl,s,${RAND(1,2)},1)

[ivr-list-cl]
exten => s,1,Goto(ivr-7,s,1)
exten => s,2,Goto(ivr-8,s,1)

When a call is made and put to this this custom destination, the number gets a busy tone and in the log it says this:

19335[2021-02-14 18:29:30] VERBOSE[160913][C-00000050] pbx_builtins.c: Goto (set-random-closed,s,1)

19336[2021-02-14 18:29:30] VERBOSE[160913][C-00000050] pbx.c: Executing [s@set-random-closed:1] Answer("PJSIP/CM.com_Federation-00000092", "") in new stack

19337[2021-02-14 18:29:30] VERBOSE[160913][C-00000050] pbx.c: Executing [s@set-random-closed:2] Goto("PJSIP/CM.com_Federation-00000092", "ivr-list-closed,s,1932202941,1") in new stack

19338[2021-02-14 18:29:30] VERBOSE[160913][C-00000050] pbx_builtins.c: Goto (ivr-list-closed,s,1932202941)

19339[2021-02-14 18:29:30] VERBOSE[160913][C-00000050] pbx.c: Auto fallthrough, channel 'PJSIP/CM.com_Federation-00000092' status is 'UNKNOWN'

It seems that ${RAND(1,2)} generates a random number of 1932202941 instead of 1 or 2.
No clue how to solve this.


(Itzik) #2

Minor correction, you don’t need to use an extra 1 at the Goto. My bad… But it’s unrelated, I guess.

I see on the open context you have 1-2 and the closed one you have 1,2 which should be right.

Try the below:

[set-random-open]
exten => s,1,Answer
exten => s,n,Goto(ivr-list-op,s,${RAND(1,2)})

[ivr-list-op]
exten => s,1,Goto(ivr-5,s,1)
exten => s,2,Goto(ivr-6,s,1)

[set-random-closed]
exten => s,1,Answer
exten => s,n,Goto(ivr-list-cl,s,${RAND(1,2)})

[ivr-list-cl]
exten => s,1,Goto(ivr-7,s,1)
exten => s,2,Goto(ivr-8,s,1)

Save and reload, then please try to make another call, if it doesn’t work, please post a call trace and the output of

asterisk -x "dialplan show s@set-random-open"

And

asterisk-x "dialplan show s@set-random-closed"

(Jeroen) #3

Thanks, this did the trick. I think me failing to reload after saving also didn’t help.