Jump to content


Our community blogs

  1. Yesterday I was asked an intersting call routing question: is it possible to route a call to different groups, depending on the amount of users currently logged in into one of those groups?


    More precisely: if in Group A are more than one users logged in, route all incoming calls to this group. If there is no or just one user logged in, route the call to Group B.


    So the question that needs be answered is how many users are currently logged in into a given group?


    With a little bit of scripting code this can be answered quickly.


    The Server Script API (VBS/Lua) provides a function PBXConfig.GetUserByAddress (VBS/Lua) which can be used to enumerate all users of a group. Per user a set of properties is available:


    • UserID
    • Name
    • EMailAddress
    • State
    • Numbers
    • NumberOfNewVoicemails



    The State property is the current state of this user. This is a numeric property and can hold any of the following values:


    • User state not available
      UserStateUnavailable = 0
    • User is logged off
      UserStateLoggedOff = 1
    • User is logged on
      UserStateLoggedOn = 2
    • User is speaking, at least one call has an external origination or destination
      UserStateSpeakingExternal = 3
    • A call is currently alerting at one of the user's devices
      UserStateAlerting = 4
    • User is speaking, none of the calls has an external origination or destination
      UserStateSpeakingInternal = 5
    • User is away (since SwyxWare 2011)
      UserStateAway = 6
    • User has do not disturb status (since SwyxWare 2011)
      UserStateDoNotDisturb = 7
    • Busy indication from external presence source (e.g. MS Teams) (since SwyxWare 13)
      UserStateActive3rdParty = 8



    Any number above 1 indicates that the user is logged on (regardless if he is free, busy, away, etc.).


    So what is needed to do is to count all users in the group who have a State value above 1


    The following is a simple function that sums all such users up and returns the sum.




    ' NumberOfLoggedInUsersInGroup
    ' Returns the number of users which are currently logged in into the given group.
    ' The users need to have a higher status as "1", i.e. being logged in (regardless if free or busy).
    ' Parameter:
    '      sGroup      name or number of group
    ' return value:
    '      integer     number of logged in users
    Function NumberOfLoggedInUsersInGroup ( sGroup )
        PBXScript.OutputTrace("-------------> NumberOfLoggedInUsersInGroup ( sGroup = " & sGroup & " )")
        Dim nReturn
        nReturn = 0
        Dim Users
        Set Users = g_PBXConfig.GetUserByAddress(sGroup)
        Dim User
        For Each User In Users
            PBXScript.OutputTrace("Found user " & User.Name & " with current state " & User.State)
            If User.State > 1 Then nReturn = nReturn + 1
        NumberOfLoggedInUsersInGroup = nReturn
        PBXScript.OutputTrace("nReturn = " & nReturn)
        PBXScript.OutputTrace("<------------- NumberOfLoggedInUsersInGroup")    
    End Function




    -- NumberOfLoggedInUsersInGroup
    -- Returns the number of users which are currently logged in into the given group.
    -- The users need to have a higher status as "1", i.e. being logged in (regardless if free or busy).
    -- Parameter:
    --      sNumber     uname or number of group
    -- Return:
    --      integer     number of logged in users
    function NumberOfLoggedInUsersInGroup( sGroup )
        PBXScript.OutputTrace ("-------------> NumberOfLoggedInUsersInGroup ( sGroup = " .. sGroup .. " )")
        local nReturn = 0
        local oUsers  = nil
        oUsers = PBXScript.GetUserByAddress(sGroup)
        if (oUsers ~= nil) then
            for i = 1, #oUsers do
                PBXScript.OutputTrace ("Found user '" .. oUsers[i]:Name() .. "' with current state '" .. oUsers[i]:State() .. "'")
                if (oUsers[i]:State() > 1) then nReturn = nReturn + 1
        PBXScript.OutputTrace ("nReturn = " .. tostring(nReturn))
        PBXScript.OutputTrace ("<------------- NumberOfLoggedInUsersInGroup")
        return bReturn



    With placing this code into the Start block of a GSE script (as explained here (VBS) or here (Lua)) it is possible to use an Evaluate block to define a simple condition for routing the calls like needed:


    • NumberOfLoggedInUsersInGroup("Group A") > 1



    The entire GSE script could then look like this:








    The above given function is also part of the Function Collection here on the forum page:






    PS: don't miss to take a look into the ECR Useful Link Collection.



  2. Tom Wellige
    Latest Entry

    By Tom Wellige,

    This post sums this great article series up. Mirjam spent quite some time to identify all those tips and to publish them here on Swyx Forum.


    As the article series dates some years back there had been a couple of articles I have not re-posted again, simply because they were not valid with a current SwyxWare version anymore.


    But the vast majority of the tips is still valid with current SwyxWare versions and that's why I decided to re-post them to make them available again after the old Swyx Forum went offline.


    Thank you very much Mirjam for all your efforts!


  3. A common feature request I have had over the years is a Call Park feature, and the usual stock reply to Can Swyx Do..... is NO! but...... of course this is software and anything is possible. I have seen a number of ways of implementing a call park feature some really clever ones that use the conference bridge facility in Swyx to some not so clever ones using analog adaptors to have live logged on extensions which are used to pick up from... sudu call park.
    Before I saw the conference room version written by Tom I had a go myself and came up with this solution a couple of years ago and put it online. Recently a couple of requests came in for the source code so I thought I would upload it here.
    This is another illustration of how different solutions to problems can be developed with Swyx, there is no right or wrong way, they either work or don't.



    So next time someone asks if "Swyx can do .........  ?",  reply  "No it can't, but you can"  🙂





    Call Park.zip



  • Blog Statistics

    • Total Blogs
    • Total Entries
  • Blog Comments

    • I have just updated the download link in the article with a correctly working version.  
    • Hi Mark,   do you still have a working version?   Thanks      
    • Nein, das Skript läuft auf JEDER SwyxWare Version. Das ist das schöne am Call Routing     Ich habe aber nochmal etwas genauer nachgesehen, und einen logischen Fehler gefunden. Der ist nun behoben und das Skript läuft einwandfrei auf meinem 13.25er Testsystem. Der Download oben im Blog Post ist aktualisiert.   Das war allerdings nur ein logischer Fehler, d.h. das Ende des Urlaubs wurde nicht richtig erkannt. Das hat aber zu keinen Skript/Ruf Abbruch geführt. Das klingt mir ehe
    • Hallo Herr Wellige 😀   ich bin gerade dabei ein Call Routing zu bauen, wo die Nutzer "einfach" Ihre Urlaubszeit eintragen können. Das hier angebrachte Skript funktioniert leider nicht mehr, das Gespräch wird beendet. Gibt es hier ggf. ein Update für die momentan aktuellste Version 13.25?   Danke schon einmal M. Schulze   getestet mit VBS nicht LUN
    • Hello Tom,   thanks for your reply.   As we´re not running the server on premise, I´ll have to make some calls to find out how to get my hands on the logfiles. The only logs we have are the mmc logs from the maschine the swyxware administration is running on.   And my usual called tech guy seems to be in holidays already  I´ll come back as soon as I get any info - when ever that will be.  
  • 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.