Flow and Twitter

The default Twitter web part it great and easy to use. You can follow a Twitter user (@), a URL of a user account, tweet or collection. These options where not enough for a communications department who wanted to show the #, @Company, the company name and from:[Company] on a SharePoint page. We were able to do this with a PowerAutomate Flow and a custom content query web part. In this post I will explain how you can do this.

SharePoint: Create a list

  • Create a SharePoint list to store the twitter information.
  • We created the following columns to store the information, your requirements might be different.
Column nameType
Favorite countsNumber
Followers countsNumber
LocationSingle line of text
Media urlsMultiple lines of text
Original tweetMultiple lines of text
Original tweet tweeted bySingle line of text
TweetMultiple lines of text
Tweeted bySingle line of text
Created atDate and time
TweetIdSingle line of text
Original tweet idSingle line of text
TypeChoice
RetweetsSingle line of text
ProfileImageUrlNumber
NameUserSingle line of text

Flow: Getting the information

  • Open PowerAutomate and create a new Flow.
  • Add the trigger When a new tweet appears.
  • Enter the required search term, see the example below.
  • We wanted to be able to filter on the different types of results, for example on # or @. This information is added to the item that will be created in the SharePoint list.
  • A tweet can be multiple types so we need an array and append all the types to it.
  • Initialize a variable called TypeTweet as an array.
  • Add a scope called Append to array – TypeTweet.
  • Add a condition that filters the #Office365 out of the TweetText.
  • If the result is yes then append the value #Office365 to the array.
  • Repeat the steps for all types of tweets.
  • Add a scope called Create list item.
  • Add the SharePoint Create item action.
  • Connect all the columns to the correct information.

Custom Content Query Web part

We used a variation of the React Content Query Web Part from Github. This is a modern version of the CQWP where you have all the freedom to grab and style items from a list or library.