Hey everyone,
Following the approach of using the Dial application along with the d
option. I can say that what I wanted to accomplish is almost considered… accomplished…
I must admit that I am surprised that this is working, although not 100% as I wanted, but as far as I tested, nothing breaks or got broken.
I also want to point out, that it seems like literally everything is doable with Asterisk, maybe you have to combine a couple of applications/functions and at the end using a “hacky” method, but it’s working
So, here’s the dialplan: (using FreePBX)
We have 4 “parking” extensions with hints. 8501, 8502, 8503 & 8504
[from-internal]
exten => _850[1-4],hint,Custom:CPark${EXTEN:-1}
exten => _850[1-4],1,Noop(Entering Custom Park Context. DEBUG: hint- ${DEVICE_STATE(Custom:CPark${EXTEN:-1})})
exten => _850[1-4],n,GotoIf($["${DEVICE_STATE(Custom:CPark${EXTEN:-1})}" = "INUSE"]?cpark-pickup,${EXTEN},1)
exten => _850[1-4],n,Playback(pbx-invalidpark)
exten => _850[1-4],n,Hangup()
[from-internal-xfer]
exten => _850[1-4],1,Noop(Checking if we can transfer the call or if there is an existing call parked already. DEBUG: The hint is ${DEVICE_STATE(Custom:CPark1)})
exten => _850[1-4],n,Set(_CPark_Parker=${PICKUPMARK})
exten => _850[1-4],n,Set(_CPark=CPark${EXTEN:-1})
exten => _850[1-4],n,GotoIf($["${DEVICE_STATE(Custom:${CPark})}" = "NOT_INUSE"]?proceed)
exten => _850[1-4],n,Noop(Seems like there's a call there. We will now return the call to the Parker. the parker is ${CPark_Parker})
exten => _850[1-4],n,Goto(from-internal,${CPark_Parker},1)
exten => _850[1-4],n(proceed),Goto(cpark-park-calls,${EXTEN},1)
[cpark-park-calls]
exten => _850[1-4],1,Noop(Parking call....)
exten => _850[1-4],n,Set(__EXITCONTEXT=cpark-exit-context)
exten => _850[1-4],n,Set(DEVICE_STATE(Custom:${CPark})=INUSE)
exten => _850[1-4],n,Answer()
exten => _850[1-4],n,Dial(local/${EXTEN}@play-park-moh,300,d)
exten => _850[1-4],n,Noop(Park timed out. Returning call to parker. The parker is: ${CPark_Parker})
exten => _850[1-4],n,Set(DEVICE_STATE(Custom:${CPark})=NOT_INUSE)
exten => _850[1-4],n,Goto(from-internal,${CPark_Parker},1)
exten => h,1,Noop(Entering the Hangup exten)
exten => h,n,GotoIf($["${DIALSTATUS}" = "ANSWER"]?skip)
exten => h,n,Noop(Caller left park, hanging up the call and resetting the BLF state)
exten => h,n,Set(DEVICE_STATE(Custom:${CPark})=NOT_INUSE)
exten => h,n(skip),Hangup()
[play-park-moh]
exten => _850[1-4],1,Noop(Starting the park MOH...)
exten => _850[1-4],n,MusicOnHold(CParkMOH)
[cpark-pickup]
exten => _850[1-4],1,Noop(Entering context to pickup-retrieve a parked call...)
exten => _850[1-4],n,Set(DEVICE_STATE(Custom:CPark${EXTEN:-1})=NOT_INUSE)
exten => _850[1-4],n,Pickup(${EXTEN}@play-park-moh)
exten => _850[1-4],n,Hangup()
[cpark-exit-context]
exten => 1,1,Noop(In exit context)
exten => 1,n,Set(DEVICE_STATE(Custom:${CPark})=NOT_INUSE)
exten => 1,n,Goto(from-internal,${CPark_Parker},1)
exten => 1,n,Hangup()
Sooo… As mentioned, this works. However, there are some improvements I want to implement.
- When retrieving a call, I want to play a beep on both legs of the call.
- Now, if the the parkee hangs up while parked, it calls the h extension in cpark-park-calls which is good. The problem is that it also calls the h extension after he call was retrieved from park and completed. Is there a way to avoid that?
- Can anyone tell if I might run into any other issues?
Thank you very much
EDIT: Forgot to include the exit context