Pre-Dial Handler Return Something Like GOSUB_RESULT?

Home » Asterisk Users » Pre-Dial Handler Return Something Like GOSUB_RESULT?
Asterisk Users 1 Comment

I’m messing around with pre-dialer handlers today and running into a wall.

Dial has the U option where I can execute a Gosub when the channels bridge and there I can set the variable GOSUB_RESULT to BUSY to make Dial act like the channel I called was Busy.

I want to do something similar with a Pre-Dial handler but don’t see a way I can Set a variable or return a value that will cause Dial to act like the channel I called was Busy?

Use case:
Endpoint 100 calls Extension 101

Extension 101 has a Pre-Dial Handler that checks how many calls Endpoint
101 has in progress and if it’s greater than X returns a Busy.

Dial acts like it got a Busy back from the Endpoint, Sets DIALSTATUS and continues through it’s dial-plan.

I’ve tried using the BUSY() Application inside my Pre-Dial handler. I’ve tried sending BUSY back as a Value with Return() to be picked up in GOSUB_RETVAL
I’ve tried setting DIALSTATUS to BUSY.

Am I trying to use the wrong tool for the Job here?

Related, Why can we have multiple Hangup handlers but not Pre-Dial handlers?

One thought on - Pre-Dial Handler Return Something Like GOSUB_RESULT?

  • Why don’t you do the how many calls the endpoint has check before Dial()?
    You can use the LOCK/UNLOCK functions as shown in [1] on the calling channel pre-dial routine to prevent reentrancy issues while doing the check. The called channel pre-dial routine is only to setup the channels you have decided to dial.

    * There is only one dial to execute the called channel pre-dial handler while there are many opportunities to specify hangup handlers.
    * How do you think you could associate different pre-dial handlers to different called channels?