Skip to main content

Automatic Retweet - Dive in the Twitter connector in a Flow

Version française disponible ici

While I'm away

The trigger for this post is simple.. I'm heading into a well deserved summer vacation where I want to remain active in some of the social medias while being able to just relax and enjoy life!

So, I figured that building an automated Flow which would capture tweets of interest (based on keyword search) and then retweet them out with a specified delay could well do the job!

This would allow me to put content in my feed, adding value to the original tweets by issuing my message later on, thus maybe appearing on someone's radar who would not have caught the original post.


The twitter connector, as of now, doesn't offer an action to retweet nor does it allow to include direct references to users / authors (@xxx). So in order to point back to the original post I had to build the twitter URL to it. I also included a signature note where I thank the author and notify the readers of this issue.

I've added this functionality as one of my project goals. Creating a custom connectors will probably allow me to resolve this. Right now, no time, so let's just do it in a quick and dirty way and solve this out when I'm back on the saddle after drinking all the margaritas in the world ;-)


Overall, here are the core functions that my Flow will execute:
  • Act on tweets that use predefined keywords, for example:
    • #powerapps
    • #powerplatform
    • #poweraddicts
  • Only process original tweets (I don't want to overflood the feed by considering RTs)
  • Only process other people's tweets (that'd be kind of awkward if I'd process my tweets)
  • Manage and process French and English tweets only
  • Keep track of the tweets I re-posted as a reference for later BI / processing


Since I want to have a log of the tweets I posted with the references to the original post as well as the posted message the Flow generated, I created an entity in CDS.

Flow details

  • Trigger: Twitter - When a new tweet is posted
  • Criteria: set the Search text criteria to 
    • #powerapps OR #powerplatform OR #microsoftflow OR #poweraddicts"
  • Initialize variables required in the flow
    • baseMsg : the new message to post (based on the language of the original tweet)
    • linkToTweet : the URL to the original tweet
    • proceedTweet : Boolean flag to allow to stop the Flow if not a supported language
  • Only proceed on original tweets (if RetweetCount = 0)
  • Only proceed with tweets from other authors (if TweetedBy is not equal to ZePowerDiver)

  • Look for tweets in French to adapt the message accordingly (if TweetLanguageCode = fr)
  • Assemble the message and assign it to the baseMsg variable
    • insert the linkToTweet variable for the URL to the original tweet
    • insert the User detail's full name (Original tweet user full name)
    • insert their tagname too (Tweeted by)
  • If not in French, then validate if it's in English (if TweetLanguageCode = en)

  • If so, assemble the message and assign it to the baseMsg variable
    • insert the linkToTweet variable for the URL to the original tweet
    • insert the User detail's full name (Original tweet user full name)
    • insert their tagname too (Tweeted by)
  • Otherwise, set the proceedTweet variable to false so the post will not be processed at next step
  • at the outcome of the previous steps, validate that proceedTweet is still True

  • if we can proceed, then inject a delay of (n) hours, as per your preference, then post the tweet using the baseMsg variable as the Tweet text
    • For the injection of the delay, the calculation is based on current time as follow:
    • addHours(utcNow(),1)
  • Last step is to insert a new record in my CDS entity to track history

Last minute modifications

After testing the flow, letting it run for a while I made a few adjustments to ensure the posted tweet would be of a maximum of 280 characters, otherwise an error is thrown by the connector.

  • First modification: I added a call to to generate a shorter url to the original tweet
  • Second modification: I shortened the baseMsg in both languages to be right to the point nothing more

  • Third modification: as a safety net, I applied a substring function to the baseMsg variable submitted to the Twitter action
    • substring(variables('baseMsg'),1,280)

And then the failure!

After implementing those last minute changes I looked back at the generated tweets and noticed that the preview feature that you normally get with the embedded links disappeared!

So, to quickly resolve this, I've removed the part of the connector, but left the substring part.

Next step

To resolve the constraints regarding the RTs and tagging, which are due to anti-spam rules from twitter, I will attempt to follow Tomas Poszytek's blog post (that I've seen on my twitter radar yesterday while finishing up the details of this article)

Keep on diving!


Popular posts from this blog

Power Platform Happy Hour - 17 juillet 2019

C'est un rendez-vous, mercredi le 17 juillet 2019. Profitons de cette période pré-vacances estivales pour plusieurs. Le but de cette rencontre est simplement de nous permettre de se voir dans un contexte libre, sans commanditaire et sans agenda.

Sans prétention et voulant suivre ce mouvement qui prend de l'ampleur dans d'autres grandes villes, soyons fiers de notre communautés d'experts et néophytes du domaine des applications d'affaires (Business Apps) de Microsoft.

Power BIPower AppsMS FlowDynamics Le rendez-vous est à la microbrasserie Helm, 273 Ave Bernard Ouest à partir de 17h
Les consommations sont au frais de chacun(e).
Si possible, se connecter au groupe sur WhatsApp afin de confirmer votre présence. Passez l'invitation à vos collègues.
PS. si vous n'avez pas WhatsApp... commentez au bas de ce post ;-)

AI Builder - Text Classification in a Flow

AI Builder - Text Classification in a Flow Version française disponible ici Use Case Some of my current learning objectives are about understanding the capabilities of the Flow connectors as well as the new Power Platform capabilities, such as the AI Builder fonctions.
In that line, I took a look the new connector from Aquaforest to integrate PDFs in a flow and considered combining it with AI Builder's Text Classification tool, all this in order to answer this hypothetical use case: Based on a PDF file received (in a OneDrive folder in this case)Convert the content of that PDF into plain textUse Text Classification to identify the document and establish if it's an invoice or a purchase orderThen based on this classification, process the request accordingly Step 1 - Build the Text Classification model The trigger of this process is a user adding a file to a monitored folder, could be any other similar trigger (email received, file transferred from an app and so on). The objecti…

My journey in becoming part of the #PowerAddicts community

My journey in becoming somewhat of a Power Addict.

Version française disponible ici
I’ve recently had that Aha! Moment where I realized the full potential of the PowerPlatform and mostly the impact it could have on people around me and certainly myself!

From then on, I’ve invested most of my usual “free” time reading, testing, debugging, writing and talking about Power Apps, CDS, Flows and connectors.
How did I get there? What brought me to that moment? What have I done since? This is the story that I’d like to share with the hope that it may inspire others, like you, to embark on the tsunami that is transforming radically how we resolve some of the business issues we have or help realize those ideas we’ve drawn.
Oh! And by the way, if my wording turns out weird, don’t hold it against me! My main language is French, but in order to share this to a broader set of people I’ve decided to write this in English.
My background
To help you understand where I come from, here’s a bit of my profe…