I have an IVR in the dialplan that Asks the caller to enter an extension if he knows it, otherwise if he presses single digit [1-6]… it executes a corresponding action…
here is it :
[my_context]
exten => s,1(exten_or_menu),Verbose("Now, Play => enter extension number , or 1-6 menu options")
same => n,Gosub(collect_number,s,1(enter_exten_sound_file,*)) ;# Ask the user to enter a sequence of digits terminated by * or time out
same => n,Set(digits_length=$[${LEN(${GOSUB_RETVAL})}])
same => n,Verbose("Collected number <${GOSUB_RETVAL}> , having length of <${digits_length}> digits")
same => n,GotoIf($[${digits_length} = 1]?${digits_length},1:call_ext) ; # execute single digit extension
same => n(call_ext),Set(extension_to_dial=${GOSUB_RETVAL})
same => n,Verbose("multiple digits, consider it an extension to dial : <${extension_to_dial}>")
same => n,Dial(PJSIP/${extension_to_dial})
; #Handle Pressed SINGLE Digit for Menu Option
exten => _[1-6],1, Verbose("Pressed Menu Option # ${EXTEN} , add the caller to <${choosen_queue}> queue...")
same => n,Queue(queue_${EXTEN})
same => n,Verbose("User Got Out of queue_${EXTEN} Queue")
same => n,Goto(rating,s,1)
; # Handle invalid digit pressed (0,7,8,9,*,#)
exten => i,1,Verbose("entered invalid menu option != (1-6)")
.
.
.
now , my problem in ( Dial(PJSIP/${extension_to_dial})
) is when the user enters an extension that is not registered in PJSIP. the dialplan execution terminates and the caller gets disconnected.
I couldn’t find a way to handle that “Exception” caused by Dial application in the dialplan>
Here is a snippet of the CLI debug log:
-- Executing [s@sms_tracking:13] Dial("PJSIP/1001-00000086", "PJSIP/987654") in new stack
[May 23 10:09:31] ERROR[401784]: chan_pjsip.c:2469 request: Unable to create PJSIP channel - endpoint '987654' was not found
[May 23 10:09:31] WARNING[402892][C-00000071]: app_dial.c:2507 dial_exec_full: Unable to create channel of type 'PJSIP' (cause 3 - No route to destination)
== Everyone is busy/congested at this time (1:0/0/1)
-- Auto fallthrough, channel 'PJSIP/1001-00000086' status is 'CHANUNAVAIL'
How this situation can be handled ?