Teaching GPT-4 to Generate Power Virtual Agents Topics

Teaching GPT-4 to Generate Power Virtual Agents Topics

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.

No alt text provided for this image


Understanding the Code

In the modern bot authoring canvas you will typically see a topic like this

No alt text provided for this image

If I flip to the code view I can see the same node represented as code

No alt text provided for this image

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.

No alt text provided for this image

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.

No alt text provided for this image


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.

No alt text provided for this image

Chat GPT responded with the following confirmation of understanding.

No alt text provided for this image

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.

No alt text provided for this image

And this is what was returned.

No alt text provided for this image

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.

No alt text provided for this image

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)

No alt text provided for this image

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.

No alt text provided for this image


Conclusion

Some points I’d like to share here in conclusion.

  1. You’ll find limitations if you try to copy a long topic into Chat GPT and ask it to simply learn that. It’s better to break down the instructions first and then teach it to use those elements.
  2. You’ll naturally learn how to understand topics in the code editor, which is a good thing, as if you have some elements you want to use elsewhere, copy and paste is now your friend again!
  3. Chat GPT can make mistakes, so don’t count on it too much.
  4. Use this as an approach to learn and think of what we’ll be able to do when these kinds of solutions are directly baked into PVA


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.

Benjamin Simonet

M365, SharePoint, Power Platform Developer

1 年
Nadir GHIDOUCHE ツ

Au four et au moulin de la transformation digitale où l'humain à toute sa place !

1 年

Paul Kamenan

Francesco Schiavoni

Account Director ??@ Microsoft - Helping Enterprise Customers in been successful in their Digital Transformation Journey

1 年

Love this

Noémie N.

Account Manager at Microsoft

1 年

Bárbara Almeida Interesting!

Anurag(Anu) Karuparti

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!

要查看或添加评论,请登录

Peter Maynard的更多文章

社区洞察

其他会员也浏览了