Fetch and Display Video Collection using Power Virtual Agents

Introduction

In the previous articles, we did see how to use markdown language to work with the formatting and beautification of text that is shown in the Power Virtual Agents. We also saw the syntax for displaying Video files.

In this article, we will see a real-time use case of creating a bot that displays videos using markdown in the bot window.

Scenario

We have a requirement to create a Guide Me bot that will pick videos related to the user requests that show them how to do a particular task and show it in the bot window. Clicking on it will walk the user through the detailed video.

Graphical user interface

Description automatically generated

Implementation

To implement this, we will create a back-end SharePoint library with the below columns that will be needed to create the markdown for the video. The Out of the box Name field will be used to store the video title

Background pattern

Description automatically generated with low confidence

Let’s head over to Power Virtual Agent and create a new bot. We will add a few trigger words that will invoke the bot

Graphical user interface, application

Description automatically generated

Followed by that let’s ask the question of what kind of Help Videos the user would like to see.

Graphical user interface

Description automatically generated

Based on the user input, we will assign a branch to each option.

Create Power Automate

Now let’s create a Power Automate by clicking on Call an action

Graphical user interface, application

Description automatically generated

This will open Power Automate where we can define the logic of fetching the related video and building the mark-up that has to be shown back in the chatbot.

We will define an input variable that can accept the Query Search Keyword from the user. Followed by that we will fetch the Video Library Contents and define a variable that we will use to hold the markdown for the video collection.

Graphical user interface, text, application, email

Description automatically generated

In the next steps, we will loop through the item collection and check if the Video Name contains the keyword searched by the user. And for matching records, in the Yes branch, we will append to the variable and create a markdown to show the video Link in PVA. The video link has the markdown syntax :

[![Alternate Text]({image-url})]({video-url} “Link Title”)

We will be fetching the Alternate Image text from the SharePoint list column by the same name, the thumbnail image URL is automatically fetched from the Out of the box list column – Thumbnail. Video URL is fetched from the Link To Item dynamic content and the Link Title is fetched from the custom SharePoint List Column

[![@{items(‘Apply_to_each’)?[‘ThumbnailAlternateImageText’]}](@{items(‘Apply_to_each’)?[‘{Thumbnail}/Medium’]})](@{items(‘Apply_to_each’)?[‘{Link}’]} “@{items(‘Apply_to_each’)?[‘Video_x0020_Link_x0020_Title’]}”)
Graphical user interface, application

Description automatically generated

Finally, let’s send back the video collection markdown to PVA

Graphical user interface, text, application, email

Description automatically generated

Display the Video Collection

Heading back to Power Virtual Agent, we will add the recently created flow and show the returned markdown video collection using the message node.

Graphical user interface, application

Description automatically generated

Test the Bot

Let’s test the Bot by triggering the chat. It has fetched the leave application videos and displayed them in the chat window. Clicking on it will play the video using the web player in a new tab.

Graphical user interface, text, application

Description automatically generated

Summary

Thus, we saw how to work with markdown language and to fetch the video based on user enquiry and show the collection of videos in the chat for user viewing.

Related Articles

Author

Author

Priyaranjan KS is a Modern Workplace Architect primarily focused on developing and architecting solutions around Office 365,Power Platform and Azure.He is also a Microsoft Most Valuable Professional(MVP) and a Microsoft Certified Trainer(MCT)

Latest Articles