Bevlar

Learning VB scripting for swyx

Recommended Posts

Bevlar    0

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.

Share this post


Link to post
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 ;)

 

Share this post


Link to post
Share on other sites
Bevlar    0

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.

Share this post


Link to post
Share on other sites
Bevlar    0

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

 

Share this post


Link to post
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.

 

Share this post


Link to post
Share on other sites
Bevlar    0

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? 

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

The topic with the useful link collection can be found here:

 

 

In case there are problems with downloads from the forum page please refer to this topic:

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now