on 01-24-2014 10:46 AM
Hi Geoff,
How do you create a counter in ICM Script to add the queue message number with the prefix "message_" and suffix ".wav"?
Thank you!
You can generate a random number in ICM (look in a Set Variable node at the Formula Editor's Built In Functions there's a function called random() - which returns a random number ibetween 0 and 1 (eg, 0.12464).
You can then use the substr(originalString,startPosition,numChars) function, to grab the 3rd character (the one just to the right of the decimal) returned from random() .
Here's the expression: substr(random(),3,1)
So, to create your audio file names like message_#.wav (where # is between 0 and 9) use: concatenate("message_",substr(random(),3,1),".wav)
If you really wanted to create a 'counter' you just select a variable (like PV10) to use as your 'counter'
Then use these nodes:
1) SetVariable: assign into PV10 the Value: -1 (no quotes) - this is done once.
Now Loop these 3 nodes forever:
2A) SetVariable: assign into PV10 the Value: mod(Call.PeripheralVariable10+1,10) ***NOTE Use mod function to keep the value of PV10 between 0 and 9 - so files are named message_0.wav through message_9.wav
2B)SetVariable: assign into PV9 the Value: concatenate("message_",Call.PeripheralVariable10,".wav")
2C) RunExtScript: PM,-9 (play contents of PV9)
Then through Steps 2A, 2B, 2C again forever until ICM sends the call to the agent.
Hi Janine, thank you very much for your explanation. In the scripting guide, they are saying that mod function takes the n1 value and divide per n2 e.g. mod(n1/n2)
Because in your explanation, the n2 = 10 you are using for a delimit character. I did the test and also works as you told me.
Thank you in advance and for your help!
This is also a nice explanation. But If I have only 4 audios prompts, how can I delimitate the random number to get only number between 0 and 3? I need to use the if node after the random generate a number to see if the number is below <4? If not generate a random number again?
For example:
1.I will use the random expression to generate a random number
2.With a IF node, I will check if the substr(random(),3,1)<=3
3.IF yes, I will concatenate
4.IF not, I will go back to step 1
Is it correct?
I did it and it works, but is it valid to use in a production environment? I have concern to impact the system performance, because almost every call will pass to this validation until we get the substring<=3.
Thank you!
For 0-3, just use trunc(random()*4)
I think it works Paul, but can you explain to me what trunc does?
The manual is so poor
I'd definitely go with Paul's suggestion: For 0-3, just use
trunc(random()*4)
random() returns a number between 0 and 0.999999...
random()*4 returns a number between 0.0 and 3.999999...
trunc(random()*4) returns the whole number portion of the above - so
you'll end up with 0-3
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: