September 25, 2022

Everyone has a love-hate relationship with Twitter, but if there’s something we can’t deny. Twitter plays a massive role in everyone’s lives, especially when running a business. So, Microsoft created the “when a new tweet is posted” trigger that helps us automate some actions and keep our social people happy.

So let’s investigate how “when a new tweet is posted,” you can use trigger in our case.

Where to find it?

To find it, you can search for the “when a new tweet is posted” trigger or by looking at “Standard.”

You may need to expand:

Find “Twitter”:

Select the “when a new tweet is posted” trigger:

And here’s what it looks like.

Pro Tip:
Power Automate tends to save the most common triggers in the main screen, so check there before going trough the full hierarchy. Also you can use the search to quickly find it.

Now that we know what it looks like let’s understand how to use it.

Usage

The action is super versatile, and you can do a lot with it. Contrarily to other automation tools, we don’t do operations on our account but use the connection to find pieces of content that “fit” the categories. For example:

  1. Check if someone posted something with a hashtag.
  2. When a handle posts something.
  3. Search by a word or sentence.
As a disclaimer I have to say I had mixed results while working with each of the options. Sometimes Power Automate would not fire when something happened, and I needed to force it manually. It also takes a bit of time for the indexation to start firing. Don’t think that you will have instant results by enabling the Flow.

We can do a lot, so let’s look at examples of each; if you want to monitor a hashtag, here’s how to do it.

Don’t forget to include the “#” sign so that Power Automate knows that you want the hashtag and not the string with that word.

Here’s how to do it for a handle. As before, don’t forget to include the “@ “sign and the “from:” indication. Power Automate will then know that you want tweets from that handle instead of searching for that string.

Finally, let’s look for a string.

The trigger returns some good information that we can use to automate things in all cases.

There’s another thing you should know. You can use operators like “AND” and “OR” to query Twitter. By doing this, you’ll be signaling to Power Automate that you want multiple parameters and not only one.

Outputs

The trigger returns a lot of information in a JSON format, although the conversion from JSON is done automatically for you. Here’s an example:

{
  "headers": {
    <redacted>
  },
  "body": {
    "TweetText": "⭐ #OnThisDayInMusic ⭐ Best birthday wishes 🎈🎂🎉 to @TheDangelo. Revisit a wonderful live performance from the #NeoSoul legend at @MontreuxJazz 🇨🇭2⃣0⃣0⃣0⃣ via @YouTube ➡️ https://t.co/dWHF63nAzN. #MusicNews https://t.co/r3tztlxlWR",
    "TweetId": "1492106142541131778",
    "CreatedAt": "Fri Feb 11 12:00:01 +0000 2022",
    "CreatedAtIso": "2022-02-11T12:00:01.000Z",
    "RetweetCount": 0,
    "TweetedBy": "meltingpot4u",
    "MediaUrls": [
      "https://pbs.twimg.com/media/FLR4CyJXEAA7ZLY.jpg"
    ],
    "TweetLanguageCode": "en",
    "TweetInReplyToUserId": "",
    "Favorited": false,
    "UserMentions": [
      {
        "Id": 2438765688,
        "FullName": "D'Angelo",
        "UserName": "TheDangelo"
      },
      {
        "Id": 20156427,
        "FullName": "Montreux Jazz Festival",
        "UserName": "MontreuxJazz"
      },
      {
        "Id": 10228272,
        "FullName": "YouTube",
        "UserName": "YouTube"
      }
    ],
    "UserDetails": {
      "FullName": "Mr Boogie 🇺🇬🇫🇷🇬🇧",
      "Location": "London, UK",
      "Id": 219281179,
      "UserName": "meltingpot4u",
      "FollowersCount": 1888,
      "Description": "Music show on @ShoreditchRadio 🇬🇧 with #Soulsa's Mr Boogie a.k.a The #VinylJunkie. #MeltingPotTheShow #Latin #Jazz #Funk #Soul #Afro #Disco #HipHop #House",
      "StatusesCount": 17473,
      "FriendsCount": 1984,
      "FavouritesCount": 4624,
      "ProfileImageUrl": "https://pbs.twimg.com/profile_images/711232374684696576/JPe0IsWX_normal.jpg"
    }
  }
}

With this information, we can do a lot. Notice that we even have the mentions, so we can automate answering people if we want to. I’ll go over this in the future in more detail, but I want to show you what you can get from the trigger.

Limitations

There are a lot of limitations, primarily due to Twitter’s API limitations. Here are some of the rules from Microsoft’s website:

  • Maximum number of connections per user: 2
  • API call rate limit for POST operation: 12 per hour
  • API call rate limit for other operations: 600 per hour
  • Frequency of trigger polls: 1 hour
  • Maximum size of image upload: 5 MB
  • Maximum size of video upload: 15 MB
  • Maximum number of search results: 100
  • Maximum number of new tweets tracked within one polling interval: 5
  • The maximum allowed ‘Search text’ parameter value length is 470

There are more but not applied to this trigger. I know that Microsoft can’t do a lot because of Twitter’s draconian (I said it) measures regarding its API, but I wish some of them would be a bit more generous.

Recommendations

Here are some things to keep in mind.

Careful with the amount of information

Twitter is well known to be a firehose of information, so having one Flow that triggers each time something happens on Twitter is quite a lot. Try to limit the range of things you want to trigger and parse so that you don’t have thousands of triggers per Flow. Remember that Power Automate has limitations on the number of triggers and time between them, so if you need to get all Tweets for a specific topic, be careful because Power Automate may not get them all.

Name it correctly

Since you may have multiple accounts, mentioning the account you’re using for the connection is helpful. Always build the name so that other people can understand what you are using without opening the action and checking the details.

Always add a comment.

Adding a comment will also help avoid mistakes. Indicate what you’re expecting, why Power Automate should trigger the Flow, and what you will use the data. It’s essential to enable faster debugging when something goes wrong. In this case, it’s nice to know in the comment “why” are you getting the information, for example.

An automated trigger is better than a scheduled one.

Sometimes people are tempted to use scheduled triggers that pool the resources once in a while. This way, they can control when the information is fetched and save much Power Automate “triggers” if their quota is low. However, even if it isn’t, it may be more efficient to do batch tasks than once by one. I understand, and in some cases, I can agree, but it brings a lot of difficulties in the process. For example, you may need to keep track of what changed from the last run until this one so that some things may get lost in the process. Also, you’re forcing something to happen periodically even if there’s no data.

I always recommend using these “automatic” triggers instead, where they trigger one by one, but only when there’s data, so you’re always sure you get something to do. Also, it’s a lot easier to debug triggers that parse a single datapoint instead of multiple simultaneously. If something fails on one, then you can fix the Flow and repeat the process. But while parsing multiple ones, things can get a lot harder.

Am I missing something? Leave a comment or interact on Twitter. Let’s work together to make this reference as complete as we can

Back to the Power Automate Trigger Reference.

Photo by Chris Carzoli on Unsplash

Manuel Gomes

I'm a previous Project Manager, and Developer now focused on delivering quality articles and projects here on the site. I've worked in the past for companies like Bayer, Sybase (now SAP), and Pestana Hotel Group and using that knowledge to help you automate your daily tasks

View all posts by Manuel Gomes →

Leave a Reply

Your email address will not be published.