简体   繁体   中英

Asterisk hangs up if caller inputs number early

We have an Asterisk IVR system setup that prompts the user for input

In our extensions file, we have the following:

[englishprocess]
exten => s,1,Answer()
exten => s,n,Wait(1)
exten => s,n,Set(TIMEOUT(digit)=2)
exten => s,n,agi(mstts.agi,"Please enter your ID number followed by pound.",en-US)
exten => s,n,Read(APCODE,,666)
exten => s,n,agi(mstts.agi,"Your ID Number is",en)
exten => s,n,SayDigits(${APCODE})
exten => s,n,agi(mstts.agi,"If this is correct press, 1, otherwise, press, 3",en-US)
exten => s,n,Read(CHECK,,1)
exten => s,n,GotoIf($["${CHECK}" = "3"]?englishprocess,s,1)
exten => s,n,Set(MYADDR=${CURL(webserviceaddress.php?idnum=${APCODE})})
exten => s,n,agi(mstts.agi,${MYADDR},en-US)
exten => s,n,Hangup()

The problem is that if the user inputs their ID before the text to speech prompt finishes, or if they hit 1 before it finishes saying

"If this is correct press, 1, otherwise, press, 3"

The service hangs up.

How can we keep the process the same and accept early user input?

If accepting user input early is not possible is there a way to prevent hangup and prompt again?

We switched to Amazon's Polly service to generate the sound files and used the asterisk method Playback(filename) instead of agi() inside of extensions_custom.conf in order to stop the call from hanging up if the user inputs text prematurely.

Granted the service ignores the inputs that are put in early, but at least it does not hang up. A better solution would accept early input. I'll update this if I find an alternative.

Edit: Found an alternative Read() which lets us play soundbites that can be interrupted, so we now have a mix of Read() and playback() calls and can control which sound files can be skipped by the user in this way. The service no longer hangs up on users and we no longer use agi() calls.

agi(mstts.agi,"text",[language],[intkey],[speed]) :

intkey is used if the user enters anything the script will stop and go to that extension. I don't know if it will work in your case but worth a try.

exten => _X,1,agi(mstts.agi,"You just pressed ${EXTEN}. Try another one please.",en,any) Try using the ,any after the language and see if that works. I got that example from https://github.com/zaf/asterisk-mstts

Asterisk Dialplan cannot by use seriously to create dynamic services with intensive TextToSpeech.

  • First because the latency could be an issue if you don't use a cache, or if you don't use an MRCP connector.
  • Secondly because by this way you not support the bargein ( https://www.w3.org/TR/voicexml20/#dml4.1.5 ) and you lost the way to interact with DTMF (or voice) at any moment.

To create a Voice Portal, you probably need a VoiceXML interpreter. You have 2 ways to create this service in an Asterisk : Voximal a commercial application running over and Asterisk, or VoiceGlue a free GPL dead project (you can run it over old Asterisk).

Look into this line:

print "STREAM FILE $file \"$keys\"\n";

https://www.voip-info.org/wiki/view/stream+file

 Usage: STREAM FILE <filename> <escape digits> [sample offset]

Send the given file, allowing playback to be interrupted by the given digits, if any.

Use double quotes for the digits if you wish none to be permitted.

If sample offset is provided then the audio will seek to sample offset before play starts.

Remember, the file extension must not be included in the filename.

After that it for some reason work like waitexten and change extension. I have no idea who and why added that to code, you can ask maintainer.

So just read files you use, not spam questions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM