Halloween has been and gone, which means Christmas is coming!! And I wanted to be the first blogger on DEV to release a Christmassy blog 🤣 — much to the annoyance of the scrooges out there!
Recently I've been doing a tonne of bot development both at home and at work and been absolutely loving it — bots that integrate with Alexa, Google Home, Luis.ai and more.
During this time I've done quite a bit of research into the best and quickest methods to create bots and was pretty shocked when I bumped into Microsoft Flow. Microsoft flow is cloud-based software that allows you to easily automate workflows and tasks across multiple applications and services. For me, the ability to really quickly auth with multiple apps instantly has made the process so much more enjoyable allowing me to spend more time on what I want the bot to do.
I've just created a new twitter account @GrinchEndOfFilm because we want our bot to love Christmas and spread as much Christmas cheer as possible!
The first thing we need to do is sign up to Microsoft Flow which can be done here!
- Automated Flow: Triggered by an event — our trigger is going to be when somebody tweets about Christmas!
- Scheduled Flow: So you choose when and how often your flow runs — we're going to create a flow that tweets how many days until Christmas and it's going to do that every day.
Goal: Create a bot which retweets lovely Christmas tweets
So our bot flow is going to be called SpreadChristmasCheer with a trigger of when somebody tweets.
When you click create you'll be presented with a lovely UI view of your bot flow so far. I want my bot to trigger when somebody tweets with the words "I" "love" "Christmas" in them:
And I want to just simply retweet them. So I click the + New Step button under the flow and create another twitter step with the action of Retweet.
A quick save and test and it should be running!
And there we have it, our Grinch (At the end of the film) has retweeted a pretty lovely tweet about Christmas 😄.
There is so much more you could do with this flow, for instance, you could easily implement some sentiment analysis on the tweet to be sure that it's actually a positive tweet about Christmas — that could easily be done by integrating the bot flow with Text Analytics which has an option for sentiment analysis.
Goal: Create a bot that tweets every day the number of days until Christmas.
This one is going to be a little more complicated, not because creating a schedule flow is any more difficult than an automated one I'm just going to add a few pointless steps to show some features of Microsoft Flow!
The first step is going to be getting a Calendar event from my google calendars account, this event is Christmas — This is a pointless step as I am literally only going to use this event's name (Christmas) as an output to the tweet). It's just purely to show how quickly you can integrate other accounts and services, having to code this up would take ages, well, for me, it would.
My endpoint returns some JSON, and in that JSON one of the values is the number of days until Christmas, I want to grab that value — luckily Microsoft Flow has an action which parses JSON for us and pops the values into variables we can use in other steps.
It asks for the content, which is the data we get in the body of the http request:
You can use an example payload to generate the Schema:
Lastly, let's add a step to post a tweet.
Let's save this and get it running!
And there we have it! This is just a very basic introduction to what you can do with Microsoft Flow, there are hundreds of actions and integrations available. Pretty much any kind of flow you want there will be some way to create it.
Like I said, I'm new to this too but am finding it very, very fast and effective.
Thank you, if you like my rambling check out my personal blogging site at https://codeheir.com/