Flow to notify Group Supervisor of Incomplete Groups

Not Yet Reviewed

We have groups in xMatters that are incomplete because they do not have an on-call roster set up. I can manually review them and contact the Group Supervisor to create the roster. However, I would like to be able to create a Flow that looks for these incomplete groups and sends a notification to the Group Supervisor. I could then initiate this Flow periodically.
Does anybody have any suggestions on how this could be done?



Date Votes

Please sign in to leave a comment.

  • Off the top of my head, and in pseudo-code, I would suggest the following as a starting point.


    1) You could have a simple form, think no field and no recipients (just submit) to trigger the flow. 

    2) The flow would begin by having a step to ping the `/groups/` API endpoint which would pull in all groups. I would also embed the supervisors here. So that would be something like `/groups?limit=1000&embed=supervisors`. I would loop through the response and push a hash for each group into an empty array. Would look something like this:


    for(var group in res) {

    var group_obj = {id = group.id, supervisors = group.supervisors}

    collated_groups += group_obj



    Now you have a hash which represents each group and has all associated supervisors.

    3) Loop through the array now, this time building a path to hit the `groups/**GROUP ID**/shifts` endpoint, which will give you all shifts for a given group. Something like this

    for (var group in collated_groups) {

    var path = base + '/api/xm/1/groups/ + group.id + '/shifts'

    **** request to above path using 'get'



    Then for each, you would analyis the results of the shifts response. If you find that the group meets your qualification for a notification to supervisors, then I would build up a payload which would be all of the supervisor ID's, done by looping through that groups supervisor list. Then trigger a form with that payload being responsible for defining the recipient list. You could even bundle in the group name if you want for more personilized email (found in the shifts res by going to `res.group.targetName`). 

    var payload = {

    properties = {

    recipients = **supervisors array  ex (aa123, aa456, aa789)**

    group_name = i.group_name





    or something approximate to that. You could then have the whole thing automated by putting the triggering form on a schedule. You could also keep yourself in the loop by CC'ing yourself on all emails sent out to keep those supervisors accountable by including your own email or MList in the recipients field. 


  • One of our consultants put together a Shift Gap inspector that might be a good starting point. I think it only looks at the shifts and if there are gaps or no members, but you might be able to tweak it to your needs. 

    As Michael said, the trigger for this is a "dummy" event that kicks off the script periodically. This integration uses the Integration Builder instead of the Flow Designer, but in theory you could port it over pretty easily. If you get this working and have any updates please post in the forum or directly in github! We'd love the feedback. 

    Let us know if that helps!
    Happy Thursday!
        --- Travis 

  • Thanks Michael and Travis. This is great.  I'll do some experimenting your suggestions...and the "Gap Inspector" was on my list too..

  • I have the Shift Gap Inspector up and running in non-prod. I ran it for 2 groups and it did report the gaps for the coming week.

    What I noticed is the gaps show as 4 hours later in both start and end time  than the actual gaps shown in the UI. That means the gaps in the Flow report are being reported in Universal Time  (i.e. GMT or UTC+0).  I checked the Display Time Zone on the groups in the UI and it is UTC-5. (Clocks have gone forward in the US but not in Europe so that explains why it is a 4 hour difference and not 5).

    I ran the on-call api call standalone and it also reports the time in UTC terms.

    So the Shift Gap Inspector Flow is running fine. I just have to figure out how to get the api call to produce the report on my time zone basis which is what is displayed in the UI.


  • Good to hear! 

    Native Javascript is terrible at dealing with dates in general and timezones are even worse. I did write up an article a while back showing how to use moment.js for these things. Check out the how-to here:


    Happy Friday!

  • I took the suggestions above and used Flow Designer to come up with a Supervisor notification for incomplete groups.

    For proof of concept, I trigger the flow with an email containing the group name in the subject line.
    A flow step gets the group roster. A switch step checks for the roster count. If it is zero, the next step gets the supervisors for the group. The final step creates an event to notify the group supervisor(s). If there is more than one supervisor, whoever responds first terminates the event.

    At present, I am sending in one group name. I'd like to be able to pass in more.
    I can create a script to loop through the groups.
    Conceptually, I want the notification form to trigger separately for each group. However, I am debating whether this is going to work.
    Travis - any thoughts on this?
    In the meantime, I am going to experiment to see what happens.


    Happy St Patrick's day!

  • Travis,

    It does not appear I can add a file here directly. I'll email you the workflow. It notifies Group Supervisors that their group is incomplete in the sense that it does not have any people on a group roster. As with the Shift Gaps Inspector, you have to change the trigger reference in the calling step (Get a list of Groups - Loop through) to point to your trigger "Start event - Trigger notify for Incomplete group".


    You control which groups are processed in the initiating form.

    Feel free to post in the xmatters repository in GitHub.




  • For those following along, we posted this up on xM Labs, under the Incomplete Groups entry



Didn't find what you were looking for?

New post