[asterisk-users] Simple(?) dialplan question.

Steve Murphy murf at parsetree.com
Sun Mar 22 10:01:42 CDT 2009


On Sun, Mar 22, 2009 at 4:09 AM, Asterisk <asterisk at solutionengineers.com>wrote:

> Hi List,
>
> I have a nice simple dialplan question for you.... Currently, I have
> definitions similar to the following in my extensions.conf file, to allow
> me
> to dial out using a variety of channels:
>
>        ; Direct dial (number starts with zero), use 0151 xxx xxxx:
>        exten => _0.,1,Set(CALLERID(number)=0845xxxxxxx)
>        exten => _0.,n,Dial(SIP/${EXTEN}@sipgate,90,t)
>        exten => _0.,n,Playback(invalid)
>        exten => _0.,n,Hangup[/code]
>
> (I've munged some of the numbers, hence the x's)
>
> Now, this works fine provided the person answers in 90 seconds or less: If
> not, I get "that option is invalid" announced, and it hangs up. I want to
> do
> this:
>
> If DIAL fails because the other party is engaged, I'd like Asterisk to
> automatically re-try the number, for as long as I've got the handset off
> the
> hook or until the other party starts ringing. As there'll be no ring tone,
> it'd be nice it it could play music until DIAL succeeds in getting a ring
> tone; at which point it makes "ring ring" noises (this will serve as my
> prompt that - hopefully - someone's going to answer soon).
>
> If DIAL fails because I got the number wrong, then a PLAYBACK to that
> effect
> would be useful... I can record my own soundfile if there isn't a standard
> one. By wrong, I mean the exchange would return number unavailable, rather
> than I get the wrong person!
>
> If DIAL fails after it's been ringing for ages (e.g. when calling the local
> Post Office sorting office, who only answer 1 in 5 calls), I'd like it to
> retry, ala the busy response.
>
> IF DIAL exits because the other party hung up, I'd want it to simply hang
> up
> on me like it does now. I suspect this is standard behaviour? But maybe it
> tries to read the invalid announce to a closed channel with my dialplan,
> I'm
> not sure.
>
> If the above can be achieved in extensions.conf, that's great, as I've not
> done any AEL... but if AEL (or AGI, even) is the only way, so be it...


You can do it all three ways.

In AEL, you'd do something like this

context internalexten
{
   _0. => {
                Set(prevstatus=NOANSWER);  /* set up a prevstatus */
                Set(CALLERID(number)=0845xxxxxxx);
                while("${prevstatus}" == "NOANSWER" || "${prevstatus}" ==
"BUSY")
                {
                    Dial(SIP/${EXTEN}@sipgate,90,tm); /* transfers and moh
*/
                    switch(${DIALSTATUS})
                    {
                      case CHANUNAVAIL:
                             Playback(bad_num);
                             hangup();
                             break;
                      case CONGESTION:
                             Playback(congested);
                             hangup();
                             break;
                      case BUSY:
                      case NOANSWER:
                              break; /* BUSY will fall thru into NOANSWER */
                      default:
                              break;
                    }
                    Set(prevstatus=${DIALSTATUS});
                 }
                 hangup();
              }
}

The above code should (I haven't tested it or anything) give you most of the
behavior you
specified, but it will play MOH up to the time someone answers. No
ringing/moh mixture...
Dial doesn't do that. You may have to correct some typos, etc. that I've
made above!

A hangup from the remote end will end the Dial app, and the result should be
ANSWER,
which should drop you out of the loop and end the call.

Also, a hangup from the dialing exten should just terminate the dialplan
execution.

I might note that the above code should be easier to read than the equiv
extenstions.conf
code!  But, I guess I'm biased!

murf


-- 
Steve Murphy
ParseTree Corp
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20090322/15eb982d/attachment-0001.htm 


More information about the asterisk-users mailing list