With Power Virtual Agents, it is possible to return a GIF or an image to the conversation via Power Automate. This post will take you through the steps of how you can use Power Automate to randomly select one of your curated images or GIFs, then send it to the conversation with the end user in Power Virtual agents. It’s an easy way to add some variety to your chatbot conversations.
1. Collect the URLs of the images and GIFs you would like to use
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 to your bot.
In this example, I’ve selected the following 5 GIFs from https://giphy.com/sunnyfxx/
To get the URL, you will need to right click on the image/GIF and select Copy image address.
2. “Call an action” to your Power Virtual Agent and create the flow
In the conversation tree of your topic in PVA, select the Call an action node for Power Automate. Create a new flow.
In your flow, add in the action Initialize variable after the trigger. Set the following values:
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”]
Expand Return value(s) to Power Virtual Agents. Click +Add output and select Text. Enter selectedgif as the title of the output.
In the selectedgif output field enter in the following:
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.
The expression should be in between () without any spaces.
Save the flow and return to Power Virtual Agents.
3. Connect your flow to your topic
Back in your PVA topic, add the flow you just created into the conversation.
Add a new message node underneath.
Within the message node, insert the selectedgif variable.
It is now ready to test. Save your topic and test your bot!