Question

I feel like this is a simple problem. Perhaps it's so simple that it's never been asked before? I just can not seem to find the answer or figure it out.

The first TwiML that the caller is presented with looks like this.

<Response>
    <Gather action="handle-extension.php" numDigits="3">
        <Play>greatings/maingreating.mp3</Play>
        <!-- Hello, if you know your party's 3 digit extenstion, please dial it at any time or press 0 for the directory. Otherwise, pelase hold while we find someone to take your call.  -->
    </Gather>
    <!-- If customer doesn't input anything, prompt and try again. -->
    <Redirect>handle-queue-main.php</Redirect>
</Response> 

The caller should be able to dial a 3 digit extension and that information should be passed to "handle-extension.php". This works fine, however... if the caller dials "0" for the directory, gather just keeps waiting for an additional 2 digits.

While searching, I did find that apparently you can use "<" and ">" in numDigits like so:

<Gather action="handle-extension.php" numDigits="&lt; 3">

But that gave me the same results as the original code.

Another solution I thought of was to use:

<Gather action="handle-extension.php" numDigits="3" finishOnKey="0">

But that didn't work for extensions that had zero in them (101 sends "1" to the next script, 110 sends "11", etc).

Perhaps the easy solution would be to change the directory extension to #, but quite frankly thats not what I'm looking for.

Any suggestions? Is what I am trying to do even possible?

Thank you for your time! :)

Was it helpful?

Solution

I do not know of a way to do exactly what you are trying to do.

Having said that, here are two easy things you can do:

  • Ask the client to press # after he or she is done entering (with finishOnKey property)
  • Set a timeout instead of the number of digits

Those are the possibilities I would explore. If the person enters more or less than 3 digits I would just catch it with the php check in processing input.

Hope this helps. Sorry for the disappointing answer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top