| Oskar wrote
This is a very simple call routing script, I need to connect the call then if the user is busy I want to park the call on hold for x number of seconds and then try again.
|
Hi Oskar,
there is a block to put the current call on hold (i.e. starting some announcement/music) within the GSE. Once you have called that you can use a simple vbscript loop to check the availability of a certain user. Don't miss to place a PBXScript.Sleep 1000 into this loop !
You can use the following function to check the the client state (place it into the start block of your gse script):
Function IsAgentFree ( sNumber )
Dim bReturn
bReturn = False
Dim PBXConfig
Set PBXConfig = PBXScript.CreateObject("IpPbxSrv.PBXConfig")
PBXConfig.Initialize PBXUser
Dim Users
Set Users = PBXConfig.GetUserByAddress (sNumber)
Dim User
For Each User in Users
' does the server recognize this user a free ?
If User.State = 2 Then
' check if client would really take the call (and not having locked it's lines)
If PBXScript.IsUserOrGroupBusy (sNumber) = 0 Then bReturn = True
End If
Next
IsAgentFree = bReturn
End Function
To put everything together:
- use the Hold block to put the call on hold
- use a VBScript code block to place the loop in
While Not IsAgentFree (100)
PBXScript.Sleep 1000
Wend
- use a Connect To block to connect the call.
please note that the Connect To block will automatically activate the call on hold, so you don't need to call the Activate block by yourself.
But maybe Morten is right by suggesting to use the build in queue blocks for this. The queue itself does in fact nearly the same a described above.
Regards, Tom.