Here’s how you can use Power Automate to randomly select an image or GIF and post it in a Microsoft Teams message.

Screenshot of sending a randomly selected image/GIF in Teams

You will first need the URL of the images or GIFs you would like to use. When the flow is run, one will be randomly selected and posted in a Microsoft Teams chat.

In this example, I’ve selected the following 5 GIFs from

To get the URL, you will need to right click on the image/GIF and select Copy image address.

Get the URL of your image or GIFs

In your flow, add in the action Initialize variable with the following values:

Name: randomgif
Type: Array
Value: Here you will need to paste in the URLs of your GIFs/images. They will need to be in the format of [“URL1”, “URL2”, “URL3”, “URL4”, “URL5”]

Screenshot of your flow action: Initialize variable

Next, add in the Microsoft Teams action Post a message in a chat or channel. The Post as and Post in values can be up to you. In the Message field, type in your message (if required) then click on the code view button.

Screenshot of your Microsoft Teams flow action. Show code view for the message.

On a new line, type the following:

<img src=”EXPRESSION”>

Screenshot of your flow Teams action. Enter in the text.

Backspace the word EXPRESSION and replace it with the following expression. You may need to type it out rather than copy and paste if you receive an error.

variables('randomgif')[rand(0, length(variables('randomgif')))]
Screenshot of your flow Teams action. Enter in the expression.

The expression should be in between “” without any spaces.

Screenshot of your flow Teams action once complete

Save the flow and it is ready to go. Run the flow to see it in action.

2 thoughts on “Send a random image or GIF with Power Automate

  1. Hi, nice article, that is i was searching,
    I have applied this method in my workflow but it is not posting gifs there,
    it is posting like this “![]”
    please help me in this regard.
    thanks in advance!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s