cancel
Showing results for 
Search instead for 
Did you mean: 

Tweet Today's Events from an RSS Feed Using Flow

I started a little community project a few years ago called 
Melbourne Theatre Calendar with the aim of listing all of the theatre shows in Melbourne in a single place. It came out of frustration that when I wanted to go see a show I couldn’t easily see what was playing ‘today’ or ‘tomorrow’.

Now that the site has a lot of content, I want to expand how I can share the information starting with Twitter. The site is built upon WordPress with The Events Calendar plugin and that plugin provides an RSS feed of the next 10 events.

After playing around with some online services that can Tweet from an RSS feed, I decided I could get a better outcome for free by using Microsoft Flow.

My goal was pretty simple, at 8am every day (local time), tweet all today’s events as individual tweets from the RSS feed. No events today, no tweet.
One small challenge is that the RSS feed contains the next 10 events regardless of event date so this needed to be accommodated.

A high level view of the resulting flow looks like Recurrence, List all RSS feed items and Apply to each.

In more detail, it it’s built as follows:

Recurrence, this is the easy part. Interval of 1 Day, running at 8am.

List all RSS feed items, also pretty straight forward. We can’t use the since option as the RSS feed could also be showing future events so we’ll do the filtering in the next step

The Apply to each action step is where things get more interesting and for me, actually started with the Condition action.

The finished result is pictured below but I’ll walk you through how it was created.

Choosing a new action below the RSS feed, I selected the Condition Control action.

You are then presented the condition statement area and If yes and If no sides of the condition.

The condition statement is just a true or false, yes or no test. 
If something IS something where the IS could be equal to, greater than, contains, does not contain and so forth.
For me I wanted the statement along the lines of [date of RSS feed item] [is equal to] [todays date].

Starting on the left side of the statement, I chose the dynamic field from the RSS feed called Feed published on.
When you do this, Flow automatically wraps an Apply to each action around the condition as it reccognises that an RSS feed has multiple items. It puts the dynamic field Body in in the select and output from the previous steps box for you too.

The test is is equal to.

The right hand side of the statement was more of a challenge to figure out and I turned to the Microsoft Flow Community for some suggestions after hitting a few brick walls.

As my test is related to the date only, I needed to first convert the Feed published on value to a date only format.
This is achieved using the formatDateTime function with the yyyy-MM-dd format string.
The end result on the left side of the statement therfore became:

formatDateTime(item()[‘publishDate’],’yyyy-MM-dd’)

With the feed item date now on the left, I needed to get today’s date to compare it to.

It was suggested I use the utcNow function but I found this wouldn’t work due to timezone differences. As I was running this flow at 8am UTC+10 this would return a value of 22:00 UTC the day before and never match the UTC date values of events that were afternoon and evening based.

Enter the getFutureTime function. By using this to add 4 hours to the returned value, I could ensure that converted date would always be the same date as the event. It has it’s own date format string too!

getFutureTime(4,’Hour’,’yyyy-MM-dd’)

Now onto the the actions. I first built this Flow with the actions outputting to email. I reccomend this whilst you’re nutting out problems with your Flow as you can use obvious text to indicate whether the email was the result of the statement being true or false.

The If no was always going to be blank as if the feed item wasn’t for an event today, I didn’t want it tweeted.

The If yes was the Post a tweet action. As the RSS events were is UTC, I needed to convert them to the correct timezone with the convertFromUtc function. With this you set the timezone and the display format.

convertFromUtc(items(‘Apply_to_each’)?[‘publishDate’],’AUS Eastern Standard Time’,’f’)

The finished Flow looks as below.

Meet Our Blog Authors
  • Working daily with Microsoft Cloud to deliver the needs of my company, my customers and various Microsoft communities and forums. | Office 365 | Flow | PowerShell | PowerApps | SharePoint |
  • Co-founder of https://plumsail.com, Office 365 and SharePoint expert. Passionate about design and development of easy to use, convenient and flexible products.
  • Microsoft Business Apps MVP. Owner of ThriveFast, an Office 365 consulting company.
  • 7x Microsoft Business Solutions MVP (CRM)
  • I'm keen in MS technologies, SharePoint, Office 365 and development for them
  • Daniel is a Business Productivity Consultant & Microsoft Business Solutions MVP who is very enthusiastic about all things Office 365, Microsoft Flow, PowerApps, Azure & SharePoint (Online). Since the preview, Daniel has been working with Microsoft Flow and later on with Microsoft PowerApps. That led to him being awarded an MVP Award for Business Solutions. He loves to blog, present and evangelize about improving productivity in the modern workspace with these amazing tools!
  • Michelle is an Office 365 solution architect in Twin Cities, MN. She has been delivering business collaboration solutions for years with her focus on SharePoint and Office 365. Michelle is a recent board member of the Minnesota Office 365 User Group and has been a member of the SharePoint community since 2009. She is a frequent speaker at MNSPUG and SharePoint Saturday and co-chaired the Legal SharePoint User Group for 4 years. Her most frequent projects have involved rolling out a large deployment of Office 365, SharePoint Online intranet, build of a "CHAMPS" Office 365 user adoption program and most recently, SharePoint On-Premise to Online Migration. Michelle is very excited about cloud technology as it is shifting her IT Pro focus to collaboration strategy and technical adoption.
  • I'm a Microsoft Office Servers and Services MVP with a special interest in SharePoint, Office 365, Microsoft Flow, Microsoft Teams and PowerApps. I work at Triad Group Plc ( https://triad.co.uk)
  • Passionate #Programmer #SharePoint #SPFx #Office365 #MSFlow | C-sharpCorner MVP | SharePoint StackOverflow, Github, PnP contributor