Back in February I wrote a blog post on how to schedule Twitter content with Microsoft Flow and SharePoint. This was quite well received, and I’ve had a few discussions with various people, who tried it themselves. One of those is fellow MVP Luise Freese (Twitter, Medium) (extremely passionate & sketchnote artist extraordinaire), who used my instructions and replicated the setup. And as I saw recently and also discussed with her, made some improvements to the Flow, which I was also thinking of doing.

My initial setup allowed posting content, but it did not provide any means to add any images to the Tweets. But seeing this tweet by Luise which she had scheduled and which includes an image made me realise, that I should get in touch with her (which I did straight away) and also test it myself (which I also did soonest).

So, I got some feedback from her (which matched the Flow I had constructed in my mind to achieve the above), made some smaller updates to my Flow, tested it, and succeeded. Here’s what needs to be done (check my first post for the initial Flow, which I’m updating here).

First, we initialise a new variable of type Object (I called it Media):

Next, we need to update the “Apply to each” item loop. First we add a “Get attachments” action at the top of it to retrieve the attachments (if any) for the current item.

As there may be multiple attachment, I’m doing another “Apply to each” loop for the attachments, retrieve the attachment content, and update my Media variable.
If there are multiple images attached, this means that only the last image will be used (The documentation mentions only “Media to be posted” of type binary, so only one item can be used here; I tested it with an array, which failed). Instead of doing this loop I could’ve also done a selection of the first item only, there’s obviously more than one way of achieving this).
If there is actually no attachment, this step will be skipped, but posting a tweet will still work (Media variable will be empty in this case, so no media will be posted).

Lastly, I simply updated the existing “Post a tweet” action to include the Media.

Here’s the final Flow in its full glory:

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.