Automate Social Media Posts with Azure Logic Apps and an RSS Feed

Hey everyone, I just thought I would piece together a quick and simple way to add some automation to your social media presence using Logic Apps to post social media posts on a schedule from an RSS feed.

As I work primarily in the world of Microsoft Azure, I thought I would use the Azure Updates RSS Feed to check twice a day and post out any updates mentioned on this feed to my social media networks.

Azure Updates RSS feed: https://azurecomcdn.azureedge.net/en-gb/updates/feed/

So the first thing we shall do is Add a new Logic App:

I have selected the consumption plan in order not to have to spin up any resouses.

Next we click Review and Create:

Once our Logic app has been created, lets jump on over to the Logic App Designer, where I will select the ‘Recurrence’ as the trigger as I just want to check and post at 2 times throughout the day:

Once here, we can add additional parameters to our recurrence block, I have opted to set my recurrence to 1 time per day, at 11am and 6pm UTC by adding the parameters, ‘At these hours’ and ‘Time Zone’:

Now we have our trigger defined, we need to do something! So the first thing we are going to do is to get our data from the RSS feed URL, so lets do that:

Click on New Step

Search for RSS and select the List all RSS feed items

Here we can paste our RSS feed URL into the box and leave the Publish Date property set as is.

At this stage we could save and run our Logic app to make sure we are receiving the RSS feed data:

Once the run has completed, you should see that we have received some data in the body of the reponse:

This image has an empty alt attribute; its file name is image-25.png

Click New Step

This next step I have added to just ensure that the body received is formatted as JSON rather than being a big lump of string data. That way we can pick out the elements of our RSS data to use in our social media items! SO we will search for and add a ‘Parse JSON‘ action:

Here we are presented by two parameters we need to provide.

The first is the Content, this will be the ‘Body’ of the List all RSS feed items action:

Next, we can see it is asking for a schema of our RSS data, which we may or may not know! However, see the link at the bottom to use sample payload data to generate our schema for us! Lets use that!

If we run our Logic App again and this time take a copy of the output from this Action:

Now go back to our Parse JSON Action block and paste this in as sample data:

Click Done

We can now see that we have generated our JSON Schema, which is great for use within the remainder of our Logic App.

If we then save and run our Logic App we can see our JSON output:

In this case we didn’t really need to use this Parse JSON step as we can see that the content and output are exactly the same! However, it is a handy step to include just to be sure that your output is properly formatted. It seems that the RSS feed action does the job for us! But no harm in double checking!

So

from here, we could remove the parse JSON step if we wanted to, but I will leave it in so you can see how the output from one stage can be the input of the next.

This image has an empty alt attribute; its file name is image-25.png
Click New Step

This time we are going to use the Filter Array Action to only find published posts based on the criteria we want to match. So we could now filter on any of the properties of the RSS data.

I’m going to do something basic that to be honest you could have used the initial Trigger to do, but this is for illustration, i’m going to filter only the posts within the last 2 days by using the Body Output of the Parse JSON action, and then adding a filter action on the ‘publishDate’ property:

Now we need to create our value, so I am going to suggest we take todays date and take away 2 days, therefore our condition and filter should give us what we need.

I am using an expression here to basically subtract 2 days from todays date. (Primarily for purposes of this blog, unfortunately the RSS didn’t have any new data within 1 day!!)

We now have a way to filter on any of the properties if we wanted to!

The final point is to now iterate through each item and send out a social media post as follows:

Select a For Each item in our ‘Body’ of the Filter Array, we want to send a post to Twitter and LinkedIn.

This is the start of our For Each loop. Next we can just add our first action.

When you set up the link you will be prompted to log in to your twitter account.

Here we are simply adding the ‘summary’ text and the ‘primaryLink’ URL to our twitter post!

Lets add in LinkedIn:

Here you can see I have split out the Title, URL and summary description as well as adding my own customer picture for each post!

Finally, in order to make sure the LinkedIn post is successful in the event that the twitter posting were to fail for some reason, we should up date our ‘configure after run’

So lets give it a run and see what we get!

Here is my LinkedIn Example:

And here is my Twitter example:

As you can see, there is so much flexibility using just these few blocks in Logic App. I have deliberately introduced a few action blocks that I have found useful, you could now look to do something cool for your own social media!

I do hope you have found this article helpful!

Overview diagram:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s