Skip to end of metadata
Go to start of metadata

While not exactly related to auto-attendant menus, we'll introduce some applications to read back various pieces of information back to the caller. The SayDigits() and SayNumber() applications read the specified number back to caller. To use the SayDigits() and SayNumber() application simply pass it the number you'd like it to say as the first parameter.

The SayDigits() application reads the specified number one digit at a time. For example, if you called SayDigits(123), Asterisk would read back "one two three". On the other hand, the SayNumber() application reads back the number as if it were a whole number. For example, if you called SayNumber(123) Asterisk would read back "one hundred twenty three".

The SayAlpha() and SayPhonetic() applications are used to spell an alphanumeric string back to the caller. The SayAlpha() reads the specified string one letter at a time. For example, SayAlpha(hello) would read spell the word "hello" one letter at a time. The SayPhonetic() spells back a string one letter at a time, using the international phonetic alphabet. For example, SayPhonetic(hello) would read back "Hotel Echo Lima Lima Oscar".

We'll use these four applications to read back various data to the caller througout this guide. In the meantime, please feel free to add some sample extensions to your dialplan to try out these applications. Here are some examples:

  • No labels


  1. If one wants to skip SayNumber with DTMF then one solution is to build the string of audio files from the number and use background.

    Using this asterisk logic


    MATH(${number:-5:2} - 11)})])}" >= "2"] & $["${LEN(${number})}" >= "4"]]?
        ${IF($[$["${number:-5:1}"!="0"] & $[${LEN(${number})} >= 5]]?

    ${IF($[$["${LEN($[TRUNC(${MATH(${number:-5:2} - 11)})])}" < "2"] & $["${LEN(${number})}" >= "4"]]?

    ${IF($[${LEN(${number})} >= 3]?

    ${IF($[$["${LEN($[TRUNC(${MATH(${number:-2:2} - 11)})])}" >= "2"] & $[${LEN(${number})} >= 2]]?
        ${IF($[$["${number:-2:1}"!="0"] | $["${number:-1:1}"!="0"]]?
        ${IF($[${LEN(${number})} >= 3]?

    ${IF($["${LEN($[TRUNC(${MATH(${number:-2:2} - 11)})])}" < "2"]?
      ${IF($[${LEN(${number})} >= 3]?

    ${IF($["${LEN(${number})}" = "1"]?

    To build a string. Its also necessary to pass the above code through a filter that removes lines and spaces so the logic is one line only.

    The output of the code needs to be filtered also via the below. This is to removed incorrectly concatenated '&' which the algorithm does not do properly.

    ${SHELL(/bin/echo -en "${number}" | sed -e 's/\&\&/\&/g' | sed -e 's/\&$//g' | sed -e 's/^\&//g' )}

  2. "If the channel variable SAY_DTMF_INTERRUPT is set to 'true' (case insensitive), then this application will react to DTMF in the same way as Background."

    Wouldn't that work better?

    And I may be missing something here, but that's a lot of code to solve a simple problem. It may not be possible in your case,  but this works for me:

    exten => 6,1,Verbose(Context: ${CONTEXT} Exten:${EXTEN})
        same => n,SET(toSay=123456)
        same => n,GoSub(say-catch,${toSay},1)
        same => n,Playback(goodbye)
        same => n,Hangup()

    exten => _X.,1,Dial(Local/${EXTEN}@say-it,,gH)
        same => n,Return()

    exten => _X.,1,Answer()
        same => n,SayNumber(${EXTEN})
        same => n,Hangup()

    From the DIAL info:

    • g - Proceed with dialplan execution at the next priority in the current extension if the destination channel hangs up.
    • H - Allow the calling party to hang up by sending the DTMF sequence defined for disconnect in features.conf.

    So what we're doing here is passing the number as an extension to a context which dials another context, which plays the dialled extension back as a number. As you're listening on a bridged call, you can abandon it at any time. This is a technique I use to abandon hold music, too.

    This seems to be the shortest way I can find. Once those two extra contexts are in your dialplan, you have a simple cancellable saynumber routine with 1 line of code (say-catch,number,1)

    CAVEAT: Only the digit defined in features.conf will cancel it!