Custom Dialplan Help

Hi All

I’m trying to write a custom dialplan, the aim is to do the following:

  • Staff Member calls into the asterisk server
    -Enters a code
    -asterisk calls PHP page (eg, example.php?code=CODEENTERED)
    -php page returns a telephone number
    -asterisk dials the number and connects the calls
    -on hangup from either party the duration of the call is passed to a variable
    -asterisk calls php page with the duration and the code as a variable.

First question, is this possible? Second Question, am I on the right track? I have not included any of the PHP calls yet, but just trying to detect the hangup, but I get an exited on non zero error.

exten => 0066,1,Answer()
exten => 0066,n,Read(UNREF,EnterRef,8) // 8 digit code entered
exten => 0066,n,Dial(******) //SipGate trunk
exten => h,1,Log(DEBUG,SOMONE HUNG UP) // detect hangup from either party
exten => h,n,Hangup() //is this needed?

Thanks in Advance!

Yes you can do this and you are on the right track.

You do not need the Hangup command in the Hangup extension.

Ok thanks at least I know it can be done and I’m going in the right direction,

I have removed the hangup line in the hangup extension.

however, if either party hangs up I get an exited on non zero error and the log entry is not created

Is there something that I am missing? or is this because I am using SIP trunking - I have read that can be an issue sometimes.

Thanks again

If your version of asterisk is new enough I’d try using a Hangup Handler instead of the H extension.

https://wiki.asterisk.org/wiki/display/AST/Hangup+handlers

2 Likes

You sir are a life saver! That worked. Thanks!

1 Like