Use plugin actions in Copilot Studio (preview)
If you read last week’s article than you know that Microsoft announced a couple of new features during the Microsoft Power Platform Conference that took place in Las Vegas the first week of October. Last week I wrote about the ability to upload documents for generative answers which is in preview today, which allows us to upload one or multiple documents to be used in generative answers in Power Virtual Agents. If you haven’t read that article, you can do so here. Another announcement that was made during MPPC was the ability to create plugins and call them as actions inside of Power Virtual Agents. This is super exiting news, because this will really allow us to cut back on the creation of topics! The use of plugins allows us to directly use a connector inside a topic, without the need to use Power Automate! Plugin actions allow the bot to use GPT to generate the questions required to enter the inputs needed to perform the action. Before plugins, we needed to manually create questions in PVA to get all the information that was needed to run the flow (I.E what is your email address, what is your name, etc.). Then we needed to feed those answers into the power automate flow, after which the flow would run after which we would feed the data back into Power Virtual agents. With the new plugins feature all of this will now be handled during runtime, so you can imagine how much faster this will be!
Adding a plugin action
The first thing you will need to do is add a plugin action to Power Virtual Agents. In this example I am going to use the existing ‘Get Current Weather’ connector so that I can use that to create a ‘weather’ topic. This topic will allow users to get weather information when interacting with the bot. When creating these plugin actions, you can use connectors (including custom connectors), skills or existing Power Automate flows.
You can do this by navigating to topics, and clicking the add button on the top. Select ‘Plugin Action(preview)’ to add the action. You can filter on the list of available items by clicking on the ‘filter’ button on the right side of the screen. If you don’t have the need to filter you can start by entering something in the search bar. For this example I am going to enter ‘Weather’ and select the ‘Get Current Weather’ connector from MSN weather. Once the connector is selected, you’ll see the ‘Connect to’ section on the ‘action details’ section of the page. From here you’ll need to sign in to the connector. Once that is done, you can click ‘next’. This will show the display name and the description of the connector. Click ‘Next’ to move on. You’ll notice this connector has 2 required inputs, one for location and one for units. Below the ‘How will the bot fill this input’ field you’ll notice it shows ‘Dynamically fill with best option’. This is where the bot will get the location data entered by the end user in the chat. This is the location for which the bot will find the weather information. In the description field which will help AI determine the type of information we are looking for. I would not recommend changing the data in either of these fields. You’ll also notice the ‘Units’ input it required. This is referring to the imperial or metric units related to temperatures. The description field explains what type of data we’re looking for. The output section is what we can use to show a message in the chat. We can use the variables from the connector and/or we can use PowerFX formula’s in the message. The message I am configuring is partially text, mixed with variables from the connector. I have entered the output message below, (the bolded words are the variables from the connector) and the screenshot shows what it looks like in the output section of the connector after I saved and went back in to edit.
The weather in Input.Location is currently Output.responses.weather.current.temp F, and it is Output.responses.weather.current.cap. The dew point is Output.responses.weather.current.dewPT and it currently feels like Output.responses.weather.current.feels
The ‘Review and Finish’ section lets you review everything that was entered. If it looks good, click ‘Add’ to add the plugin to the Power Virtual Agent. You can always go back to the plugin to edit if needed.
Create a topic and use the plugin
The next thing we need to do is create a new topic, that will call this plugin action. You can start creating the topic by navigating to ‘Topics’ and clicking on the ‘+Add’ button on the top. Select ‘Topic’ and ‘From blank’. I called my topic ‘Weather Topic’, but obviously you can name it anything you want. I added ‘weather’ as a trigger phrase. Now here comes the magic! The next thing we are going to do is add the plugin action node. You can do this by clicking on the ‘+’ button, and selecting ‘Call an action’. You should see the ‘Plugin actions(preview)’ tab on the right side of the ‘basic actions’. Click on ‘Plugin actions(preview)’ and select the MSN Weather plugin action we just created. Then click ‘Save’ to save the topic. You see there are a lot less steps here, no need to ask a question about which city the user wants to know the weather for, the plugin will make sure it gets the information needed! Test your bot by typing ‘Weather’ in the chat and see what happens!
Show Metric and Imperial Temps
To take this one step further I am going to show you how we can show both the imperial temperature of the location and the metric temperature. I noticed the plugin only seems to give the temperature in Fahrenheit, (even if I choose to show the temperature in Metric) so I am going to use a PowerFX function to calculate the value in Celsius. In order to do that I am going to hard code the units to be set to Imperial (just to show you that we can if you would ever need to do that. Click on the ‘+Set Value’ button in the plugin action node, and select ‘Units’. Then enter Imperial as the value. This will hardcode the temperature unit of measure to Imperial.
To change the message and add the PowerFX to calculate the value in Celsius, go back to the plugin by navigating to Topics > Plugin Actions(preview), and open the previously created plugin. Go to outputs and click on the FX button to add the following PowerFX formula:
Trunc((Topic.Output.responses.weather.current.feels-32)*5/9)
Test the bot again and you’ll notice it now shows the temperature both in Fahrenheit and in Celsius!
I hope you enjoyed reading this article! Be sure to check in again next week for a new article or subscribe here to never miss another post!
Comments are Closed