Problems with Directed call Pickup

I have some problems with Directed call Pickup function that is not working in my dialplan, which is rather simple, but includes 2 separate contexts.

This is the basic dialplan:

exten => 105,1,Dial(SIP/105,10,tT)
exten => 106,1,Dial(SIP/106,10,tT)
exten => 197,1,Dial(SIP/197,10,tT)

exten => 100288506,1,Dial(SIP/197,30,tT)

The “internal-calls” context is used for all inter-extension calls, “from-trunk” context is used for all calls to and from the VoIP provider. All the extensions have defined the same callgroup and pickupgroup parameters in sip.conf.

Group call pickup is defined in features.conf as ** and works perfectly for internal (between extension) and incomming (from VoIP provider) calls.

Directed call pickup feature is defined in extensions.conf like:

exten => _**.,1,Pickup(${EXTEN:2}@internal-calls)
exten => _**.,n,Pickup(${EXTEN:2}@from-trunk)

The idea is when I see a ringing extension, I can use Directed call pickup feature by dialing **exten_num. I do not want to use Group call pickup.

Directed call pickup works perfectly for internal calls (between extensions), but for incomming calls (from VoIP provider) I get a following error (I dial **197 from ext. 106):

    -- Executing [**197@internal-calls:1] Pickup("SIP/106-000013dd", "197@internal-calls") in new stack
[Feb 16 18:31:35] NOTICE[16177]: app_directed_pickup.c:297 pickup_exec: No target channel found for 197.
    -- Executing [**197@internal-calls:2] Pickup("SIP/106-000013dd", "197@from-trunk") in new stack
[Feb 16 18:31:35] NOTICE[16177]: app_directed_pickup.c:297 pickup_exec: No target channel found for 197.
    -- Auto fallthrough, channel 'SIP/106-000013dd' status is 'UNKNOWN'

I really do not uderstand why is this happening.

I have browsed the internet and that was one of the solutions that should be working as expected.

Alternative 1
One more solutions would be re-defining the Directed pickup extension to:

exten => _**.,1,Set(GLOBAL(PICKUPMARK)=${EXTEN:2})
exten => _**.,n,Pickup(${EXTEN:2}@PICKUPMARK)

This solution works for internal and incomming calls, but behaves like Group pickup. It does not matter which extension you put after **, it picks up the ringing extension either way. For instance, I can pick up a ringing extension 197 by dialing **103. This is not a good solution.

Alternative 2

One more option to use PICKUPMARK in a different way:

exten => 105,1,Dial(SIP/105,10,tT)
exten => 106,1,Dial(SIP/106,10,tT)
exten => 197,1,Dial(SIP/197,10,tT)

exten => 100288506,1,Set(__PICKUPMARK=197)
exten => 100288506,n,Dial(SIP/197,30,tT)

exten => _**.,1,Pickup(${EXTEN:2}@PICKUPMARK)

With this code, Direct call pickup also works. But it also means defining PICKUPMARK for every DID, which is not very cool for me. I would prefer a different solution.

Alternative 3

One more thing is that the Direct call pickup is working fine if I have this dialplan:

exten => 105,1,Dial(SIP/105,30,tT)
exten => 106,1,Dial(SIP/106,30,tT)
exten => 197,1,Dial(SIP/197,30,tT)

exten => 100288506,1,Goto(internal-calls,197,1)

exten => _**.,1,Pickup(${EXTEN:2}@internal-calls)

Since I want 2 different behaviors for incomming calls for a DID (from PSTN) and for and extension (internal call), this solutions is also not an option.

My wish is to use this dialplan and have Directed call pickup working:

exten => 105,1,Dial(SIP/105,30,tT)
exten => 106,1,Dial(SIP/106,30,tT)
exten => 197,1,Dial(SIP/197,30,tT)

exten => 100288506,1,Dial(SIP/197,30,tT)

exten => _**.,1,Pickup(${EXTEN:2}@internal-calls)

In all logic this should work, but it does not. Is this a software bug or am I missing something?

I am seeing the same behaviour on Asterisk and

Directed call pickup sounds like a very basic thing and I am surprised that it is not working as expected.

Does anybody have any good insight about the PICKUPMARK variable?

I am still not sure if this is an issue for the bug tracker. I do not know about you, but I find that Directed call pickup without PICKUPMARK variable does not work when the “source call” comes in on a different context than the call for call pickup.

The user Gatozero suggested the use of PickupChan(). It turns out that it works much better than Pickup() app.

My new code for directed call pickup is now:

The PickupChan() works for:

  • the issues with call inter-contex call routing, which Pickup() apparently has
  • directed call pickup of a call to a ring group (with PickupChan(), you can pickup a call to a ring group with picking up a ringing call on only one of the extension of the ring group - this is also a thing that a lot of users can not do with Pickup())

So all looks like PickupChan() is a much better alternative than Pickup(). It just fixes all the problems and limitation that Pickup() app has always had (one of the things was not being able to pickup a ring group call by just trying to pick up one of the ringing phones from the ring group).

I am also struggling with directed call pickup, your last solution with pickupchan is
nice, only one thing- did you notice that you have missed call on phone from which
call was picked up? And one more thing, after call pickup there is channel zombie
left after nobody answer at phone B. But thing with missed call is thing I would
like to solve. If you made call pickup with *8 (group pickup) you will see that you
wont have missed calls on B phone.

Update: missed calls defends on phones and their sf/fw, but still there is
exited non-zero on 'SIP/511-0000008e
where SIP/511 was B number, but I guess it doesnt matter.

What version of asterisk are you using?

I think I tried my original call pickup setup in some later versions of Asterisk (I think arround 1.8.14) and I did not replicate the problem on that version. I did a really quick test there, so I am not 100%, but I think the problem already got resolved.
but I think that “zombie” problem is not important


in asterisk 13 the same problem.
reliable direct call pickup impossible.
if i want to pick up a call, sometimes i picked up an outgoing call from an other user.

Are there new solutions for direct call pick up?

The original problem was one of confusing extensions and devices. To pick up the call he would have needed to dial **100288506 not **197.

Unless you have the same problem, which is user error, not unreliability, you need to provide more information.

following problem:

Call1: employee A (Number: 200) (Context A, Pickup/Callgroup 1) -> Try to call external with sip-provider (Number: 012345678)

Call2: employee B (Number: 300) (Context A, Pickup/Callgroup 1) -> Calls Employee C (Number: 400) (Context B, Pickup/Callgroup 2)

Call3: Employee D (Number: 500) (Context B, Pickup/Callgroup 2) try to pick up with **400 call from employee C. But now Employee D call with employee A!!!

Call 2 continues


exten => _**.,1,SET(GLOBAL(PICKUPMARK)=${EXTEN:2})
exten => _**.,n,Pickup(${EXTEN:2}@PICKUPMARK)

asterisk cli with the wrong call pick up:

    -- Executing [**400@contextb:1] NoOp("SIP/employeed-000015e2", "employeed 500 pick up 400") in new stack
    -- Executing [**400@contextb:2] Set("SIP/employeed-000015e2", "GLOBAL(PICKUPMARK)=400") in new stack
  == Setting global variable 'PICKUPMARK' to '400'
    -- Executing [**400@contextb:3] Pickup("SIP/employeed-000015e2", "400@PICKUPMARK") in new stack
       > 0x7f86902a29d0 -- Probation passed - setting RTP source address to
   -- SIP/employeed-000015e2 answered SIP/employeea-000015d8

Now employee d calls with employee a. but employee a had tried to call extern with sip-provider but this call was ended.
call 2 continue. Telephone of Employee C is ringing.

I use realtime for all extensions. I have a table with extensions that are allowed to pick up other extensions. My extensions are 5 digits, and I use a soft-key with BLF for the pickup. Here’s the code I use.


;Pickup Or Dial
exten 	=> _*8ZXXXX,1,NoOp(${EXTEN:2:5} ${DEVICE_STATE(SIP/${EXTEN:2:5})})
same	=> n,Set(canpickup=${ODBC_READSQL(select count(*) from pickup where extension='${EXTEN:2:5}' and allowed_exten='${CALLERID(num)}')})
same	=> n,GotoIf($["${canpickup}"="0"]?dial)

same	=> n,GotoIf($["${DEVICE_STATE(SIP/${EXTEN:2:5})}"="RINGING"]?pickup:dial)
same	=> n(pickup),Pickup(${EXTEN:2:5}@PICKUPMARK)
same	=> n,Hangup()
same	=> n(dial),GoSub(subInternalDialer,s,1(${EXTEN:2:5},20))
same	=> n,Hangup()


;Used soley for internal dialing of 3, 4, or 5 digit numbers

exten	=> s,1,NoOp()
same	=> n,Set(thishost=${SYSTEMNAME})
same	=> n,Set(ARRAY(cluster,ext,devicetype,devopt,vmbox)=${ODBC_READSQL(select ext_cluster\, ext_dialed\, ext_dev_type\, ext_options\, ext_vm_box from extensions where ext_dialed='${ARG1}')})
same	=> n,Set(lockout=${ODBC_READSQL(select ext_lockout from extensions where ext_dialed='${CALLERID(num)}')})
same	=> n,Set(canbepickedup=${ODBC_READSQL(select count(*) from pickup where extension='${ARG1}')})

same	=> n,GotoIf($["${canbepickedup}"="0"]?skippickupmark)
same	=> n,Set(__PICKUPMARK=${ARG1})

same	=> n(skippickupmark),GotoIf($["${devicetype}" = ""]?invalidext)

same	=> n,GotoIf($["${lockout}" = "1"]?lockout)

same	=> n,GotoIf($["${cluster}" != "${SYSTEMNAME:0:-2}"]?remoteSystem)

same	=> n,GotoIf($["${devicetype}" = "autoattendant"]?autoattendant,s,1)
same	=> n,GotoIf($["${devicetype}" = "confbridge"]?confbridge,s,1)
same	=> n,GotoIf($["${devicetype}" = "hotdesk"]?hotdesk,s,1)
same	=> n,GotoIf($["${devicetype}" = "intercom"]?intercom,s,1)
same	=> n,GotoIf($["${devicetype}" = "phone"]?phonedial)
same	=> n,GotoIf($["${devicetype}" = "queue"]?queues,s,1)
same	=> n,GotoIf($["${devicetype}" = "queuelogin"]?queue_login,s,1)
same	=> n,GotoIf($["${devicetype}" = "ringgroup"]?ringgroup,s,1)
same	=> n,GotoIf($["${devicetype}" = "voicemail"]?voicemail,s,1)

same	=> n(phonedial),NoOp(${ARG1})
same	=> n,Dial(SIP/${ext},${ARG2},${devopt})
same	=> n,NoOp(${DIALSTATUS})
same	=> n,Goto(s-${DIALSTATUS},1)
;Need to add logic for voicemail
same	=> n,Voicemail(${vmbox}@from-internal-sip,us)
same	=> n,Hangup()

same	=> n(remoteSystem),Dial(SIP/${cluster}/${ARG1},${ARG2},${devopt})
same	=> n,Hangup()

same	=> n(lockout),Festival(This line has been locked out of the system)
same	=> n,Hangup()

same	=> n(invalidext),Return()

exten	=> s-BUSY,1,Festival(This line is busy)
same	=> n,PlayTones(busy)
same	=> n,Busy(5)
same	=> n,Hangup()
exten	=> s-NOANSWER,1,Festival(This line was not answered)
same	=> n,Hangup()
exten	=> s-CANCEL,1,Festival(This line was ended before the callee picked up)
same	=> n,Hangup()
exten	=> s-CONGESTION,1,Festival(This line has congestion)
same	=> n,Hangup()
exten	=> s-CHANUNAVAIL,1,Festival(This line is not available)
same	=> n,Hangup()
exten	=> s-DONTCALL,1,Festival(This line is rejected by the callee)
same	=> n,Hangup()
exten	=> s-TORTURE,1,Festival(This line was sent to the torture menu)
same	=> n,Hangup()
exten	=> s-INVALIDARGS,1,Festival(This line has invalid arguments)
same	=> n,Hangup()

exten	=> i,1,Hangup()
exten	=> t,1,Hangup()
exten	=> h,1,Hangup()

;;;exten => _10XXX,hint,park:${EXTEN}@parkedcalls
exten => _ZXXXX,hint,SIP/${EXTEN}

exten	=> _10XXX,hint,Custom:${EXTEN}@hints
exten	=> _10XXX,1,NoOp(Parking for ${EXTEN} State: ${DEVICE_STATE(Custom:${pos}@hints)})
same	=> n,Set(lot=locallot)
same	=> n,Set(pos=${EXTEN})
same	=> n,Set(PARKINGEXTEN=${pos})

same	=> n,GotoIf($["${DEVICE_STATE(Custom:${pos}@hints)}"="RINGING"]?pickup:park)

same	=> n(park),Set(DEVICE_STATE(Custom:${EXTEN}@hints)=RINGING)
same	=> n,Park(${lot})
same	=> n,Hangup()

same	=> n(pickup),Set(DEVICE_STATE(Custom:${pos}@hints)=INUSE)
same	=> n,ParkedCall(${lot},${pos})
same	=> n,Hangup()

exten	=> i,1,Hangup()
exten	=> t,1,Hangup()
exten	=> h,1,Set(DEVICE_STATE(Custom:${pos}@hints)=NOT_INUSE)
same	=> n,Hangup()
parkeddynamic = yes 

findslot => first
;parkinghints => yes
parkingtime => 300 
comebacktoorigin => yes
parkedcalltransfers => both
parkedcallreparking => both

context => parkedcalls
parkext => 10000
parkpos => 10001-10999
asterisk.pickup table (11000 is allowed to pick up 12000 or 13000 if they're ringing)
extension 	allowed_exten
12000 	        11000
13000 	        11000


set a channel variable in the incoming context:

exten => _XXX,1,Set(__PICKUPMARK=${EXTEN})
same => n,Dial(SIP/${EXTEN})

exten => 123454678,1,Set(__PICKUPMARK=200)
same => n,Dial(SIP/200)

exten => _**X.,1,Pickup(${EXTEN:2}@PICKUPMARK)