Jump to content

Tom Wellige

Root Moderator
  • Posts

    4,309
  • Joined

  • Last visited

  • Days Won

    117

 Content Type 

Profiles

SwyxPEDIA Wiki

Zendesk Integration

Persistent Variables

Longest Waiting

VBScript build in functions

GSE build in functions (VBScript)

Server Script API (VBScript)

GSE build in functions (Lua)

Server Script API (Lua)

Function Collection (VBScript)

Function Collection (Lua)

IPS Integration

Jira Service Integration

Forums

Blogs

Downloads

Blog Entries posted by Tom Wellige

  1. Tom Wellige
    From 2009 to 2011 mirjam baumberger wrote a great blog, the "Fridays' Swyx Tip". Every Friday she posted a tip regarding the usage of SwyxWare and connected tools and devices. As the old forum is offline, this article series will be restored here again over the time. Please note that some information in this article series might not be valid anymore with current SwyxWare versions.
     
    This blog article was originally posted on 24.06.2011 03:41
     
    Dear Swyx Users
     
    With SwyxWare 2011 I can set my phone status to "DO NOT DISTURB" and all my co-workers are automatically updated with my DND status.

    This is a useful feature for many users and managers and we have been asked about this features a lot in the past. Good news is, it's now available 🙂

    I have created a Callrouting Script which routes incoming calls to my extension based on my user status: Speaking, Logged Off, Free, Away or DND.

    AdvancedDDIRouting.zip
     
    It is simply a modification of the popular Advanced DDI call routing script prior SwyxWare Version 2011.
     

     
     
    And there is a special "feature" implemented. You will be able to see if you receive a call in DND mode and you have even the possibility to pick up this call while the caller is listening to your greeting message:
     
    "Hi there, although I'm in the office, I can't pick-up your call at this moment. Please leave me a message after the tone and I will return your call ASAP. Thank you".
     
    This allows me to keep in control of any incoming calls to my extensions, I can let one caller go through to my voicemail, but pick up another one, because I know it is an important call !
     
    Pretty sneaky, what do you think ?
     
     
    Have a good weekend and happy Swyxing...
     
    Regards
    Mirjam
     
    @ IT Net World Ltd, NZ & AUS SWYX Distributor
    http://www.itnetworld.co.nz/
     
  2. 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. Tom Wellige
    Lua → VBScript
     
    Some time ago I wrote about checking for being in (or out) of a time period more flexible. To recap, the GSE Time block only offers to enter hard coded dates and times, but it doesn't offer the usage of variables.
     

     
    In that previous article I showed how easy it VBScripts makes to take the date/time calculation in the own hands by using CDate() to convert a string into a date and afterwards use DateDiff() for the calculation.
     
    The beauty of the CDate() function is, that it handles all the different date formats like dd.mm.yyyy, mm/dd/yyyy, dd/mm/yyyy, a.s.o. for us. You just pass a written date like "24.12.2022" into the function, which then checks the regional settings of your Windows machine to figure the correct date/time format to identifiy the day, month and year correctly.
     
    Of course Lua also has some nice date and time functionality, but it completely leaves the format trouble on the users side. To get a date value where we can calculate with there is an os.time() function which takes the date not as string but as a table, and we have to fill this table with all values like day, month, year, a.s.o.
     
    This might sound more complicated as it is:
     
    local vChristmas = os.time{day=24, month=12, year=2022}  
    but it becomes obvious that we can't use date strings like "24.12.2022" anymore. Unless we handle the conversion from string to table (incl. taking care of the date format) ourselves:
     
    local sChristmas = "24.12.2022" local nDay = tonumber(StringLeft(sChristmas, 2)) local nMonth = tonumber(StringMid(sChristmas, 4, 2)) local nYear = tonumber(StringRight(sChristmas, 4)) local vChristmas = os.time{day=nDay, month=nMonth, year=nYear}  
    That's a lot of code just to be able to use a date string like "24.12.2022" don't you agree?
     
    In the end I want to have a call routing which will be handled exactly like the one in the orignal article, where I can set a start and end date of my vacation as a GSE rule parameter, as string. But I don't want to do all this conversion stuff by myself.
     
    Fortunately there is a solution, and a really easy one in fact. Behind every GSE block there is some either VBScript or Lua code which handles the action or the selected condition. Behind the Within a specified time period condition of the Time block there is a function called
     
    function WithinTheTimeOfEx(szBeginDate, szBeginTime, szEndDate, szEndTime, bIgnoreDate, bIgnoreTime)  
    It takes all the parameters from the time period configuation window (as string), does all needed conversion and afterwards also the needed calucation using os.datediff(). 
     
    Only thing we have to be aware of when using this function is that it uses a hard coded date format "dd.mm.yyyy" and time format "HH:MM:SS". By the way, you might have noticed from the GSE build-in functions CurDate(), CurDateTime(), CurTime() and the Server Script API function PBXUser.Now() that they also use hard coded date/time formats. You now have an idea why that is.
     
     
    So, coming back to the call routing:
     

     

     
    With the rule parameters
     

     

     
     
    You can download this script from here:
     
    Vacation_Lua.rse
     
     
    Enjoy!
     
    PS: Don't miss to take a look into the ECR - Useful Link Collection
     
     
  4. Tom Wellige

    General
    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.
     
     
    VBScript
    '------------------------------------------------------------------- ' 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 Next NumberOfLoggedInUsersInGroup = nReturn PBXScript.OutputTrace("nReturn = " & nReturn) PBXScript.OutputTrace("<------------- NumberOfLoggedInUsersInGroup") End Function  
     
    Lua
    ------------------------------------------------------------------ -- 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 end end PBXScript.OutputTrace ("nReturn = " .. tostring(nReturn)) PBXScript.OutputTrace ("<------------- NumberOfLoggedInUsersInGroup") return bReturn end  
     
    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:
     
    Function Collection (VBScript) - NumberOfLoggedInUsersInGroup Function Collection (Lua) - NumberOfLoggedInUsersInGroup  
     
    Enjoy!
     
    PS: don't miss to take a look into the ECR Useful Link Collection.
     
     
×
×
  • 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.