[solved] Need help in parking macro

Hi there,
In order to avoid the need for an explicit parked extension number to be communicated to the expected destination, i was expecting to use the ParkAndAnnounce application to call the recipient and inform him of the same.

I was envisioning a system in which everybody had an associated “park warning extension” of the 7xxx fame (XXX being the internal SIP phones) that anyone could call in order to automatically park an incoming call and warn the new destination.

The regular parking callback-if-no-pickup timeout must apply.

This is the code i developed so far but i can’t make it quite work, ca anyone give an hint?
Thanks in advance.




exten => s,1,Answer()
exten => s,n,Wait(1)
exten => s,n,ParkAndAnnounce(pbx-transfer:PARKED|20|${ARG1}|SIPextensions,${ARG2},1)


include => parkedcalls
exten => _73XX,1,Macro(parking,SIP/${EXTEN:1},${CALLERIDNUM})
exten => _3XX,1,Dial(SIP/${EXTEN})[/img]

Yep yep…i use a def… mechaninism:

I use 5100 as a “push the bugger to a park slot” function.

My features conf:
parkext=>5100 ; What ext. to dial to park
parkpos=>5101-5120 ; What extensions to park calls on
context=>parkedcalls ; Which context parked calls are in
parkingtime=>600 ; Number of seconds a call can be parked for

So we have 5100 to trigger a parking.
5101-5120 are slots.

Extensions.conf (sniplet):
exten => 5100,1,park()
exten => 5100,2,hangup

This is giving me an announcement like
"The call was parked to 5101" (or something similar).

Ok…remember 5101, done.

To get “my” parked call back:
exten => _5200XXXX,1,ParkedCall(${EXTEN:4})
exten => _5200XXXX,2,hangup

So i dial 52005101 to get my parked call back.

While my extension is PRETTY long, you can (of course) use a shorter one, or even a “*” or whatever.
Its just me who doesnt bother with longer digit-colums :laughing:

(And i dont want to have overlaps/simple switch timeouts when using a short digit which is also the beginning of an existant extension).

Hey there and thanks for your response.
However that’s not what i had in mind :smile: For that use case the usual “hear 51xx, then unpark when dial 51xx” will cover my needs with just the include=>parkedcalls. I was aiming to a more advanced situation that I’ll try to clarify below:

  1. A calls to B (internal SIP extension 300)
  2. B knows that the call is intended to C (SIP extension 301)
  3. B dials 7301 to park the call and warn C and hangs up
  4. A is put on Hold and C is ringed by Asterisk who tells him the parking slot
    5.1) If C does not call the parking slot after a timeout, B is ringed back.
    5.2) If C dials the parking slot number he communicates with A.


nice idea. I tried a similar thing as you to see what would happen:

exten => _72XX,n,ParkAndAnnounce(pbx-transfer:PARKED|20|Local/${EXTEN:1}@from-internal,Local/${CallerID(num)}@from-internal)
exten => _72XX,n,Hangup

It works fine except the timeout part. I’m using the transfer button on the polycom, so it is doing a sip transfer. What I noticed is that none of the callerid, blindtransfer, rdnis fields are being set (I don’t think the rdnis field would be applicable). I haven’t spent much time to investigate. As soon as I figure out what variable or otherwise how to get the return field it should work fine. The one issue I did notice is that you will certainly want to use a different message, with an appropriate pause to give the receiving caller a moment to collect their thoughts. The current message is too cryptic (but this is details…)

If you figure out the return context, do post (as will I if I get some more cycles to play with this).


duh - it’s the ${CHANNEL}

here is what I did to get it working. It seemed to be very picky on the format of the return dialstring, but just tested and it works. Note mine is ‘hard coded’ for a 3 digit extension. You could make the more flexible with some simple pattern matching to extract the proper ‘CID’ out of the CHANNEL variable for the return. But it is ‘proof of concept’ - now just make a better intro message…

exten => _72XX,n,ParkAndAnnounce(pbx-transfer:PARKED|20|Local/${EXTEN:1}@from-internal|from-internal,${CHANNEL:4:3},1)
exten => _72XX,n,Hangup

Yay, thats a nice little piece of code, P_Lindheimer :smile:

Tnx !

Hmm that sure looks promising! Thank you for your help.
However I haven’t yet had the opportunity to test it fully given that my console indicates an error when invoking the CallerID(num) variable:

– Executing NoOp(“SIP/ulisses-c397”, “CALLERID: 0 BLINDTXF: SIP/atcom1-9350 RDNIS: CHANNEL:SIP/ulisses-c397”) in new stack
May 11 13:17:35 ERROR[29969]: pbx.c:1373 ast_func_read: Function CallerID not registered
– Executing ParkAndAnnounce(“SIP/ulisses-c397”, “pbx-transfer:PARKED|20|Local/302@SER_Asterisk|SER_Asterisk| 0|1”) in new stack
– Dial Tech,String: (Local,302@SER_Asterisk)
– Return Context: (SER_Asterisk, 0,1) ID: ulisses
– Warning: Return Context Invalid, call will return to default|s

Since it returns a 0, everything goes awry from there :\

Did you write CALLERID all in capitals?

That was it!!! I thought it was case insensitive…
Thanx. :smile:

Unfortunatly THIS variable isnt.
There are a few in asterisk which are casesensitive.

Lindheimer posted the code correct, but your CLI reading pointed to a case mismatch, since you wrote it like “CallerID”

Function CallerID not registered

This looks promising. I tried it and what happens is the call that is supposed to announce the extension only rings once and hangs up, so they never get a chance to hear about the parked call.

It appears from the logs that it’s playing before the extension answers.

Here is my final version. It will only work with SIP phones though, i was aiming for a mixed voip/legacy phones scenario but until the ${DIALEDPEERNUMBER} isn’t fixed i have no way to interpret the ${CHANNEL} information that comes from ISDN or ZAP lines.




exten => s,1,Answer()
exten => s,n,Wait(1)
exten => s,n,SetVar(returnphone=${ARG4:4})
exten => s,n,SetVar(returnphone=${CUT(retphone,1)})
exten => s,n,ParkAndAnnounce(pbx-transfer:PARKED|60|Local/${ARG2}@${ARG1}|${ARG3}|${returnphone}|1)


include => parkedcalls

exten => _73XX,1,Macro(parkingmacro,${CONTEXT},${EXTEN:1},${CONTEXT},${BLINDTRANSFER})

exten => 301,1,Dial(SIP/ulisses)
exten => 301,2,Goto(prehangup,s,1)
exten => 302,1,Dial(SIP/dionysus)
exten => 302,2,Goto(prehangup,s,1)
exten => 303,1,Dial(SIP/atcom1)
exten => 303,2,Goto(prehangup,s,1)

exten => s,1,Playtones(busy)
exten => s,2,Wait,36000
exten => i,1,Goto(prehangup,s,1)
exten => t,1,Goto(prehangup,s,1)