Summary:ASTERISK-02646: [new_app] app_intercept.c
Reporter:Anthony Minessale (anthm)Labels:
Date Opened:2004-10-21 12:05:47Date Closed:2011-06-07 14:05:15
Versions:Frequency of
Environment:Attachments:( 0) app_intercept.c
( 1) app_intercept.diff.txt
Description:This app is an external verison of what *8 does for
Zap channels.

set a var called INTERCEPT_TAG before you dial somewhere
and another channel can execute Intercept(xyz) to take
the unanswered call.

Intercept an unaswered Call.

Intercept([<Channel Name>|<varmatch>|auto])

Intercept an unanswered channel:
A) who's name begins with <Channel Name>
B) Containing the variable INTERCEPT_TAG matching <varmatch>
C) The first encountered unanswered channel if 'auto' was specified.


contributed by Edgewater Networks to the community. www.edgewaternetworks.com
Comments:By: Mark Spencer (markster) 2004-10-23 09:08:22

Why not use the call pickup api, out of curiosity since it's already there?

By: philipp2 (philipp2) 2004-10-28 08:09:55

Very nice! Now, if this could be used to exploit the "press line button to pick-up" SNOM function I think a lot of people would be really happy. Quote:

"[...] You can not pick up a call by hitting the blinking button,  I was going
to do this work but I decided to just train the receptionists to hit *8
instead. I have not studied this extensivly, but to implement it, I
think it would just require asterisk to have support for sip "replaces"
(I don't know if asterisk supports this or not) and the ringing notify
needs to go out with a few more fields.  (It seems that the snom phone
contacts the sip device listed in one of the ring notify message fields
with an invite including a "replaces" header to pick up a call) [...]"


By: twisted (twisted) 2004-10-28 18:34:06

I like this, but THIS:

if (option_verbose  > 2)
"%s Drops Back to Pass, Picked Off by %s! ... The 10 ... the 5 ... Touchdown!!!\n",
newchan->name, chan->name);

should REALLY be changed to something more along the lines of

ast_verbose(VERBOSE_PREFIX_3 "%s Intercepted call destined for %s.\n", chan->name, newchan->name);

IMHO, of course.

By: twisted (twisted) 2004-11-14 21:35:37.000-0600

Hmm... gonna have to prod this one, to bring it back to life.

By: Clod Patry (junky) 2004-11-26 23:21:01.000-0600

This is just to correct some errors in your typos.
Sorry, didn't have time to test it for now. Will do when I'll have more time.

By: Anthony Minessale (anthm) 2004-11-27 09:28:37.000-0600

markster, to answer your question it was so you can assign unique pickup
tags to different inbound calls and have several pickup codes specific
to what tag you intend to intercept

so when a call comes in you set the var INTERCEPT_TAG to a special code
then you setup special dynamic extension to be able to dial the various tags

One Exapmple:

exten => _10XX,1,SetVar(INTERCEPT_TAG=${EXTEN:2})

exten => 1001,n,Dial(Zap/1)
exten => 1002,n,Dial(Zap/2)
exten => 1003,n,Dial(Zap/3)
exten => 1004,n,Dial(Zap/4)

exten => _88XX,1,Intercept(${EXTEN:2})

If you have 4 inbound extensions 1001 1002 1003 1004 and you
see all 4 ringing and you want to only intercept the one on 1004

you can also bind it to a specific channel on say a t1

exten => _88XX,1,Intercept(Zap/${EXTEN:2})

8820 would answer t1 channel 20

and to be a dead ringer for *8 you *could* have

exten => *7,1,Intercept(auto)

This was a bounty app that I reccommend be shared as a condition of
my creating it so take it or leave it it is not that big a deal to me
although other ppl seem to like it.

By: petersv (petersv) 2004-11-27 09:45:41.000-0600

Directed call pickups are nice to have at times. They play nice with pagers for example.

The same functionallity can be provided via the manager interface. It is a bit cumbersome to do it that way instead of through the dialplan like this.

For SIP we have the SUBSCRIBE/REPLACES mechanism for BLF+Directed pickup, but perhaps this function can be used to implement it on mgcp phones? I think I have seen mgcp phones with a lot of buttons and leds.

By: Matthew Marlowe (marlowe) 2004-11-30 11:25:41.000-0600

I seem to be having some issues with this bug.

I have in a macro:

exten => s,1,SetGlobalVar(INTERCEPT_TAG=${ARG3})
(I tried SetVar but it wouldnt work at all taht way.)

$ARG3 is simple a name, like BOB

I have an extension that has Intercept(BOB)

A Call comes in, I dial the intercept(BOB) and get:

   -- Executing Macro("IAX2/gear3tx@gear3tx/11", "stdexten|617|SIP/617|BOB") in new stack
   -- Executing SetGlobalVar("IAX2/gear3tx@gear3tx/11", "INTERCEPT_TAG=BOB") in new stack
   -- Setting global variable 'INTERCEPT_TAG' to 'BOB'
   -- Executing SetVar("IAX2/gear3tx@gear3tx/11", "_ALERT_INFO=<Direct>") in new stack
   -- Executing Playback("IAX2/gear3tx@gear3tx/11", "gear3/transferred|skip") in new stack
   -- Playing 'gear3/transferred' (language 'en')

   -- Executing SetMusicOnHold("IAX2/gear3tx@gear3tx/11", "gear3") in new stack
   -- Executing Dial("IAX2/gear3tx@gear3tx/11", "SIP/617|20|t") in new stack
   -- Called 617
   -- SIP/617-fe47 is ringing

This is where I execute the Intercept...

   -- Executing Intercept("SIP/614-7a8a", "BOB") in new stack
 == No one is available to answer at this time
   -- Executing Goto("IAX2/gear3tx@gear3tx/11", "s-NOANSWER|1") in new stack
   -- Goto (macro-stdexten,s-NOANSWER,1)
   -- Executing VoiceMail("IAX2/gear3tx@gear3tx/11", "u617") in new stack
   -- SIP/617-fe47 Drops Back to Pass, Picked Off by SIP/614-7a8a! ... The 10 ... the 5 ... Touchdown!!!
   -- Attempting native bridge of SIP/614-7a8a and SIP/617-fe47
   -- Playing 'voicemail/gear3/617/unavail' (language 'en')
   -- Hungup 'IAX2/txlink/10'
 == Spawn extension (macro-dialout, s, 8) exited non-zero on 'SIP/614_2-fa74' in macro 'dialout'
 == Spawn extension (internal, 16092521155, 1) exited non-zero on 'SIP/614_2-fa74'
monitor executing ( nice -n 19 soxmix "/var/spool/asterisk/monitor/OUT-16092521155-20041130-123658-in.wav" "/var/spool/asterisk/monitor/OUT-16092521155-20041130-123658-out.wav" "/var/spool/asterisk/monitor/OUT-16092521155-20041130-123658.wav"  && rm -f "/var/spool/asterisk/monitor"/OUT-16092521155-20041130-123658-* ) &
 == Spawn extension (macro-stdexten, s-NOANSWER, 1) exited non-zero on 'IAX2/gear3tx@gear3tx/11' in macro 'stdexten'
 == Spawn extension (mainmenu, 617, 1) exited non-zero on 'IAX2/gear3tx@gear3tx/11'

Immediately after executing the intercept I get the users voicemail altho the originally dialed phone continues to ring.