Hero Insights: Using Power Automate to Set Contact Images

If you are just joining us, I am working on a series to learn about Dynamics 365 and Customer Insights using superheroes! You can check out the full series on the Hero Insights page. Enjoy!


Previously, we added data on the Common Data Service. Today, we’re using Power Automate for something exciting! I think this solution was super cool for my example scenario. However, I do understand it has some room for improvement and probably is not something that should be run on your production instance. Hopefully, it will still facilitate your learning and still be interesting!

The Goal

The goal today is to get pictures to somehow populate the contact image on my hero (Contact) records. Since I was working with superheroes who have appeared countless times already in comic books, it just seemed logical that I would be able to find their image in order to add to their Contact.

There were a few roadblocks keeping me from this goal. My first struggle was that I didn’t want to manually hunt down every hero’s image and upload them to each contact one by one. So I wanted to use one of the superpowers of this technology to scour the internet to add the appropriate pictures for me. I completed this by using Flow to search Twitter for the character, grabbed the image from the tweets, and added them to the corresponding hero’s contact.

My second struggle was that I needed to find a way to run the Flow for all of our records. Originally, I had planned to do this via an on-demand trigger. There were still some fiddly bits with solutions and on-demand Flows which were slightly complicated by the fact that you can only upload the Contact images using the Common Data Service (current environment) connector.

It was at this time that I reevaluated and decided just to run for all records at once. Of course this timed out. To solve this issue, I modified the Get Records to only grab those starting with a particular letter of the alphabet (thanks to an assist from the XrmToolBox FetchXML Builder). I could enter the letter as part of the trigger button so that the actual Flow did not need to be modified between runs. This allowed me to kick of the Flow multiple times in a row and it could be running in parallel.

The Solution

Enough chatting, let’s see what the solution actually looked like.

Trigger Flow manually and request letter
We manually triggered the Flow and requested a letter. This filtered the list of Heroes (Contacts) to a reasonable amount to ensure the rest of the logic did not timeout.
For each contact, Get contact and account
For each Contact retrieved from the last step, we need to get the Contact and Account details. We only need the Account for the Account Name in the upcoming Twitter search.
Search Twitter based on Contact Details
To the Twitterverse! We will search Twitter by the Hero name (in Last Name field) and Publisher (Account name). This is set to return multiple tweets. Then we will want to look at each tweet and each piece of media attached.
Saving Image and Adding to CDS
Once we have found the image, we need to save it on OneDrive. Then get the file content. Finally we can upload that as the Contact Entity Image.

Room For Improvement

Just like every superhero has a weakness, this flow does have some vulnerabilities.

We have to search for multiple tweets with the hope that at least one contains a picture. If there are multiple images, the first one is being saved and then it is failing on the overwrite. If there are no images (or no tweets), then nothing is done.

Who knows what you are downloading from Twitter so that is a risk that some may not trust the internet that much. Plus copywrite laws … let’s not talk about that one.

This may have been a case where a Custom Connector could be used to search a specific Super Hero wiki where we could guarantee results that met our needs.


Despite the potential issues or room for improvement I would still call this a success. Check out a few of the images that were found. Of the 710 heroes, 336 were updated with pictures.

Here are a few of the Contacs with their images from Twitter captured via a Flow in Power Automate
Here are a few of the Contacts with their images from Twitter captured via a Flow in Power Automate

Today’s episode was busting at the seams with excitement but come back tomorrow for even more thrills and chills where we will set up the Customer Insights Trial!

Leave a Reply