Update May 2019: A follow up post with additional information has been published.

Two years ago, I wrote a blog post about how you can schedule Twitter content with Azure Functions. I used Azure Table Storage to store relevant content that I want to get published, and Azure Functions to query it periodically to check if anything needs to get posted to Twitter.

Today, I thought I should finally check if the same functionality is also available with Microsoft Flow. So basically, I wanted to test if I can more or less recreate what I developed previously, by simply using what’s available out-of-the-box in Office 365.

First thing to consider: how often do I want my Flow to check if there’s new content to be tweeted? While I was able to schedule my Azure Function to run every minute (which I barely used), Flow allows only checks every 5 minutes in the Free plan, and a maximum of 2,000 runs per month. I decided to proceed with an hourly schedule, I didn’t think that I’d need a finer granularity. With 24 runs a day, that’s 720 runs a month, well below the limit. And as I don’t have any other flows running, I will not hit the limit in my single user tenant.

As for the storage, I create a new SharePoint list with the following columns

  • The Title column should contain a simply text to help me get a quick understanding of the tweet’s purpose
  • Content is a multi-line text column to store the actual tweet
  • TweetDate is a DateTime column to store when the tweet should be published (well, not before this date and time)
  • Sent is used to keep track of tweets that have already been published. I used a choice column with values Yes and No (default)
  • Lastly, TweetLink is a text column in which I planned to store the link to the published tweet

Here’s how the list looks like with some sample content:

The Flow itself was quite straight-forward to set up, as there’s obviously a connector to SharePoint Online lists, and also a connector to Twitter. My complete flow was thus quite simple: 1 trigger and 3 actions, of which 2 are in an Apply to each loop. That was definitely much easier to set up than my Azure Function.

We start the Flow with an hourly trigger, which retrieves the items from my Tweets list. I use a Filter Query to fetch only those items which need to be published (TweetDate is less than or equal to right now) and have not been published yet (Sent equals No):
TweetDate le ‘@{utcNow()}’ and Sent eq ‘No’

I then use an Apply to each action to loop through all the content that needs to be posted. First I use the Post a tweet action for which I simply use the Content from my retrieved item as tweet text. This action will return a TweetId, which I use in my last action.
I update my SharePoint list item and set the Sent Value to Yes (so that we dont post the same tweet over and over again), as well as the TweetLink to the URL of my tweet with the following expression:
concat(‘https://twitter.com/modery/status/’, body(‘Post_a_tweet’)[‘TweetId’])

That’s it! Without any development, and with just a few OOTB functionalities and some expressions, I was able to recreate the required functionality within a few minutes.
And as a bonus, I can even make use of it now from within the SharePoint app on my phone and schedule new Tweets anywhere, anytime.

Here’s the homepage of my dedicated site which contains my list, showing me immediately the next scheduled tweets:

Here’s my list:

And lastly, here’s how I could add a new entry:

One thought on “Scheduling Twitter Content with Microsoft Flow”

  1. Thank you for this, this is something i have been looking to do for some time. However i was wondering if it is possible to create a list of tweets and for the flow to cycle through each one everytime the flow is run, rather than specifying a date?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.