Asterisk 21. How to handle not answered incoming call to Queue/ IVR / Endpoint?

I want to handle not answered call to Queue/ IVR / Endpoint and continue to my Stasis application [stasis-incoming] without hang-up the call (channel). How can I do that?
Here’s my dailplan:

[DCS-Incoming]
include = stasis-incoming

[stasis-incoming]
exten => _X.,1,Stasis(stasis-incoming-app)

[generalIncoming]
exten => s,1,NoOp(general-incoming: RECORDING_FILENAME=${RECORDING_PATH_FILE})
same => n,Set(CALLERID(NAME)=${CUSTOM_CALLER_ID})
same => n,MixMonitor(${RECORDING_PATH_FILE},a,${MIXMON_POST})
same => n,NoOp(general-incoming: finished)
same => n,Return(${EXTEN})

[queue]
exten => _X.,1,GoSub(generalIncoming,s,1)
same => n,Answer()
same => n,Queue(${QUEUE_NAME},,,,120)
same => n,Hangup()

[endpoint]
exten => _X.,1,GoSub(generalIncoming,s,1)
same => n,Dial(PJSIP/600)
same => n,Hangup()

[IVR]
exten => _X.,1,GoSub(generalIncoming,s,1)
exten = _X.,n,Verbose(1, "New caller, ${CALLERID(num)} dialed into the IVR.")
 same = n,Answer()
 same = n(start),Background(basic-pbx-ivr-main)
 same = n,WaitExten(10)
 same = n,Background(basic-pbx-ivr-main)
 same = n,Hangup()

To handle unanswered calls to a Queue, IVR, or Endpoint and continue to your Stasis application without hanging up the call, you can modify your dialplan as follows:

[DCS-Incoming]
include = stasis-incoming

[stasis-incoming]
exten => _X.,1,Stasis(stasis-incoming-app)

[generalIncoming]
exten => s,1,NoOp(general-incoming: RECORDING_FILENAME=${RECORDING_PATH_FILE})
same => n,Set(CALLERID(NAME)=${CUSTOM_CALLER_ID})
same => n,MixMonitor(${RECORDING_PATH_FILE},a,${MIXMON_POST})
same => n,NoOp(general-incoming: finished)
same => n,Return(${EXTEN})

[queue]
exten => _X.,1,GoSub(generalIncoming,s,1)
same => n,Queue(${QUEUE_NAME},120) ; Set a timeout for unanswered calls
same => n,Stasis(stasis-incoming-app) ; Continue to Stasis application
same => n,Hangup()

[ivr]
exten => _X.,1,GoSub(generalIncoming,s,1)
same => n,Background(your_ivr_menu) ; Use your IVR menu here
same => n,Stasis(stasis-incoming-app) ; Continue to Stasis application
same => n,Hangup()

[endpoint]
exten => _X.,1,GoSub(generalIncoming,s,1)
same => n,Dial(PJSIP/600)
same => n,Stasis(stasis-incoming-app) ; Continue to Stasis application even if unanswered
same => n,Hangup()

In the above dialplan:

  • For the Queue section, after the Queue application, you directly go to the Stasis application. This ensures that whether the call is answered by an agent in the queue or not, it proceeds to your Stasis application.
  • For the IVR section, after playing the IVR menu, it goes directly to the Stasis application.
  • For the Endpoint section, after the Dial application, it proceeds to the Stasis application regardless of whether the call is answered or not.

you can handle hangup event and do everything you need

see that blog:

Thanks for your help. I’ve changed the context. Now my problem is recognize whether the call declined or unanswered. In the fallowing scenario:

  1. Call unanswered, HANGUPCAUSE=0:
    – Nobody picked up in 10000 ms
    – Executing [972211111111@endpoint:3] Set(“PJSIP/dcs-endpoint-00000197”, “HANGUPCAUSE_STRING=PJSIP/600-00000198”) in new stack
    – Executing [972211111111@endpoint:4] NoOp(“PJSIP/dcs-endpoint-00000197”, “Finished 0:PJSIP/600-00000198”) in new stack
    – Executing [972211111111@endpoint:5] HangupCauseClear(“PJSIP/dcs-endpoint-00000197”, “”) in new stack
    – Executing [972211111111@endpoint:6] Gosub(“PJSIP/dcs-endpoint-00000197”, “stasis-incoming,972211111111”) in new stack

  2. Call declined, HANGUPCAUSE=17:
    == Everyone is busy/congested at this time (1:1/0/0)
    – Executing [972211111111@endpoint:3] Set(“PJSIP/dcs-endpoint-00000197”, “HANGUPCAUSE_STRING=PJSIP/600-00000199”) in new stack
    – Executing [972211111111@endpoint:4] NoOp(“PJSIP/dcs-endpoint-00000197”, "Finished 17:PJSIP/600-00000199") in new stack

  3. Call unanswered, HANGUPCAUSE=17:
    – Nobody picked up in 10000 ms
    – Executing [972211111111@endpoint:3] Set(“PJSIP/dcs-endpoint-00000197”, “HANGUPCAUSE_STRING=PJSIP/600-0000019a”) in new stack
    – Executing [972211111111@endpoint:4] NoOp(“PJSIP/dcs-endpoint-00000197”, “Finished 17:PJSIP/600-0000019a”) in new stack

HANGUPCAUSE =17 not cleared, despite I use same => n,HangupCauseClear()

[endpoint]
exten => _X.,1,GoSub(generalIncoming,s,1)
same => n,Dial(PJSIP/${LOCAL_EXTENSION},10)
same => n,Set(HANGUPCAUSE_STRING=${HANGUPCAUSE_KEYS()})
same => n,NoOp(Finished ${HANGUPCAUSE}:${HANGUPCAUSE_STRING})
same => n,HangupCauseClear()
same => n,GoSub(stasis-incoming,${EXTEN},1)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.