random IVR announcement?

merk

Guru
Joined
Sep 5, 2008
Messages
66
Reaction score
1
Hi everyone,

Today a customer asked me a question that I am unsure how to properly tackle.

He wants to record approximately 10 different IVR recordings and have each play in a random order.

The only way I can think of it is to have time conditions but then its not really random. Then I thought maybe a symlink to a script or directory to randomly select a file but I dont know how to do it.

Any ideas or suggestions?
 

Lost Trunk

Guru
Joined
Aug 5, 2008
Messages
228
Reaction score
0
Well, here's an UNTESTED method that might work, or might not. This may not be an elegant way to do it anyway, so maybe someone else can offer something better.

Create ten identical IVR's, except have each use a different announcement.

Create ten Misc. Applications, and let each one point to a different IVR. Give each Misc. Application a number that is in theory dialable but that no one would think to dial, and increment each code by one. Example: 009001, 009002, 009003 ... 009010.

Add a context to extensions_custom.conf:

Code:
[custom-random-ivr]
exten => s,1,Set(EXTEN=00$[${RAND(1,10)} + 9000])
exten => s,n,Goto(from-did-direct,${EXTEN},1)

Create a Custom Destination (under the Tools tab in FreePBX - you might need to install the Custom Applications module):
custom-random-ivr,s,1

Point your inbound route(s) to the Custom Destination.

No idea if this will actually work, just a thought to maybe get you started.
 

jroper

Guru
Joined
Oct 20, 2007
Messages
3,832
Reaction score
71
Hi

Another method may be to change the language.

So in /var/lib/asterisk/sounds, have 10 new directories, each with a different IVR reordings in them.

Then pass the inbound call to the custom context, as per the last post, to come up with a random number, then pass that back into inbound routes, as per the last post - ( same code required) and then into the set language, then into the single IVR.

That should be easier to maintain, as changes to the IVR need only be done once.

Joe
 

merk

Guru
Joined
Sep 5, 2008
Messages
66
Reaction score
1
Hi guys,

Thanks for the response. I tried LOST TRUNKS method and came up empty handed. Whenever the system tries to dial the misc application I get the message everyone is congested in the CLI.

I tried to have it dial the misc application directly but it still didnt work.
Code:
[custom-random-ivr4]
exten => s,1,Goto(app-miscapps-$[${RAND(1,13)} + 0],n,1)
exten => s,2,hangup

Any ideas or directions?

Thanks in advance.
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,207
Reaction score
5,236
Not sure you can use a variable in a context name. Try sending call to mycontext,s,3 or s,5 etc for the various recordings.
 

merk

Guru
Joined
Sep 5, 2008
Messages
66
Reaction score
1
Sorry for my short message before, I cut it short to make the train home. Caller ID = 914-555-1575 and the DID is 718-555-0400

The variable in the context name works properly, I see in the CLI that it dialed 009001 and then 009002 etc etc in a random order.

Custom IVR
Code:
[COLOR=black]exten => s,1,Dial(Local/00$[${RAND(1,10)} + 9000])[/COLOR]
[COLOR=black]exten => s,2,hangup [/COLOR]


Error Code
Code:
[COLOR=black]-- Executing [7185550400@from-trunk:1] Set("SIP/americanservices-bc045540", "__FROM_DID=7185550400") in new stack[/COLOR]
[COLOR=black]-- Executing [7185550400@from-trunk:2] Gosub("SIP/americanservices-bc045540", "app-blacklist-check|s|1") in new stack[/COLOR]
[COLOR=black]-- Executing [s@app-blacklist-check:1] LookupBlacklist("SIP/americanservices-bc045540", "") in new stack[/COLOR]
[COLOR=black]-- Executing [s@app-blacklist-check:2] GotoIf("SIP/americanservices-bc045540", "0?blacklisted") in new stack[/COLOR]
[COLOR=black]-- Executing [s@app-blacklist-check:3] Set("SIP/americanservices-bc045540", "CALLED_BLACKLIST=1") in new stack[/COLOR]
[COLOR=black]-- Executing [s@app-blacklist-check:4] Return("SIP/americanservices-bc045540", "") in new stack[/COLOR]
[COLOR=black]-- Executing [7185550400@from-trunk:3] ExecIf("SIP/americanservices-bc045540", "1 |Set|CALLERID(name)=9145551575") in new stack[/COLOR]
[COLOR=black]-- Executing [7185550400@from-trunk:4] Set("SIP/americanservices-bc045540", "__CALLINGPRES_SV=allowed_not_screened") in new stack[/COLOR]
[COLOR=black]-- Executing [7185550400@from-trunk:5] SetCallerPres("SIP/americanservices-bc045540", "allowed_not_screened") in new stack[/COLOR]
[COLOR=black]-- Executing [7185550400@from-trunk:6] Goto("SIP/americanservices-bc045540", "custom-random-ivr3|s|1") in new stack[/COLOR]
[COLOR=black]-- Goto (custom-random-ivr3,s,1)[/COLOR]
[COLOR=black]-- Executing [s@custom-random-ivr3:1] Dial("SIP/americanservices-bc045540", "Local/009003") in new stack[/COLOR]
[COLOR=black]== Everyone is busy/congested at this time (1:0/0/1)[/COLOR]
[COLOR=black]-- Executing [s@custom-random-ivr3:2] Hangup("SIP/americanservices-bc045540", "") in new stack[/COLOR]
[COLOR=black]== Spawn extension (custom-random-ivr3, s, 2) exited non-zero on 'SIP/americanservices-bc045540'[/COLOR]
[COLOR=black]-- Executing [h@custom-random-ivr3:1] Dial("SIP/americanservices-bc045540", "Local/009009") in new stack[/COLOR]
[COLOR=black]== Everyone is busy/congested at this time (1:0/0/1)[/COLOR]
[COLOR=black]-- Executing [h@custom-random-ivr3:2] Hangup("SIP/americanservices-bc045540", "") in new stack[/COLOR]
[COLOR=black]== Spawn extension (custom-random-ivr3, h, 2) exited non-zero on 'SIP/americanservices-bc045540' [/COLOR]

Another one of the attempted Custom IVR

Code:
[COLOR=black][custom-random-ivr][/COLOR]
[COLOR=black]exten => s,1,Goto(app-miscapps-$[${RAND(1,13)} + 0])[/COLOR]
[COLOR=black]exten => s,n,hangup[/COLOR]

Error
Code:
[COLOR=black]Executing [7185550400@from-trunk:1] Set("SIP/americanservices-bc0161b0", "__FROM_DID=7185550400") in new stack[/COLOR]
[COLOR=black]-- Executing [7185550400@from-trunk:2] Gosub("SIP/americanservices-bc0161b0", "app-blacklist-check|s|1") in new stack[/COLOR]
[COLOR=black]-- Executing [s@app-blacklist-check:1] LookupBlacklist("SIP/americanservices-bc0161b0", "") in new stack[/COLOR]
[COLOR=black]-- Executing [s@app-blacklist-check:2] GotoIf("SIP/americanservices-bc0161b0", "0?blacklisted") in new stack[/COLOR]
[COLOR=black]-- Executing [s@app-blacklist-check:3] Set("SIP/americanservices-bc0161b0", "CALLED_BLACKLIST=1") in new stack[/COLOR]
[COLOR=black]-- Executing [s@app-blacklist-check:4] Return("SIP/americanservices-bc0161b0", "") in new stack[/COLOR]
[COLOR=black]-- Executing [7185550400@from-trunk:3] ExecIf("SIP/americanservices-bc0161b0", "1 |Set|CALLERID(name)=9145551575") in new stack[/COLOR]
[COLOR=black]-- Executing [7185550400@from-trunk:4] Set("SIP/americanservices-bc0161b0", "__CALLINGPRES_SV=allowed_not_screened") in new stack[/COLOR]
[COLOR=black]-- Executing [7185550400@from-trunk:5] SetCallerPres("SIP/americanservices-bc0161b0", "allowed_not_screened") in new stack[/COLOR]
[COLOR=black]-- Executing [7185550400@from-trunk:6] Goto("SIP/americanservices-bc0161b0", "custom-random-ivr|s|1") in new stack[/COLOR]
[COLOR=black]-- Goto (custom-random-ivr,s,1)[/COLOR]
[COLOR=black]-- Executing [s@custom-random-ivr:1] Goto("SIP/americanservices-bc0161b0", "app-miscapps-4") in new stack[/COLOR]
[COLOR=black]== Spawn extension (custom-random-ivr, s, 1) exited non-zero on 'SIP/americanservices-bc0161b0' [/COLOR]


---

Working when dialing 009001 locally from extension 656
Code:
Executing [009001@from-internal:1] NoOp("SIP/656-bc055df0", "Running miscapp 1: IVR1") in new stack
    -- Executing [009001@from-internal:2] Goto("SIP/656-bc055df0", "ivr-9|s|1") in new stack
    -- Goto (ivr-9,s,1)
    -- Executing [s@ivr-9:1] Set("SIP/656-bc055df0", "MSG=custom/IVR1") in new stack
    -- Executing [s@ivr-9:2] Set("SIP/656-bc055df0", "LOOPCOUNT=0") in new stack
    -- Executing [s@ivr-9:3] Set("SIP/656-bc055df0", "__DIR-CONTEXT=") in new stack
    -- Executing [s@ivr-9:4] Set("SIP/656-bc055df0", "_IVR_CONTEXT_ivr-9=") in new stack
    -- Executing [s@ivr-9:5] Set("SIP/656-bc055df0", "_IVR_CONTEXT=ivr-9") in new stack
    -- Executing [s@ivr-9:6] GotoIf("SIP/656-bc055df0", "0?begin") in new stack
    -- Executing [s@ivr-9:7] Answer("SIP/656-bc055df0", "") in new stack
    -- Executing [s@ivr-9:8] Wait("SIP/656-bc055df0", "1") in new stack
    -- Executing [s@ivr-9:9] Set("SIP/656-bc055df0", "TIMEOUT(digit)=3") in new stack
    -- Digit timeout set to 3
    -- Executing [s@ivr-9:10] Set("SIP/656-bc055df0", "TIMEOUT(response)=8") in new stack
    -- Response timeout set to 8
    -- Executing [s@ivr-9:11] Set("SIP/656-bc055df0", "__IVR_RETVM=") in new stack
    -- Executing [s@ivr-9:12] ExecIf("SIP/656-bc055df0", "1|Background|custom/IVR1") in new stack
    -- <SIP/656-bc055df0> Playing 'custom/IVR1' (language 'en')
  == Spawn extension (ivr-9, s, 12) exited non-zero on 'SIP/656-bc055df0'
    -- Executing [h@ivr-9:1] Hangup("SIP/656-bc055df0", "") in new stack
  == Spawn extension (ivr-9, h, 1) exited non-zero on 'SIP/656-bc055df0'

I'll try a few more ideas tomorrow and report back with anything.

thanks!
 

merk

Guru
Joined
Sep 5, 2008
Messages
66
Reaction score
1
Great news! I figured it out by having it dial the IVR directly, I know this is not a fool proof way but it works.

Code:
[custom-random-ivr]
exten => s,1,Goto(acustom-random-ivr-$[${RAND(1,13)} + 0],s,1)
exten => s,n,hangup

[acustom-random-ivr-1]
exten => s,1,Goto(ivr-9,s,1)
exten => s,n,hangup

[acustom-random-ivr-2]
exten => s,1,Goto(ivr-12,s,1)
exten => s,n,hangup

[acustom-random-ivr-3]
exten => s,1,Goto(ivr-13,s,1)
exten => s,n,hangup

[acustom-random-ivr-4]
exten => s,1,Goto(ivr-14,s,1)
exten => s,n,hangup

[acustom-random-ivr-5]
exten => s,1,Goto(ivr-15,s,1)
exten => s,n,hangup

[acustom-random-ivr-6]
exten => s,1,Goto(ivr-18,s,1)
exten => s,n,hangup

[acustom-random-ivr-7]
exten => s,1,Goto(ivr-19,s,1)
exten => s,n,hangup

[acustom-random-ivr-8]
exten => s,1,Goto(ivr-20,s,1)
exten => s,n,hangup

[acustom-random-ivr-9]
exten => s,1,Goto(ivr-21,s,1)
exten => s,n,hangup

[acustom-random-ivr-10]
exten => s,1,Goto(ivr-16,s,1)
exten => s,n,hangup

[acustom-random-ivr-11]
exten => s,1,Goto(ivr-17,s,1)
exten => s,n,hangup

[acustom-random-ivr-12]
exten => s,1,Goto(ivr-11,s,1)
exten => s,n,hangup

[acustom-random-ivr-13]
exten => s,1,Goto(ivr-10,s,1)
exten => s,n,hangup
 

Members online

No members online now.

Forum statistics

Threads
25,835
Messages
167,895
Members
19,259
Latest member
dancosge
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Top