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

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 https://giphy.com/sunnyfxx/
- https://media4.giphy.com/media/MYCg1AoPwiSuDuD13O/giphy.gif
- https://media1.giphy.com/media/RhHqv0oKyc9dkjHwLn/giphy.gif
- https://media.giphy.com/media/W2bxebmDd8s1yrO8aT/giphy.gif
- https://media.giphy.com/media/5UFK2tqEqpeCyadiuV/giphy.gif
- https://media.giphy.com/media/ZbfOV3d6iAT5VoHsoj/giphy.gif
To get the URL, you will need to right click on the image/GIF and select Copy image address.

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”]

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.

On a new line, type the following:
<img src=”EXPRESSION”>

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')))]

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

Save the flow and it is ready to go. Run the flow to see it in action.
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 “![]https://www.funimada.com/assets/images/cards/big/bday-643.gif”
please help me in this regard.
thanks in advance!
Would be good to see a picture of your flow. Drop me a message on LinkedIn (https://www.linkedin.com/in/rishonaelijah/) with some screenshots of your flow so I can see what might be wrong