[asterisk-users] Read & Background

John Millican jmillican at sentinelcommunications.com
Sat Jul 5 10:48:31 CDT 2008


Hello All,

Asterisk 1.4.20.1
SuSE 10.3

I have been building a dial plan and have run into some questions that I
have not been able to answer on Voip-info or google.  I am trying to use
either Read or Background to gather user input to an IVR in a Macro.  I
need to be able to branch based on the user entering the # key or up to
3 digits.  When I use Background I get the # key but am only able to
collect one digit.  If I use Read I can the three digits but the # key
is not recognized.  The system knows that a key was pressed as it exits
the prompt immediately but it then spits out to the CLI that the "user
entered nothing" and the variable uchoice is in fact empty.
What I have had to do is use a combination of both Read and Background,
rather ugly in my opinion.

Macro snipit:

exten => s,n,Read(uchoice|outmessg/greeting|3||1|3);
exten => s,n,GoToIf($[${LEN(${uchoice})}>0]?${uchoice},1);
exten => s,n,Background(outmessg/directory_rotary|m||macro-jm-in);
;have tried the above with and without the m option
exten => s,n,WaitExten(3);

This works but puts an unfortunate pause between the two prompts in
order to give the caller time to decide what they want to do.  I can't
just test for empty/NULL to see if the user hit the # key as I need to
go to operator if the user does nothing which also leaves uchoice set to
nothing.  I have set uchoice to 0 previously in the dialplan but when it
goes through read it gets reset to either the user entry of nothing if
the user does not press a key or presses #.

I would just not use the # key but the prompts were previously recorded
and I need to match prior functionality.

If I could get Read to recognize the # key or Background to accept more
than one digit I would be a much happier camper. Am I missing something?

Am in process of upgrading a test box to 1.4.21.1 to see if there is any
change, but hopes are not high.

Any help is much appreciated.

Thanks,
JohnM




More information about the asterisk-users mailing list