top of page
  • Writer's pictureEd G.

Birthday Bot - Part One - v2.0 - Continuous Improvement

Updated: Mar 22, 2020

One of the things I teach in my "What to do when your flows don't flow" session, is to not worry so much about 'elegance' or 'efficiency'. Build the thing with the tools you have, and then go back and make it better as you learn more. I love that Power Automate affords us, as Makers, the opportunity approach problems in different ways.


That is exactly what happened as I was building the second half of the Birthday Bot. With each step in the chat-bot half, I found something I could have done better in the notification half, so I went back and made some changes that improve the performance; I also better equip us to work through "Part Two".

Throughout this, I'll reference version 1.0 to keep from building the whole thing over again from scratch. If you're doing this for the first time, keep both open so you can see where I have made changes.

Here we go.


The first thing I found out was that I can eliminate the variable that was keeping track of how many birthdays we have coming up by using the length() function instead. When you wrap this function around a string, it will tell you how many characters are in that string, when used with an array, it will return the number of items in that array.

This is an obvious replacement for counting how many birthdays there are in 7 days, but I will also use it in Part Two if the birthday person has more than one email address.

To prepare for that, I needed to initialize an array variable to hold all of the email addresses. If you aren't familiar with variables yet, take a look at Joe Unwin's video, Power What: Variables.

I'll explain why later, but I also had to initialize a string variable to hold just a 'carriage return' or 'line break'. I did this by just clicking in the "Value" box and hitting the <Enter> key.


Everything else remains the same until we get to the "Yes" path of the first condition which matches the "MM-dd" formatted birthday of each contact, to the same-formatted date that is 7 days out. Since we got rid of the varBirthdayCount, we won't need the "Increment Variable" step, but I did decide to keep the varBirthdayList array which will seem superfluous in a moment, but I'll explain why I kept that in a bit.

The new "Yes" path for v2.0 of the Birthday notification

My original version for the chat-bot part (Birthday Bot - Part Two) was replicating most of the notification process, but using an intent trigger from AtBot. That was my 'fix' for not being able to initiate a chat conversation from the middle of a flow, and is the reason why I changed the notification text to have the user respond with the trigger intent, "Birthday".

This method would cause a problem if the user didn't respond to the notification until the following day, as the birthday would now be six days out and be missed by the original filter as it tried to match the 7-days-out date with the contact's birthday. It was also tremendously slow as it worked to sift through each contact all over again.

The new method stores all of the pending-birthday-contact-details in a SharePoint list, where I am also tracking if they've been 'processed' by the Birthday Bot yet.

In the image above, you can see the Apply to Each loop where I am appending each eMail Address to the varEmailOptions array. If there are multiple eMail addresses, though, it will end up looking like this: ["",""] and I want to have them stacked on top of each other with a line break in between so that the chat-bot part can easily present them as options to the user. To do this, I use the join() function to tie the two items together using my varCR as the delimiter.

I also changed the eMail column to "Multi-line text" in my SharePoint list to accommodate this and was able to end up with the results at the bottom of the image to the left.

You can see that with just a few functions, it is easy to multiply the power of your flow, as well as simplify most instances.

This is the Slippery Slope that others have warned me about, so I'll try to keep things firmly in the 'maker-space'.


The last part of the main "yes" path inside the Apply to Each loop is to add the information to my SharePoint list.

The only weird bit here is that I had to use expressions at first to resolve each of the sub-arrays that were the Home and Business addresses. The output from the Outlook Get Contacts action for the addresses would look like this:

{\"street\":\"123 Main Street\",\"city\":\"Anytown\",\"state\":\"NE\",\"countryOrRegion\":\"US\",\"postalCode\":\"15745\"}"

So for each of the fields, I started with an expression:


This would grab just the street address portion ("123 Main Street" in the example) of the Business Address and drop that in the BusStreet column of that SharePoint item.


Finally, I was able to clean up the part that counts the birthdays and react appropriately in the notification. If there are no birthdays, the flow just cancels. Then inside the SMS part, I added a big long If() statement that said if there are multiple birthdays, send something that says "You have 3 birthdays...", but if there is only one it will send "You have a birthday". It's the little things.

I put both of the expressions inside the comments of the action so you can see what is happening.


I feel pretty good about this version, and it feels like the chat-bot part will be better because of these changes. Building flows is an iterative process, so this is a great example of how you shouldn't feel like you need to 'nail it' the first time.

Get in, make mistakes, learn some things, and have fun! Try. Fail. Learn. Repeat.

263 views0 comments


bottom of page