Skip to content

Commit 381e733

Browse files
authored
Merge pull request #10117 from MicrosoftDocs/matp-3988419
Matp 3988419 - Create low-code plug-ins to use with a copilot
2 parents 71c07aa + e6cfbc8 commit 381e733

File tree

6 files changed

+157
-0
lines changed

6 files changed

+157
-0
lines changed

powerapps-docs/maker/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,6 +2041,8 @@
20412041
href: ./data-platform/lowcode-plug-ins-examples.md
20422042
- name: Low-code plug-ins Power Fx
20432043
href: ./data-platform/low-code-plug-ins-powerfx.md
2044+
- name: Create low-code plug-ins to use with a copilot (preview)
2045+
href: ./data-platform/low-code-plugins-copilot-studio.md
20442046
- name: Work with actions
20452047
items:
20462048
- name: Use actions
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
---
2+
title: Create Dataverse low-code plug-ins to use with a copilot (preview)
3+
description: Learn how to create low-code plug-ins to use with Microsoft Copilot generative AI actions.
4+
author: mikefactorial
5+
ms.author: dikamath
6+
ms.reviewer: matp
7+
ms.service: powerapps
8+
ms.topic: how-to
9+
ms.date: 04/26/2024
10+
ms.custom: template-how-to
11+
ms.collection: bap-ai-copilot
12+
---
13+
# Create low-code plug-ins to use with a copilot (preview)
14+
15+
[!INCLUDE [cc-beta-prerelease-disclaimer](../../includes/cc-beta-prerelease-disclaimer.md)]
16+
17+
Copilot actions are a way to extend the capabilities of your copilot bots. With Copilot generative AI actions, you create custom actions that are triggered by your copilot bot. These actions are used to perform a wide range of tasks, such as sending emails, creating records in Microsoft Dataverse, or calling external APIs. In this article, you create a basic low-code plug-in that adds two integers together and a more complex plug-in that can be used to send a notification either of which can be used to create an action in Microsoft Copilot Studio.
18+
19+
> [!IMPORTANT]
20+
> - This is a preview feature.
21+
> - [!INCLUDE [cc-preview-features-definition](../../includes/cc-preview-features-definition.md)]
22+
23+
## Prerequisites to use the plug-in with Microsoft Copilot
24+
25+
Before you begin, make sure you have the following prerequisites:
26+
27+
- Access to a Dataverse environment that includes the Dataverse Accelerator App for creating low-code plug-ins.
28+
- Access to Copilot Studio in the same environment as your Dataverse environment.
29+
30+
## Basic low-code plugin example
31+
32+
In this example you create a low-code instant plug-in that adds two numbers and returns the sum of those numbers. You then create a Copilot action that calls this low-code plug-in to perform the addition. The copilot you create works for numbers and arbitrary text queries that contain numbers and fractions spelled out.
33+
34+
To create your basic low-code instant plug-in, follow these steps:
35+
36+
1. Open the Dataverse Accelerator App in your Dataverse environment by going to **Apps** > **All** > **Dataverse Accelerator App** and select **Play**.
37+
2. From the Dataverse Accelerator App, select **New plug-in** and select **Instant plug-in**.
38+
3. Enter a descriptive display name for your plug-in. For example *Sum numbers*, and then select **Create**.
39+
4. In the **Parameters** section:
40+
- Add the following input parameters:
41+
- **Parameter Name**: *Number1*, **Type**: **Float**
42+
- **Parameter Name**: *Number2*, **Type**: **Float**
43+
- Add the following output parameter:
44+
- **Parameter Name**: *Result, Type*: **Float**
45+
5. In the **Expression** section, enter the following code:
46+
47+
```
48+
{Result: Number1 + Number2}
49+
```
50+
:::image type="content" source="media/low-code-plugin-copilot-action1.png" alt-text="Create instant low-code plugin that adds to numbers" lightbox="media/low-code-plugin-copilot-action1.png":::
51+
6. Select **Save** to save your plug-in.
52+
53+
### Create a copilot to call your basic low-code plug-in
54+
55+
Go to Copilot Studio, and open the environment that has the plug-in.
56+
57+
1. Create a copilot. More information: [Create and configure copilot plugins](/microsoft-copilot-studio/copilot-plugins-overview)
58+
1. Enable generative actions on the copilot. More information: [Enable generative actions](/microsoft-copilot-studio/advanced-generative-actions#enable-generative-actions)
59+
1. Add a generative AI action. When you add the action, search for 'Perform an unbound action in selected environment' and select the action. More information: [Use Generative Actions in Microsoft Copilot Studio](/microsoft-copilot-studio/advanced-generative-actions)
60+
1. Configure the action with the following details:
61+
- Add a model description that lets the copilot know when to call this action. Use plain English to describe the conditions under which this action should be called. For example, you can enter "Adds numbers and return the sum of those numbers given 2 floating point values." More information: [Authoring descriptions](/microsoft-copilot-studio/advanced-generative-actions#authoring-descriptions)
62+
- Use these **Inputs**:
63+
- Change **How will the copilot fill this input for the Organization** parameter to **Set as a value**.
64+
- Select your current environment (the environment in which you created your low-code plug-in) as the value for the **Organization** parameter.
65+
- Change **How will the copilot fill this input for the Action Name** parameter to **Set as a value**.
66+
- Select the low-code plug-in you created as the value for the **Action Name** parameter. If you're unsure what the name of your plug-in is you can find it in the Dataverse Accelerator App by selecting it from the list and selecting **Copy code snippet** and then pasting the code into a text editor.
67+
- Additional **Inputs**:
68+
- Add and the following input parameters. Adding additional inputs doesn't currently show details in Copilot Studio. You can verify that the inputs were added correctly by selecting **Open the code edit and reviewing the code**, which should show the additional inputs under the inputs section in the action YAML:
69+
- **Parameter Name**: *Number1*
70+
- **Parameter Name**: *Number2*
71+
1. Save and publish the copilot.
72+
73+
### Test your copilot action
74+
75+
Follow these steps in the **Test copilot** pane in Copilot Studio.
76+
77+
1. Select the sparkle icon at the top of the chat window to start tracing mode. This allows you to confirm that your action is being called and verifies the inputs and outputs of your action. More information: [Testing you copilot using generative actions](/microsoft-copilot-studio/advanced-generative-actions#testing-your-copilot-using-generative-actions)
78+
1. Enter the text in the chat window *Add 5.2 and 10.3* and select **Send**.
79+
80+
If everything is configured correctly, you see the expected result of 15.5 output in the chat window and the trace pane shows the inputs and outputs of your action. The trace pane looks similar to the following example. You can try some other prompts to test the action further and change the language to see how the action responds. Some examples:
81+
82+
- *If I have 3 apples and my friend gives me 4 more, how many apples do I have in total?*
83+
- *If I have 1/2 pounds of cheese and I order another 1/4 pounds, how much cheese do I have total?*
84+
85+
:::image type="content" source="media/low-code-plugin-copilot-action3.png" alt-text="Results of adding two numbers from copilot" lightbox="media/low-code-plugin-copilot-action3.png":::
86+
87+
## Send notification low-code plugin example
88+
89+
In this example you create a low-code instant plug-in that wraps an existing API for use with a copilot. The action sends a notification to the user specified in the copilot action when the user creating the action tests it in Copilot Studio. The copilot determines the required parameters from the plain language query from the user and sends a notification using a Dataverse low-code plugin-in to a model-driven app in Power Apps.
90+
91+
To create your low-code instant plug-in, follow these steps:
92+
93+
1. Open the Dataverse Accelerator App in your Dataverse environment by going to **Apps** > **All** > Dataverse Accelerator App and select play.
94+
2. From the Dataverse Accelerator App, select **New plug-in**, and then select **Instant plug-in**.
95+
3. Enter a descriptive display name for your plug-in. For example, *Send in-app notification to user* and select **Create**.
96+
4. In the **Parameters** section:
97+
- Add the following input parameters:
98+
- **Parameter Name**: *UserName, Type*: **String**
99+
- **Parameter Name**: *Title, Type*: **String**
100+
- **Parameter Name**: *Body, Type*: **String**
101+
- **Parameter Name**: *Url, Type*: **String**
102+
- Add the following output parameter:
103+
- **Parameter Name**: *Result, Type*: **String**
104+
5. In the **Expression** section, enter the following code. Notice that we're wrapping the existing `XSendAppNotification` API with the plugin to give the ability to find users by name. This behavior helps when called from copilot, which can only provide information the user knows about the person and not more esoteric IDs of records that the underlying API is expecting:
105+
106+
```powerappsfl
107+
XSendAppNotification(Title,
108+
First(Filter(Users, UserName in 'Full Name')),
109+
Body,
110+
[XCreateUrlAction("Click Here", Url)]
111+
);
112+
{Result: "Success"}
113+
```
114+
115+
:::image type="content" source="media/low-code-plugin-copilot-action2.png" alt-text="Create a low-code plugin to send notification" lightbox="media/low-code-plugin-copilot-action2.png":::
116+
6. Select **Save** to save your plug-in.
117+
118+
### Create a copilot to call your send notification low-code plug-in
119+
120+
Go to Copilot Studio, and open the environment that has the plug-in.
121+
122+
1. Create a copilot. More information: [Create and configure copilot plugins](/microsoft-copilot-studio/copilot-plugins-overview)
123+
1. Enable generative actions on the copilot. More information: [Enable generative actions](/microsoft-copilot-studio/advanced-generative-actions#enable-generative-actions)
124+
1. Add a generative AI action. When you add the action, search for 'Perform an unbound action in selected environment' and select the action. More information: [Use Generative Actions in Microsoft Copilot Studio](/microsoft-copilot-studio/advanced-generative-actions)
125+
1. Configure the action with the following details:
126+
- Add a model description that lets the copilot know when to call this action. Use plain English to describe the conditions under which this action should be called. For example, you can enter "Calls a Dataverse API to send a notification to a user in Dataverse to remind or alert them to something important with a title, body and optionally a link for more details." More information: [Authoring descriptions](/microsoft-copilot-studio/advanced-generative-actions#authoring-descriptions)
127+
- Use these **Inputs**:
128+
- Change **How will the copilot fill this input for the Organization** parameter to **Set as a value**.
129+
- Select your current environment from the dropdown list (the environment in which you created your low-code plug-in) as the value for the **Organization** parameter. You need to put your cursor in the textbox in order for the list of available environments to show.
130+
- Change **How will the copilot fill this input for the Action Name** parameter to **Set as a value**.
131+
- Select the low-code plug-in you created as the value for the **Action Name** parameter. You need to put your cursor in the textbox in order for the list of available APIs to show. The value to enter here is the schema name of the low-code plugin, such as `org_SendInAppNotificationToUser`. If you're unsure what the schema name of your plug-in is you can find it in the Dataverse Accelerator App by selecting it from the list and selecting **Copy code snippet** and then pasting the code into a text editor.
132+
- Additional **Inputs**:
133+
- Select **Add** and add following input parameters. Notice that adding additional inputs doesn't currently show details in Copilot Studio. This is a known issue. You can verify that the inputs were added correctly by selecting **Open the code edit and reviewing the code**, which should show the additional inputs under the inputs section in the action YAML:
134+
- **Parameter Name**: *UserName*
135+
- **Parameter Name**: *Title*
136+
- **Parameter Name**: *Body*
137+
- **Parameter Name**: *Url*
138+
1. Save and publish the copilot.
139+
140+
### Test your send notification copilot action
141+
142+
Follow these steps in the **Test copilot** pane in Copilot Studio.
143+
144+
1. Select the sparkle icon at the top of the chat window to start tracing mode. This allows you to confirm that your action is being called and verifies the inputs and outputs of your action. More information: [Testing you copilot using generative actions](/microsoft-copilot-studio/advanced-generative-actions#testing-your-copilot-using-generative-actions)
145+
1. Enter the text in the chat window *Send a notification to my user to check out this url https://copilotstudio.microsoft.com*, and then select **Send**.
146+
147+
If everything is configured correctly, you see that a notification has been sent in the **Test copilot** pane. The notification is sent as a model-driven in-app notification when the specified user plays the app.
148+
149+
:::image type="content" source="media/low-code-plugin-copilot-action4.png" alt-text="Results of notifcation sent from copilot" lightbox="media/low-code-plugin-copilot-action4.png":::
150+
151+
You can try some other prompts to test the action further and you could change the plugin to be smarter about how it searches for users given a name to see how the action responds. For example, you could add a step to search for the user by email address if the name doesn't return a result.
152+
153+
## See also
154+
155+
[Use low-code plug-ins in Dataverse](low-code-plug-ins.md)
28.1 KB
Loading
44.6 KB
Loading
81.2 KB
Loading
97.9 KB
Loading

0 commit comments

Comments
 (0)