This flow will check against off hours, weekends, and a sender exclusion list to decide if it needs to send an after hours email or not.
This flow Section breakdown:
*This needs to be created from an automated flow*
- When a new email arrives in a shared mailbox (V2) Operation - Trigger for the flow.
- Original Mailbox Address will be the shared email you are wanting to watch
- Folder will most likely be the inbox. Whichever folder within the email you want to watch
- utc to est - Convert Time Zone Operation - emails (at least on my tenant) seem to come in as UTC instead of our time zone. You can check for yourself by running a test and check the output from the "When a new email arrives" section. If you search for Received you will probably see the time is different than your local time
- Base time is set to pull the time the email was received
- Format String should be sent to the sortable date/time pattern
- Source Time Zone: UTC
- Destination: Whatever your time zone is
- val weekday - Compose Operation - further along, the check will need to know what day of the week it was when the email was received. The input provided calculates that and provides a number 0-6 representing the days
- Sunday - 0
- Saturday - 6
- Date Removal - Compose Operation - further along, the check will not like the format the time and date are currently in, so the date part needs to be dropped. The input formats it so that only the time is listed
- Make sure to capitalize the HH at the end section. HH will be 24-hour time, hh will not.
- Weekend and Time Check - Or Condition Operation - This is the section doing all the time/date comparing. It checks to see if any of the conditions are met. If NONE of the conditions are met (email arrived between 8am-4:30pm M-F), it will end the flow. If ANY of the conditions are met, it will continue to the next step
- Make sure it is set to an Or function. That way only one of the conditions need to be satisfied
- First two are checking the day of the week. They check to see if the day of the week is equal to 0 (Sunday) or 6 (Saturday).
- The last two check on the time the email was received. The first checking if the time is after 4:30pm (16:30 in 24-hour time) and the second checking if the time is before 8:00am (8:00 in 24-hour time)
- Weekend and Time Check Condition Results
- If no - Terminate Operation - You'll want to set the flow to terminate and set the status to cancelled to signify it went through the flow and found it did not need to sends the email successfully
- If yes - Flow continues on to go through exclusion check
- FromValue - Compose Operation - Makes an easily accessible value of the From for the initial email
- FromCaps - Compose Operation - Converts the from email address to all caps. The From Check below is case sensitive, so it is best to just make it compare everything in all caps to avoid things slipping through.
- From Check - Condition Operation - All of the email addresses and key words you want to be excluded will be listed here. For the example, I have VOICEMAIL@FAKECOMPANY.COM listed so that if that if the watched email receives an email from that address, an auto reply will not be sent out. I also have PRINTER on there to catch any email address with the word printer in it. That prevented me from needing to add every printer email address to the exception list individually.
- Using key words instead of individual emails can make the process much easier.
- Make sure everything listed is in ALL CAPS or else the check will not work properly.
- Also make sure to set it to an Or condition.
- You can add a total of 10 individual checks but if you group some together, you can go past the 10 limit, then ungroup them.
- From Check Condition Results:
- If Yes - The flow is terminated in the same way as the other termination. This would indicate that the flow detected that the from address included one of the keywords/emails listed in the From Check
- If No - The flow continues to send out the email. Meaning the flow did not see any of the emails/keywords in the from address
- Send an email from a shared mailbox (V2) Operation - This is where you will compose the email to be sent out.
- Original Mailbox Address - probably want to make it the same email you are watching, but you do you!
- To - Set this to From so that the email is sent to the initial sender
- Subject and Body - You may want to test a couple rounds with this to get the formatting right. It can be a bit finnicky.
- Advanced Options - Up to you, but I recommend changing the Importance setting from low to Normal.