IVR

DTMF stands for Dual Tone Multi-Frequency

Background(prompt1&prompt2&prompt3)
# not to include the file extension(.wav)

plays a sound prompt, but listens for DTMF input.
Asterisk then tries to find an extension in the current dialplan context that matches the DTMF input.

WaitExten(timeout)

Asterisk to wait a few more seconds after playing the sound prompt.

Example

Example 1

# redirect the caller to our menu
exten => 1010,1,Goto(my_menu,s,1)

[auto_attendant]
exten => s,1,Verbose(2,Incoming call from ${CALLERID(number)})
   same => n,Playback(silence/1)
   same => n,Background(prompt1&prompt2&prompt3)
   same => n,WaitExten(10)
   same => n,Goto(timeout-handler,1)
 
exten => timeout-handler,1,Verbose(2,IVR timeout from ${CALLERID(number)})
   same => n,Dial(${GLOBAL(OPERATOR)},30)
   same => n,Voicemail(operator@default,${IF($[${DIALSTATUS} = BUSY]?b:u)})
   same => n,Hangup()

P.S.

s: Start extension

When an analog call comes into Asterisk, the call is sent to the s extension.
   
Example 2

[demo-menu]
exten => s,1,Answer(500)
   same => n(loop),Background(press-1&or&press-2)
   same => n,WaitExten()
 
exten => 1,1,Playback(you-entered)
   same => n,SayNumber(1)
   same => n,Goto(s,loop)
 
exten => 2,1,Playback(you-entered)
   same => n,SayNumber(2)
   same => n,Goto(s,loop)

; Handling Special Extensions

; i: Invalid entry extension
exten => i,1,Playback(option-is-invalid)
   same => n,Goto(s,loop)

; t: Response timeout extension
exten => t,1,Playback(are-you-still-there)
   same => n,Goto(s,loop)
   
P.S.

T: Absolute timeout extension
core show function TIMEOUT

menu with timeout

[my_menu]
exten => s,1,Verbose(2,Incoming call from ${CALLERID(number)})
        same => n,Set(NUMINVALID=0)
        same => n,Set(NUMTIMEOUTS=0)
        same => n(LOOP),Background(thank-you-for-calling)
        same => n,Set(TIMEOUT(digit)=5)
        same => n,Set(TIMEOUT(response)=10)
        same => n,WaitExten(5)

exten => t,1,Verbose(2,IVR timeout from ${CALLERID(number)})
        same => n,Set(NUMTIMEOUTS=$[${NUMTIMEOUTS}+1]})
        same => n,Gotoif($["${NUMTIMEOUTS}" < "3"]?s,LOOP)
        same => n,Background(vm-goodbye)
        same => n,Hangup()

exten => i,1,Set(NUMINVALID=$[${NUMINVALID}+1]})
        same => n,Background(invalid)
        same => n,Gotoif($["${NUMINVALID}" < "4"]?s,LOOP)
        same => n,Playback(vm-goodbye)
        same => n,Hangup()

 

Creative Commons license icon Creative Commons license icon