The Birthday Bot started as a simple idea to tie in plenty of fun connectors into a use-case that could translate well to an actual business need. What began as a quick endeavor, however, turned into a multi-part journey as each 'new thing' turned into a series of other 'new things' to learn.
One of the first things I bumped into was my inability to trigger a chatbot from an event. Meaning: My original design would see that there was a birthday coming, notify the user, ask how to proceed and move on from there...but the only way to trigger the bots (that I knew) was for the user to send an "Intent". This is why I changed the dialogue in the notification from "Would you like to review the upcoming birthdays?" to "If you'd like to review, respond with 'Birthday'". This allowed me to break the process into two separate flows: One to recognize the impending birthday and send the SMS notification, and then another to trigger the chatbot conversation walking the user through sending birthday wishes.
I was also able to clean up my expressions by integrating my newfound knowledge on the length() function. In this expression, I'm checking to see if there are multiple birthdays or a single birthday, and adjusting the grammar accordingly..."You have x birthdays" vs. "You have a birthday". Details on my use of the length function can be found in Birthday Bot - Part One - v2.0.
I chose AtBot and Twilio for handling the interaction with the user and I'm quite happy with them both (totally unsponsored opinion!). The beauty of Power Automate is that you can find a connector that suits your needs specifically and plug in the same steps for that connector. If you're new to AtBot, check out their Getting Started Guide, and then also this walk-through from Matt Wade on connecting your AtBot account to your Twilio number to interact with your flow via SMS. While both services require a paid plan to integrate this way, I feel they are very reasonable and have attached a pic to show the current pricing. During my building of the Birthday Bot, I have been using both services way more heavily than I would in production, and I've barely scratched the surface on a $20 payout. With all of my testing, I have only used 151 messages in AtBot this month...which means that even if I kept up this pace, I'd only use about 600 messages per month. The production version of Birthday Bot won't see nearly that much volume.
We only want this process to trigger with a very specific word, "Birthday", so we don't want to add the ambiguity that a natural language layer would add. See my other article, Microsoft Flow: Hungry Teams, Natural Language Chatbots, and Yelp, on how to layer Luis.ai on top of a chatbot for a more 'natural' feel.
This means that our chatbot will be triggered whenever it receives the exact intent, or 'utterance', of "Birthday".
The next steps are to initialize some variables: A carriage return similar to the last post, and an ID for when we select a quote to put on the card, and also when we select a card. You'll see later how we'll use a Do Until loop as a make-shift approval process.
Note that the Quote ID is an integer since it's coming from a SharePoint list which I created, but the Card ID is a string because that is being sent from our third-party card provider. We will set them both with a default value so the Do Until loop can go until they are something different.
The next couple of steps will just be Compose actions that we will use to store our login credentials for the third-party card provider, HandWrytten. We will use a security technique I learned from Pieter Veenstra to hide that information from the run history.
The last part I'll cover in this episode is grabbing all of the unprocessed birthdays from our SharePoint list that we wrote to in our previous flow. We use a List Items action with the highlighted OData filter to only grab the rows we want.
The next post will cover how we process through each birthday, choose a random quote and approve it, and then select how we will send the birthday wishes.
Get in, make mistakes, learn some things, and have fun! Try. Fail. Learn. Repeat.
Comments