[asterisk-dev] On ParkAndAnnounce and parking lot

Andrew Kohlsmith akohlsmith-asterisk at benshaw.com
Mon Mar 27 08:52:53 MST 2006


On Monday 27 March 2006 04:45, Sharath Chandra wrote:
> I downloaded the latest branch as on today 27th March. I tried to access
> the 'PARKEDAT' variable in the following manner, but always the value of
> ${PARKEDAT} is displayed blank. Actually i want to access this variable
> when dialed on another extension.
> Can you give me some sample dialplan showing the usage.

> [default]
(on a technical note, I'd *never* suggest actually using [default].  Put a 
matchall that does a Hangup in there and nothing else, and use specific 
contexts so you never get a call there you're not expecting.)

> include => parkedcalls

Your dialplan looks like a real potential rat's nest...  I'd strongly suggest 
separating things out and saving yourself a world of headaches in the (near) 
future.

> exten => 4170056,1,Answer
> exten => 4170056,2,Wait(1)
> exten => 4170056,3,Playback(welcome)
> exten => 4170056,4,ParkAndAnnounce(|20||default,${EXTEN},5)

You're not using ParkAndAnnounce correctly at all; You're saying to come back 
to "default,${EXTEN},5" if the park times out, but you're not specifying who 
to call and tell the parking lot to, nor are you specifying a template to 
announce with. ParkAndAnnounce isn't quite the same as Park().

With ParkAndAnnounce, you need to Dial() someone to "announce" the parked 
call's slot to.  This was originally intended to be played out over an 
overhead paging system, but it's far too useful to just relegate to that 
simple task.  To use the variable it's easiest to "call" the Local/ channel 
and deal with it in there:

exten => 4170056,4,ParkAndAnnounce(PARKED||Local/${EXTEN}@ParkedAt)

That will "Dial" (i.e. create a call) to 4170056 in the ParkedAt context and 
"play" the parking lot # to that extension.  We don't care about the audio, 
but the variable ${PARKEDAT} will arrive there as well, and that's what we're 
interested in.  I've also eliminated the timeout.  So now let's use the 
variable:

[ParkedAt]
exten => _X.,1,NoOp(Call to ${EXTEN} was parked at ${PARKEDAT})
exten => _X.,n,Goto(default,${EXTEN},5)

All this does is jump back to your original context (again, don't use default, 
icky, icky, icky!) at the next priority, and you can take it from here:

> exten => 4170056,5,NoOp(${PARKEDAT})
> exten => 4170056,6,Playback(goodbye)
> exten => 4170056,7,Hungup

Now you're not doing much.  If you want to store it somewhere that something 
else (another call, perhaps) can use it, you need to put it somewhere, like 
in AstDB:

exten => 4170056,5,Set(DB(LastParkedCall)=${PARKEDAT})

Now you can use 4170057 to actually pull it and use it:

exten => 4170057,1,Answer
exten => 4170057,n,Wait(1)
exten => 4170057,n,Set(PARKEDAT=DB(LastParkedCall))
exten => 4170057,n,Set(DB(LastParkedCall)=)
exten => 4170057,n,ParkedCall(${PARKEDAT})

(Note that the application name is ParkedCall, not ParkedCalls.)

You can see that I set the channel variable PARKEDAT here to the DB value I 
stored, and then I erase the DB value (actually set it to an empty value).  
If you wanted to be more robust you could check for an empty value and deal 
with it, or even create some kind of array storage, since every parked call 
will "erase" the value of the last one in the DB.

Clear as mud?  :-)

To Recap:  ParkAndAnnounce() parks the call, and then Dial()'s someone to 
announce where the call is, instead of announcing the parking slot to the 
other party (the one who requested the park).  It's that Dial()'d someone 
that not only gets the audio, but also gets the channel variable.

Another (slightly more complete) example follows.  *74 parks the call, *75 
picks up the last parked call.  If nobody picks up the parked call within 20 
seconds, the *74 dialplan continues by clearing out the DB entry and calling 
the receptionist's phone (extension 221 in this example):

[foo]
exten => *74,1,ParkAndAnnounce(PARKED,20,Local/s at ParkedAt)
exten => *74,n,NoOp(Call timed out, erasing Parking Slot Number since call 
isn't there anymore, it's here)
exten => *74,n,Set(DB(LastParkedAt)=)
exten => *74,n,NoOp(Ok, the person you've parked is back here... What are you 
gonna do?)
exten => *74,n,Goto(extensions,221,1)

exten => *75,1,NoOp(Going to pick up the last parked call)
exten => *75,n,Set(PARKEDAT=DB(LastParkedAt))
exten => *75,n,Set(DB(LastParkedAt)=)
exten => *75,n,ParkedCall(${PARKEDAT})

[ParkedAt]
exten => s,1,NoOp(Call was parked at ${PARKEDAT})
exten => s,n,Set(DB(LastParkedAt)=${PARKEDAT})
exten => s,n,Hangup

-A.



More information about the asterisk-dev mailing list