This example implements parking slots; each slot holds one caller.
Note that the feature implemented by this dialplan logic is different from the features that the park and valet_park dialplan tools provide. The park application will place a caller on hold (on the system), and you must bridge to or transfer the caller to effectively retrieve the call. The valet_park application allows you to place a call on hold (on the system) and make the call retrievable by dialing a certain number.
The implementation described below provides the ability to use the same destination number to trigger holding the call in a particular FIFO OR to trigger retrieval of a call from a particular FIFO, depending on the state of the FIFO. Different from simply using park or valet_park, this dialplan controls the use of multiple FIFOs as holding slots for calls, with a one-to-one mapping between calls "parked" and unique FIFOs; only one caller can be on hold in any given FIFO at a time. If a call is on hold in a given FIFO, running this dialplan for that FIFO will result in retrieval of the call. See below for details.
If you call this extension:
- If the slot is empty, you park yourself in the slot.
- If the slot is holding a caller, the caller will be removed from the slot and delivered to you - you and the caller will be connected.
If you transfer a caller to this extension:
- If the slot is empty, the transferred caller will be placed in the slot.
- If the slot is holding a caller already, the transferred caller and parked caller will be connected (the parked caller being removed from the slot).
This behavior is implemented by using FIFOs. The fact that only one caller is allowed in a FIFO at a time is controlled by this dialplan, which uses the FIFO count of callers.
Having this feature in a single extension (and single destination) is great for making a BLF/speed-dial button on a SIP phone which points to this extension. Then you have a single button to control parking and un-parking.
In this example, the regular expression matching the destination for this extension is "slot\d+" so that you may have any number of slots (i.e. you may have slot1, slot2, slot3, ..., slot100, etc.).
You may define FIFOs (e.g. define FIFOs named slot1, slot2, and slot3) in autoload_configs/fifo.conf.xml.