Jump to content

Learning VB scripting for swyx


Bevlar

Recommended Posts

Hi, I am looking for resources on how to learn writing VB scripts to use in the Swyx GSE.

 

My first project is to count the number of busy or DND users in a group when a call comes in and connect to an overflow group if 75% of users are unavailable. 

 

Any links or general advise will be greatly appreciated.

Link to comment
Share on other sites


Hi there,

 

here you will find the "Useful link collection", that contains all freely available information/links about ECR and own scripting.

 

http://www.swyx-forum.com/forum/149-extended-call-routing-ecr/

 

There are also links to the api references. So all in all this should be everyone's starting point.

 

If you have specific questions you can of course always ask here ;)

 

Link to comment
Share on other sites


Thanks Tom,

 

I didn't see the useful links tucked away at the bottom. Obviously there's a lot of links and a lot of information to read through, please can you point me in the right direction for what I'm trying to achieve? For example to get and evaluate busy and dnd status do I need to look into VB scripting or using the API? I'm comfortable with the GSE for basic routing (using the blocks) but the rest is new to me.

Link to comment
Share on other sites


Hi Tom, thanks for the links. Would you mind taking a look at my code and let me know if I'm heading in the right direction?

 

In theory if group 101 has 2 members and are both unavailable the script should return 0

 

dim oPBXConfig
set oPBXConfig = PBXScript.CreateObject("IpPBxSrv.PBXConfig")
oPBXConfig.Initialize PBXUser

Dim nCount
nCount = 0

Dim nReturn
nReturn = 0

Dim oUsers
Set oUsers = oPBXConfig.GetUserByAddress("101")

Dim User
For Each oUser In oUsers

	nReturn = User.State
	if nReturn = 2 then
		nCount = nCount + 1
	elsif nReturn = 4 then
		nCount = nCount + 1
	elsif nReturn = 6 then
		nCount = nCount +1
	else
		nCount = nCount +0
	endif

Next

	UserStatus = nCount

 

Link to comment
Share on other sites


Weren't you interested in busy and DND? If so you should sum up the states 3,5,7.

By doing so you sum up all users in the group who are busy (internal or external) or have dnd configured.

With oUsers.Count you will get the number of all users in the group. With that you will be able to check for your 75% threshold.

 

Link to comment
Share on other sites


Going forward I want to be able to connect to an overflow group based on user availability. I figured this would be a good building block to work from.

With this code I want to skip a connection block if all of the group members are unavailable to take the call. I used 2 3 & 6 because it was the shortest if statement to get a result of either available or unavailable.

 

Would it be better to define the Userstatus result with an if statement? If I understand correctly this would allow me to use the zero and one links on the script block to route the call.

 

Next
	if nCount = 0 then
		UserStatus = 0
	else
		UserStatus = 1

 

Is my code valid? 

Link to comment
Share on other sites


Actually I pointed you on the UserStatus example to see how to "evaluate" the user status from the collection you get from GetUserByAddress.

 

Of course you can rewrite the code inside that function to what ever you like, but then it simply isn't "UserStatus" anymore.

 

If you only want you function to return two values (connect or don't connect) you should let your function return either True or False, and then use the "Evaluate" block to call it. The return value will then be mapped automatically on the both exits.

Link to comment
Share on other sites


  • 1 year later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and have taken note of our Privacy Policy.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.