login | register
Thu 16 of Oct, 2008 [04:09 UTC]

voip-info.org

History

Asterisk cmd Pickup

Created by: JustRumours,Last modification on Thu 14 of Aug, 2008 [12:38 UTC] by jperez

Pickup

Asterisk now comes with its own directed Pickup application, see bug 4865. This will conflict with the bristuff app_pickup. Therefore the current version of bristuff (0.3) changed the name of this application to DPickup.

Synopsis

 Pickup(extension[@context])

Description

This dialplan command allows you to pick up calls that are ringing a specific extension. The device which is ringing need not have callgroup or pickupgroup set, you just need to know the extension.
This application also allows you to specify partial extensions. For example, you have block 200 to 209 and you want to pick up any calls that my be ringing on those 10 phones, you just pickup 20 and it'll pick up the most recent ringing one. Another side effect is that you can pickup a call that a person might be making for an outbound call... rather cool :-)
An example for the dialplan is below, and installation can be accomplished by using astxs or manually modifying the Makefile.


New in Asterisk v1.4

If you use the special string "PICKUPMARK" for the context parameter, for example 10@PICKUPMARK, this application tries to find a channel which has defined a channel variable name PICKUPMARK with the same content as "extension".

So, if you a SET(GLOBAL(PICKUPMARK)=1234) in extension 123, the PickUp(1234@PICKUPMARK) will try to pick extension 123. See example below.


jperez: Warning Using a global variable seems like an awfull error to me. Every call made to extension 1234, 1235, etc will overwrite the global variable and so only the last call made to an extension can be picked up. I have tried in version 1.4.21.1 other way that works and uses channel variables, but you must pay attention to variable inheritance. So, in the dialplan you must implement pickup logic like:

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

Don't set PICKUPMARK in the "extension" _*8. like in the example given below, that's nonsense. You should set the channel variable when making a call to the extension, something like:

exten => 1234,1,Set(__PICKUPMARK)=1234
exten => 1234,n,Dial(...)

Please take note of the two underscores before the variable name. That means "inherit unlimited depth". You should be using macros to define extensions, so better add that line to the macro. If you do so, your pickup logic will work seamlessly.

This is my first post so please feel free to edit this and correct it. I think someone more knowledgeable should edit the whole post and delete the misleading info. This has taken me a while to grasp, I hope that you find it usefull.


See bug/patch 5694:
Modified the Pickup application to accept multiple extensions pickup syntax,like

 Pickup(extension1&extension2&...)

For example,

 Pickup(601&602&603)

will try to pickup extension 601, 602, 603 sequentially, if one of them is in ringing state.


Example

 exten => _7.,1,Pickup(${EXTEN:1}@default)

 If phone with number 42 rings you can catch the call by dialing 742. You don't need to use the context, 
 exten => _7.,1,Pickup(${EXTEN:1}) works for all contexts.

Example using PICKUPMARK for Asterisk 1.4

 ; This configuration uses *8xxx to pickup extension xxx, so need to strip the first two digits of the extension
 exten => _*8.,1,SET(GLOBAL(PICKUPMARK)=${EXTEN:2})
 exten => _*8.,n,Pickup(${EXTEN:2}@PICKUPMARK)


Bristuff

Bristuff introduced its own Pickup application before Asterisk had its own (see Asterisk cmd BristuffPickup ). The Asterisk Pickup version is therefore renamed to DPickup in Bristuff >= 0.3.

Remark:

This command pickups up the dialed EXTENSION, not the ringing channel/device.
So when the dialplan says;

 200,1,Dial(SIP/100&SIP/101)

And someone calls extension 200
The call cannot be picked up by using Pickup(100@default) or Pickup(101@default)
But needs to be picked up using Pickup(200@default)

The context however is NOT mandatory

Multiple context pickup


If you have multiple contextes where calls are incomming,
for example external (for calls from outside) and internal (for internal calls),
you can use following pickup setup to get the pickup working:

 exten => _71XXX,1,Pickup(${EXTEN:2}@external)
 exten => _71XXX,2,Pickup(${EXTEN:2}@internal)

In the example above, you can pickup a caller from outside,
who is calling an extension (and going into the context external),
and also you can pickup a caller from internal call.

Troubleshooting


See also



Go back to Asterisk - documentation of application commands


Comments

Comments Filter
222

333Pickup() return value?

by diepiapaopolopo, Thursday 12 of July, 2007 [20:08:09 UTC]
Is there any kind of state that can be detected and acted upon if Pickup() fails? (i.e., the channel wasn't ringing) I've tried adding an n+101 priority, an i priority, and an n+1 priority, but none of them are ever reached.
222

333Pickup bug has Mantis number ?

by olivier2831, Tuesday 12 of September, 2006 [16:45:02 UTC]
Hi Roberto,
Is your bug referenced in Mantis ?

222

333Pickup bug

by rubbermaiden, Thursday 26 of January, 2006 [17:45:12 UTC]
Hy Henrik. I also tried to use the Pickup command and after strugglying a little bit in the source code. I found that is an error, please edit the app_directed_pickup.c and search for the following line:
>>> if (target && (!target->pbx) && target->_state == AST_STATE_RINGING) ) {
Then replace the whole line with:
>>> if (target && (!target->pbx)) {
I don't know why but the target->_state is always 0 causing the code target->_state == AST_STATE_RINGING) to always return 0 and never pickup the call.
And recompíle the Asterisk source.

Another comment, whe the command description says that it matches partial extensions this is not true. Searching in the code I saw that it uses the function: ast_get_channel_by_exten_locked and this function calls another function channel_find_locked(NULL, NULL, 0, context, exten), this parameters dictates that this function will match only by context and extension using the strcasecmp. The strcasecmp will return 0 only if the exact extension matches.

Please change your extensions.conf to:
exten => _*8.,1,Pickup(${EXTEN:2}@incoming)

And now dial *8xxxx (xxxx is the exact extension number that is ringing).

I hope this helps .

222

333Re: Using Pickup extension

by rubbermaiden, Thursday 05 of January, 2006 [17:39:14 UTC]
Please read my Pickup bug and try it. Thanks.
222

333Using Pickup extension

by henrikost, Sunday 09 of October, 2005 [18:59:43 UTC]
I'm trying to use the Pickup application using CVS HEAD:


exten => _*8XXX,1,Pickup(${EXTEN:2}1@incoming)


but I'm not able to pickup anything..:
   — Executing Pickup("OH323/sb...@192.168.2.5-ea9329af", 
"011@incoming") in new stack
 == Spawn extension (from-internal, *8011, 1) exited non-zero on 
'OH323/sb...@192.168.2.5-ea9329af'
   — Hungup 'OH323/sb...@192.168.2.5-ea9329af' 


The incomming call I try to pickup is on extension 011 calling 0111 on
a H323 device (using the OH323 driver). The H323 works otherwise fine,
in and outgoing, incl transfer.


I have tried both picking up extension 011 and 0111, with and without
the context incoming, which is the context the incoming call should be
in... No luck.


I'm running CVS HEAD of today on a Debian Sarge stable.


By the way, when I get it to work, how do I pick up a call when I dont
know the extension? Can I search possible extesions for one which
should be possible to pickup or can I use wildcards (_01.)?