Teaching GPT-4 to Generate Power Virtual Agents Topics
Peter Maynard
Program Manager at Microsoft | Low Code Developer | YouTube Creator at Paying it Forward
I recently encountered an issue where one of my topics became unresponsive in Power Virtual Agents. When I asked a colleague for help, I learned that topics are executed as code and can be authored using the code editor.
Having played with Chat GPT a lot I thought to myself, “Is there a way I could use GPT to help generate topics?”
This short article outlines my learning from this experiment and how you can try it yourself.
First off, to view the code of your topic, if you navigate to the top right-hand corner and click on the three dots, it will allow you to open the code editor.
Understanding the Code
In the modern bot authoring canvas you will typically see a topic like this
If I flip to the code view I can see the same node represented as code
It’s important to note there is a header at the top of the code editor. This is important in terms of defining the topic which would be created.
Let’s unpack a couple of things here about the code editor so we’re clear we understand the relationship between a node on the authoring canvas, versus the code editor.
For this example:
actions: This covers all the actions that will take place in your topic. For example, the messages / questions / Power Automate calls, etc that you’ll make are considered actions. This comes always before the actions and covers all of them you have in your topic.
kind: This represents the type of action / node that you are using. In the example above we’re using a SendActivity kind which equates to a Message.
Id: Is a unique value to your action / node
activity: This represents the content of the action / node.
Each action type has a unique set of values to represent the data within it. I’m including an example below for a Question, which of course has more fields.
Leveraging the code to teach ChatGPT
Note: I am using Chat GPT 4, as the number of tokens is bigger giving me more flexibility to put more information in a single message (as I’m lazy :D)
In order to teach ChatGPT the structure of this code, I gave it the following prompt.
领英推荐
Chat GPT responded with the following confirmation of understanding.
Creating a new topic and testing it
So like any good developer, I decided to use Chat GPT as well to generate the topic I would apply this code to.
This is the prompt I provided, based on creating some sample context around meditation.
And this is what was returned.
Looks pretty good right?
Let’s give it a go.
So to do this, create a new topic in PVA and go to the code editor. Copy and paste this content and then we’ll see what happens below.
So, you might have spotted it, but there is an error on line 8. The code needs to be tabbed in.
Simply select row 8 to 36 and hit tab on the keyboard. (result below)
Now if I click out of the code editor I can go back to the canvas, and you can see below that I have a basic topic created, all without clicking anything inside PVA.
Conclusion
Some points I’d like to share here in conclusion.
Thanks a lot for taking the time for reading this and for the community (and Dan for suggesting I write this!)
Disclaimer - Whilst I do work at Microsoft, the views in this post are entirely my own, and representative of my experience developing solutions with the Microsoft Power Platform.
M365, SharePoint, Power Platform Developer
1 年Xavier Goret
Au four et au moulin de la transformation digitale où l'humain à toute sa place !
1 年Paul Kamenan
Account Director ??@ Microsoft - Helping Enterprise Customers in been successful in their Digital Transformation Journey
1 年Love this
Account Manager at Microsoft
1 年Bárbara Almeida Interesting!
AI Leader @Microsoft | Author - Generative AI for Cloud Solutions | Responsible AI Advisor | Ex-PwC, EY | Global Guest Lecturer | Marathon Runner
1 年Nick Francis I think you will love this!