Every Monday morning, posts who is on leave this week from BambooHR to Slack, with their dates, holidays and work anniversaries.
Uses
BambooHR
Slack
Tell the team who's out this week
On Monday morning nobody knows who is off this week, so meetings get booked with people who are away, cover isn't arranged and HR spends the week answering "is Sam off?". Every Monday at 08:00, the week's approved time off and company holidays are read from BambooHR and posted to your team's Slack channel as one message: how many people are out, then each person with the real dates of their leave, so someone away since last Thursday or back next Tuesday shows exactly that. Company holidays follow, then the work anniversaries that fall this week, such as "Priya Shah – 3 years on Wednesday".
Only names and dates are posted. The type of leave stays private unless you switch it on, so a sick day reads simply as a day out. A week with nobody away gets one short line saying so. If BambooHR can't be read, nothing is posted and the run is marked as failed, so an outage never reads as "nobody is out"; if only the anniversaries can't be checked, who's out is still posted and the run names what was left out.
You need BambooHR and Slack connected, with BambooHR connected through an HR admin's account so it can see everyone's time off and hire dates, and the ID of the Slack channel the message goes to. Two settings let you show the type of leave and switch anniversaries off.
showLeaveType to false.Set showLeaveType to false.includeWorkAnniversaries to true.Set includeWorkAnniversaries to true.slackChannelId to blank.Set slackChannelId to blank.today.Get today's date and save it as today.today and save it as weekStart.Get the start of the week for today and save it as weekStart.today and save it as weekEnd.Get the end of the week for today and save it as weekEnd.weekStart readable as “2 Nov” and save it as weekFrom.Make weekStart readable as “2 Nov” and save it as weekFrom.weekEnd readable as “2 Nov” and save it as weekTo.Make weekEnd readable as “2 Nov” and save it as weekTo.entries to an empty list.Set entries to an empty list.nextPage to 1.Set nextPage to 1.morePages to true.Set morePages to true.morePages is yes:While morePages is yes:readErrorIf a step below fails, save the error as readErrorweekStart to weekEnd. Save it as whosOut.List who's out in BambooHR from weekStart to weekEnd. Save it as whosOut.entries and whosOut.entries into one list and save it as entries.Combine entries and whosOut.entries into one list and save it as entries.morePages to whosOut.has_more.Change morePages to whosOut.has_more.readError.message). Check the BambooHR connection under Integrations, then run the workflow again.Stop and report a problem: Nothing was posted: who's out could not be read from BambooHR (readError.message). Check the BambooHR connection under Integrations, then run the workflow again.nextPage.Add 1 to nextPage.entries where item.type in lowercase is holiday and save it as holidays.Keep each item in entries where item.type in lowercase is holiday and save it as holidays.entries where item.type in lowercase is not holiday and save it as absences.Keep each item in entries where item.type in lowercase is not holiday and save it as absences.showLeaveType is yesIf showLeaveType is yestypesErrorIf a step below fails, save the error as typesErrorleaveTypes.List time off types. Save it as leaveTypes.leaveTypes.time_off_types and save it as leaveTypeNames.Rename fields in leaveTypes.time_off_types and save it as leaveTypeNames.absences with leaveTypeNames by timeOffTypeId and save it as absences.Match absences with leaveTypeNames by timeOffTypeId and save it as absences.typesError.message). Check the BambooHR connection, or set showLeaveType to false, then run the workflow again.Stop and report a problem: Nothing was posted: the types of leave could not be read from BambooHR (typesError.message). Check the BambooHR connection, or set showLeaveType to false, then run the workflow again.absences by name, smallest first and save it as absencesByName.Sort absences by name, smallest first and save it as absencesByName.absencesByName by start, smallest first and save it as absencesInOrder.Sort absencesByName by start, smallest first and save it as absencesInOrder.absencesInOrder by employeeId and save it as peopleOut.Group the items in absencesInOrder by employeeId and save it as peopleOut.personLines to an empty list.Set personLines to an empty list.person in peopleOut:For each person in peopleOut:periods to an empty list.Set periods to an empty list.absence in person.items:For each absence in person.items:absence.start readable as “Mon 2 Nov” and save it as period.Make absence.start readable as “Mon 2 Nov” and save it as period.absence.end is not absence.startIf absence.end is not absence.startabsence.end readable as “Mon 2 Nov” and save it as absenceLastDay.Make absence.end readable as “Mon 2 Nov” and save it as absenceLastDay.period to period to absenceLastDay.Change period to period to absenceLastDay.absence.leaveType, or if it is empty and save it as leaveTypeName.Use absence.leaveType, or if it is empty and save it as leaveTypeName.leaveTypeName isn't blankIf leaveTypeName isn't blankperiod to period (leaveTypeName).Change period to period (leaveTypeName).period to the end of periods and save it as periods.Add period to the end of periods and save it as periods.periods with , and save it as periodList.Join periods with , and save it as periodList.person.items[0].name – periodList to the end of personLines and save it as personLines.Add • person.items[0].name – periodList to the end of personLines and save it as personLines.holidays by start, smallest first and save it as holidaysInOrder.Sort holidays by start, smallest first and save it as holidaysInOrder.holidayLines to an empty list.Set holidayLines to an empty list.holiday in holidaysInOrder:For each holiday in holidaysInOrder:holiday.start readable as “Mon 2 Nov” and save it as holidayDates.Make holiday.start readable as “Mon 2 Nov” and save it as holidayDates.holiday.end is not holiday.startIf holiday.end is not holiday.startholiday.end readable as “Mon 2 Nov” and save it as holidayLastDay.Make holiday.end readable as “Mon 2 Nov” and save it as holidayLastDay.holidayDates to holidayDates to holidayLastDay.Change holidayDates to holidayDates to holidayLastDay.holiday.name – holidayDates to the end of holidayLines and save it as holidayLines.Add • holiday.name – holidayDates to the end of holidayLines and save it as holidayLines.anniversaries to an empty list.Set anniversaries to an empty list.anniversaryProblems to an empty list.Set anniversaryProblems to an empty list.showLeaveType is yes and absences isn't empty and the items in absences where…If showLeaveType is yes and absences isn't empty and the items in absences where…the type of leave was left out because BambooHR did not say which type each absence is. Set showLeaveType to false to post without it. to the end of anniversaryProblems and save it as anniversaryProblems.Add the type of leave was left out because BambooHR did not say which type each absence is. Set showLeaveType to false to post without it. to the end of anniversaryProblems and save it as anniversaryProblems.includeWorkAnniversaries is yesIf includeWorkAnniversaries is yescolleagues to an empty list.Set colleagues to an empty list.datedColleagues to an empty list.Set datedColleagues to an empty list.staffCursor to blank.Set staffCursor to blank.moreStaff to true.Set moreStaff to true.staffErrorIf a step below fails, save the error as staffErrormoreStaff is yes:While moreStaff is yes:staffPage. List employees. Save it as staffPage.colleagues and staffPage.employees into one list and save it as colleagues. Combine colleagues and staffPage.employees into one list and save it as colleagues.staffCursor to staffPage.next_cursor. Change staffCursor to staffPage.next_cursor.moreStaff to staffPage.has_more. Change moreStaff to staffPage.has_more.colleagues where item.hireDate, or if it is empty isn't blank and item.hireDate is not… and save it as datedColleagues.Keep each item in colleagues where item.hireDate, or if it is empty isn't blank and item.hireDate is not… and save it as datedColleagues.colleagues where item._restrictedFields contains hireDate and save it as hiddenHireDates.Keep each item in colleagues where item._restrictedFields contains hireDate and save it as hiddenHireDates.colleagues and save it as activeCount.Count the items in colleagues and save it as activeCount.activeCount is 0If activeCount is 0work anniversaries were left out because BambooHR returned no active employees. Connect BambooHR with a key from someone who can see everyone's records. to the end of anniversaryProblems and save it as anniversaryProblems.Add work anniversaries were left out because BambooHR returned no active employees. Connect BambooHR with a key from someone who can see everyone's records. to the end of anniversaryProblems and save it as anniversaryProblems.hiddenHireDates and save it as hiddenCount.Count the items in hiddenHireDates and save it as hiddenCount.hiddenCount of your activeCount active employees from this connection, so their work anniversaries were left out. Connect BambooHR with a key from someone who can see hire dates, or set includeWorkAnniversaries to false. to the end of anniversaryProblems and save it as anniversaryProblems.Add BambooHR hides the hire date of hiddenCount of your activeCount active employees from this connection, so their work anniversaries were left out. Connect BambooHR with a key from someone who can see hire dates, or set includeWorkAnniversaries to false. to the end of anniversaryProblems and save it as anniversaryProblems.activeCount active employees has a hire date in BambooHR. to the end of anniversaryProblems and save it as anniversaryProblems.Add work anniversaries were left out because none of your activeCount active employees has a hire date in BambooHR. to the end of anniversaryProblems and save it as anniversaryProblems.datedColleagues to an empty list.Change datedColleagues to an empty list.staffError.message). to the end of anniversaryProblems and save it as anniversaryProblems.Add work anniversaries were left out because the employee list could not be read from BambooHR (staffError.message). to the end of anniversaryProblems and save it as anniversaryProblems.unreadableHireDates to an empty list.Set unreadableHireDates to an empty list.colleague in datedColleagues:For each colleague in datedColleagues:dateError If a step below fails, save the error as dateErrorcolleague.hireDate to weekEnd and save it as yearsBySunday.Count the years from colleague.hireDate to weekEnd and save it as yearsBySunday.yearsBySunday is greater than or equal to 1If yearsBySunday is greater than or equal to 1colleague.hireDate by yearsBySunday years and save it as anniversaryDate.Move colleague.hireDate by yearsBySunday years and save it as anniversaryDate.weekStart and anniversaryDate in days is greater than…If the difference between weekStart and anniversaryDate in days is greater than…colleague.displayName, or colleague.firstName colleague.lastName if it is empty and save it as colleagueName.Use colleague.displayName, or colleague.firstName colleague.lastName if it is empty and save it as colleagueName.anniversaryDate and save it as anniversaryDay.Get the day of the week for anniversaryDate and save it as anniversaryDay.yearsText to yearsBySunday years.Set yearsText to yearsBySunday years.yearsBySunday is 1If yearsBySunday is 1yearsText to 1 year.Change yearsText to 1 year.anniversaries and save it as anniversaries.Add a record of date and line to the end of anniversaries and save it as anniversaries.colleague.displayName to the end of unreadableHireDates and save it as unreadableHireDates.Add colleague.displayName to the end of unreadableHireDates and save it as unreadableHireDates.unreadableHireDates isn't emptyIf unreadableHireDates isn't emptyunreadableHireDates with , and save it as unreadableNames.Join unreadableHireDates with , and save it as unreadableNames.unreadableNames could not be read, so their work anniversaries were left out. Correct it in BambooHR. to the end of anniversaryProblems and save it as anniversaryProblems.Add the hire date of unreadableNames could not be read, so their work anniversaries were left out. Correct it in BambooHR. to the end of anniversaryProblems and save it as anniversaryProblems.anniversaries by date, smallest first and save it as anniversariesInOrder.Sort anniversaries by date, smallest first and save it as anniversariesInOrder.line from every item in anniversariesInOrder and save it as anniversaryLines.Get line from every item in anniversariesInOrder and save it as anniversaryLines.peopleOut and save it as peopleCount.Count the items in peopleOut and save it as peopleCount.outSummary to peopleCount people.Set outSummary to peopleCount people.peopleCount is 0If peopleCount is 0outSummary to nobody has time off booked.Change outSummary to nobody has time off booked.outSummary to 1 person.Change outSummary to 1 person.peopleSection to blank.Set peopleSection to blank.peopleCount is greater than 0If peopleCount is greater than 0personLines with a new line and save it as personList.Join personLines with a new line and save it as personList.peopleSection to Change peopleSection to
personList.holidaySection to blank.Set holidaySection to blank.holidayLines isn't emptyIf holidayLines isn't emptyholidayLines with a new line and save it as holidayList.Join holidayLines with a new line and save it as holidayList.holidaySection to Change holidaySection to
*Holidays*
holidayList.anniversarySection to blank.Set anniversarySection to blank.anniversaryLines isn't emptyIf anniversaryLines isn't emptyanniversaryLines with a new line and save it as anniversaryList.Join anniversaryLines with a new line and save it as anniversaryList.anniversarySection to Change anniversarySection to
*Work anniversaries*
anniversaryList.postErrorIf a step below fails, save the error as postErrorslackChannelId. Save it as posted.Send a message to slackChannelId. Save it as posted.*Who's out this week (weekFrom – weekTo):* outSummary@peopleSection@holidaySection@anniversarySectionpostError.message). Check that 'slackChannelId' at the top of the workflow is your team channel's ID, and for a private channel add the Lodol app to it by typing /invite Lodol in that channel.Stop and report a problem: The message could not be posted to Slack (postError.message). Check that 'slackChannelId' at the top of the workflow is your team channel's ID, and for a private channel add the Lodol app to it by typing /invite Lodol in that channel.holidayLines and save it as holidayCount.Count the items in holidayLines and save it as holidayCount.anniversaryLines and save it as anniversaryCount.Count the items in anniversaryLines and save it as anniversaryCount.anniversaryProblems isn't emptyIf anniversaryProblems isn't emptyanniversaryProblems with Also, and save it as problemList.Join anniversaryProblems with Also, and save it as problemList.weekFrom – weekTo (outSummary), but problemList.Stop and report a problem: Posted who's out for weekFrom – weekTo (outSummary), but problemList.weekFrom – weekTo: outSummary; holidays: holidayCount; work anniversaries: anniversaryCount.Finish the run: Posted who's out for weekFrom – weekTo: outSummary; holidays: holidayCount; work anniversaries: anniversaryCount.