[asterisk-users] 'h' extension on call-out

Tony Mountifield tony at softins.clara.co.uk
Mon Nov 12 10:52:38 CST 2007


In article <9cbf3f070711120739t1e44a123ga4c1a6aa76177751 at mail.gmail.com>,
Artifex Maximus <artifexor at gmail.com> wrote:
> On Nov 12, 2007 2:04 PM, Tony Mountifield <tony at softins.clara.co.uk> wrote:
> > In article <9cbf3f070711120416v249d0a81s1388fa58b0169287 at mail.gmail.com>,
> >
> > Artifex Maximus <artifexor at gmail.com> wrote:
> > > Hello!
> > >
> > > I would like to store ISDNCAUSE on automatic call-out campaign
> > > (possibly gives more detail on failed call). How is it possible?
> > >
> > > I have tried 'failed' and 'h' extension. No luck. Extension 'failed'
> > > does not know anything about ISDNCAUSE and 'h' extension is not called
> > > at all. Any idea?
> > >
> > > I am using Asterisk 1.2.14 on FC4 if it counts.
> >
> > I think you will find the 'h' extension is only called at the end of
> > a successful call.
> Extension 'h' is executed on every hangup event from both side.

But your experience as described directly contradicts that assertion.

My statement that 'h' is only called at the end of a successful call was
not accurate. It depends how the dialplan is written. The actual condition
is this:

When a channel is hung up, IF and ONLY IF that channel is executing in
the dial plan, the 'h' extension is called in whatever context that
channel is in currently.

> > If the call is unsuccessful, the Dial command will return, and you can
> > then check ${ISDNCAUSE} on the next line of your dialplan.
> There is no dial command because I only wrote a call file to
> /var/spool/asterisk/outgoing and actually dial has been made by
> pbx_spool module. There is a 'failed' extension but no HANGUPCAUSE
> there.

That is why you are not executing the 'h' extension. You are placing
the call directly to a channel. That channel does not start executing
the dial plan until it is answered. In that respect, my original
statement was correct. Because it only starts the dialplan when the
call is successfully answered, there is no context in which to execute
an 'h' extension on a failed call.

You might find it useful to use a Local channel. Instead of doing this:

Channel: Zap/g1/123456789
Context: mycontext
Extension: s
Priority: 1

Try doing this:

Channel: Local/123456789 at outgoing
Context: mycontext
Extension: s
Priority: 1

(replace "mycontext" and "s" with whatever you are using currently)

And in extensions.conf:

[outgoing]
exten => _X.,1,Dial(Zap/g1/${EXTEN})
exten => _X.,n,NoOp(${EXTEN}:DIALSTATUS=${DIALSTATUS};HANGUPCAUSE=${HANGUPCAUSE})

exten => h,n,NoOp(${EXTEN}:DIALSTATUS=${DIALSTATUS};HANGUPCAUSE=${HANGUPCAUSE})

In that case you should find the 'h' in [outgoing] gets executed on both successful
and failed calls.

(Replace "Zap/g1" with whatever channel technology you are using)

Cheers
Tony

-- 
Tony Mountifield
Work: tony at softins.co.uk - http://www.softins.co.uk
Play: tony at mountifield.org - http://tony.mountifield.org



More information about the asterisk-users mailing list