Photo by Ian Turnell from Pexels

There’s a lot you can do with Microsoft Flow and implementing the approval action. This will allow you to put in a process to control any Flow you want to. Most of the sample approval templates in Flow are focused around business processes.

In this post, however, we’re going to cover the following scenario:

I am at a developer conference and I want to watch Twitter for tweets about the conference that I might want to retweet.

Note: Unlike the Flow actions I have made use of in previous posts, the Approval action is one of the Premium actions and requires a paid premium subscription to Flow.

For this process, we’re going to use one of the templates from the predefined list in Microsoft Flow as our starting point. In your main Flow dashboard, create a new Flow from a template by selecting New -> Create from template. In the templates list, search for “Retweet with approval”. Create a new Flow from that template.

Default-Template

Default-Template

Let’s look at the predefined steps in our Flow. Our trigger is the Twitter “When a new tweet appears” trigger. This is followed by the “Start an approval” action and finally, a Condition action.

“When a new tweet appears” trigger

There are several types of text you might put in here. You can monitor for a #hashtag, a @username, a “specific string”, or conditional strings. The help text that shows up in the “Search text” box states:

Search term like "happy hour", #haiku, from:@username, love OR hate

Most conferences will have a hashtag they post for attendees to use. Many conferences also have their own Twitter username. For our example, we’re going to monitor for mentions of the fictional #barretconf2018 hashtag or anything from the @barretblake username. Let’s put the following in the search box:

from:@barretblake OR #barretconf2018

“Start an approval” action

The Approvals action  in Flow has one big downside for our particular example. With the default settings, it will send an email to you notifying you each and every time the Twitter search triggers. This is fine if your approval process is for the occasional file creation or time off request. However, if you are following a big, popular conference tag like #msbuild, or even a small one like #stirtrek, your email inbox will be flooded with notification emails each time the trigger runs.

As such, the first thing we are going to do is to click on the “Show advanced options” text at the bottom. This will reveal the “Enable notifications” option. Change this to “No”. This will prevent your email provider from hating your guts. Don’t worry. Twitter will still hate your guts. It’s just how they are.

For our example, we’re going to assume that you’ll use your time waiting between sessions to check the Approvals list, so you don’t need the email notifications anyway. There are two ways you can do this. In the web interface, you can click on the “Approvals” menu item in the left menu and go through your waiting Approvals list. Or you can download the Microsoft Flow app to your iOS or Android phone and access the Approvals list there.

We’re also going to change a couple of the other default settings in the “Start an approval” action. First, click in the “Assigned to” box and select your Flow username. If your username doesn’t appear to select, enter the email address for your Flow username. I’ve tried putting other email addresses in there but it throws an error indicating the user is invalid when it tries to run.

Note: If you create a Team Flow, you can add other users as possible approvers for the Approvals action. One of the options in the Start an approval action allows you to set whether any Flow approver can approve it, or if it requires that all approvers in the “Assigned to” box must approve a Flow for it to continue. Team Flows require a paid Microsoft Flow plan.

Next, change the Title to be something unique so you’ll know what the request is for. In our case I’m going to put “##CONFERENCE RETWEET REQUEST##”.

Lastly, in the Details field, enter something that will show you the username and text of the tweet you’re looking at retweeting. You can see below what I selected for this example.

approval-action

approval-action

Condition action

The Condition has nothing in the “If no” branch. That is fine. We don’t want to do anything if we choose not to retweet something. In the “If yes” branch, the default action is to “Post a new tweet” that contains the text of the tweet to be retweeted.

The default would simply copy the text of the original tweet into a new tweet from you. This would be passing off the original tweet as your own content without giving credit to the originator. Since we’re not jerks, we don’t want to do that. Instead we will be making a couple of changes to fix that.

We are going to take advantage of Twitter’s “smarts” and pass in the URI to the original tweet. When Twitter detects this URI, it will treat it as a retweet with comment. And that’s good enough to give credit where it’s due. We’ll throw on a #hashtag as well just for fun.

Doing this will require a couple of additional steps. At the top of the Flow, just below the trigger, add an “Initialize variable” action. I’ve mentioned previously that in Microsoft Flow, the creation of variables to be used anywhere in the Flow must be the very first thing after the trigger. Set the variable as type String and call it whatever you like. It doesn’t need an initial value.

Now, in the “If yes” branch of the Condition, add a “Set variable” action above the “Post a new tweet” action. Because the Twitter trigger in Flow doesn’t have the URI of the tweet built in as an output, we are going to have to build it ourselves based on what we know about Twitter and the outputs it does give us. Set the value of our string variable to the following:

concat('#barretconf2018 https://twitter.com/', triggerBody()?['UserDetails']?['UserName'], '/status/', triggerBody()?['TweetId'])

This will build our new tweet text, keeping the proper reference to the original content so we don’t come across as assholes stealing others’ tweets.  Obviously, if Twitter someday changes the URI structure that points to tweets, this Flow will be broken. But since this example is meant for short term use only, we can live with that.

Our last step is to change the tweet text in the “Post a new tweet” action to instead use our variable. Save your changes and bang, you can join in the Twitter action on conference day and see what people are saying.

Fin

As I mentioned above, this is a Flow that should be used with care. If the user and/or #hashtag you’ve chosen to follow is extremely active you can quickly find your Approvals list a bit overloaded with items waiting for your response. Thankfully, Flow allows you to turn your Flows on and off at will, so if it does get a bit much, turn it off and stop the tidal wave. Still, it’s a good way to play around with the Flow Approvals process in a way that’s not tied to SharePoint or Office.