December 19, 2024

Everyone has a love-hate relationship with Twitter, but there’s something we can’t deny. Twitter plays a massive role in everyone’s lives, especially when running a business. Companies with a lot of presence in social media tend to automate their posts, so with that in mind, Microsoft created the “when a new tweet is posted” trigger that helps us automate some actions, like retweeting or keeping track of what the competition is doing, to name a few examples.

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

Where to find it?

You can search for the “when a new tweet is posted” trigger or look at “Standard.”

In the list of connectors and triggers in Power Automate access the "Standard" option

You may need to expand the following:

Since Twitter is not the most common option, expand it and search for it.

Find “Twitter”:

Twitter connector from the list of all available connectors in Power Automate

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

Select "when a new tweet is posted" in the Twitter's connector in Power Automate

And here’s what it looks like.

The "when a new tweet is posted" trigger in Power Automate has many functionalities like searching for a term, hashtag username, and a lot more.
Pro Tip:
Power Automate tends to save the most common triggers on the main screen, so check there before going through the full hierarchy. Also, you can use the search to find it quickly.

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 much 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.

Example of a hashtag search in the "when a new tweet is posted" in Power Automate

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. 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.

Example of a user search in the "when a new tweet is posted" in Power Automate

Finally, let’s look for a string.

Example of a random string search in the "when a new tweet is posted" in Power Automate

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. Doing this will signal to Power Automate that you want multiple parameters, 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 they are not applied to this trigger. I know that Microsoft can’t do much 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 the 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 expect, why Power Automate should trigger the Flow, and how 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” you are 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. 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, debugging triggers that parse a single data point instead of multiple simultaneously is much easier. 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.

Back to the Power Automate Trigger Reference.

Photo by Chris Carzoli on Unsplash

Manuel Gomes

I have 18 years of experience in automation, project management, and development. In addition to that, I have been writing for this website for over 3 years now, providing readers with valuable insights and information. I hope my expertise allows me to create compelling, informative content that resonates with the audience.

View all posts by Manuel Gomes →

Leave a Reply

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

Mastodon