Create copilot actions
Scenario
In this lab, you will:
- Create copilot actions
What you will learn
- How to add use Power Automate to access data in Microsoft Dataverse
High-level lab steps
- Create a Power Automate cloud flow to retrieve Dataverse data with a copilot action
- Create a Power Automate cloud flow to create Dataverse data with a copilot action
Prerequisites
- Must have completed Lab: Work with entities
Detailed steps
Exercise 1 - Create Copilot action to retrieve data from Dataverse
Microsoft Copilot Studio can access data in Microsoft Dataverse using Power Automate cloud flows.
Task 1.1 - Create Power Automate flow to retrieve a property
-
Navigate to the Microsoft Copilot Studio portal
https://copilotstudio.microsoft.com
and ensure you are in the appropriate environment. -
Select Copilots from the left navigation pane.
-
Select the Real Estate Booking Service you created in the earlier lab.
-
Select the Actions tab.
-
Select + Add an action.
-
Select the Flow filter, then select Create a new flow.
-
Sign in to Power Automate if prompted.
-
Select Run a flow from Copilot in the top-left of the screen and enter
Get Property
as the flow name. -
Select the trigger step Run a flow from Copilot and select + Add an input.
-
Select Text.
-
Enter
Bedrooms
for Input andNumber of Bedrooms
for Please enter your input. -
Select the + icon between the two steps in the flow and select Add an action.
-
Enter
Dataverse
in the Search field and select See more for the Microsoft Dataverse connector. -
Select the List rows action.
-
If prompted for authentication, select OAuth and select Sign in.
Note: If you see a ‘Failed to create OAuth connection’ error, you may need to allow popups in your browser.
-
Select Real Estate Properties for table name.
-
Enter
contoso_bedrooms eq
(with a space after eq) in the Filter Rows field. -
With the Filter Rows field still selected, select the lightning icon to its right, then select the Bedrooms parameter.
-
In the main Power Automate pane, select the Respond to Copilot action and select + Add an output.
-
Select Text.
-
Enter
PropertyId
for Enter a name -
Select the Enter a value to respond with field, and select fx (Insert Expression).
-
Enter the following expression into the top field:
first(outputs('List_rows')?['body/value'])['contoso_realestatepropertyid']
-
Select Add.
-
Select + Add an output.
-
Select Text.
-
Enter
PropertyName
for Enter a name. -
Select the Enter a value to respond with field, and select fx (Insert Expression).
-
Enter the following expression:
first(outputs('List_rows')?['body/value'])['contoso_propertyname']
-
Select Add.
-
Select the Settings tab in the Respond to Copilot pane.
-
Ensure that Asynchronous Response is set to Off.
-
Select Save near the upper-right of the page.
-
Wait for the save to complete, then close the Power Automate tab.
Task 1.2 - Add a Copilot action to retrieve a property
-
Select Refresh from the Copilot Studio dialog box to see the new Flow.
-
Select the Get Property flow.
-
Select Next.
-
Select Next.
-
Select Finish.
Task 1.3 - Add the Get Property Copilot action to the topic
-
Select the Topics tab.
-
Select the Book a Real Estate Showing topic.
-
Select the the + icon below the How many bedrooms do you need question? node, select Call an action, then select the Get Property flow.
-
Select the NumberofBedrooms variable for the Bedrooms input parameter.
-
Select the three dots in the Which property do you want to see? node and select Delete.
-
Select the the + icon under the Action node and select Send a message.
-
In the Enter a message field, enter
Property
(with a space following it). -
In the same node, select the {X} (Insert variable) icon and select the PropertyName variable.
-
Select Save.
Exercise 2 - Create Copilot action to create data in Dataverse
Microsoft Copilot Studio can ceate data in Microsoft Dataverse using Power Automate cloud flows.
Task 2.1 - Create Power Automate flow to make a booking
-
Select the Actions tab in Real Estate Booking Service.
-
Select + Add an action.
-
Scroll down and select Create a new flow.
-
Select Run a flow from Copilot in the top-left of the screen and enter
Create Booking Request
as the flow name. -
Select the trigger step Run a flow from Copilot and select + Add an input.
-
Select Text.
-
Enter
PropertyId
for Input andProperty
for Please enter your input. -
Select + Add an input.
-
Select Text.
-
Enter
ViewerName
for Input andViewer Name
for Please enter your input. -
Select + Add an input.
-
Select Text.
-
Enter
ViewerEmail
for Input andViewer Email
for Please enter your input. -
Select the + icon between the two steps in the flow and select Add an action.
-
Enter
Dataverse
in the Search field and select See more for the Microsoft Dataverse connector. -
Select the Add a new row action.
-
Select Booking Requests for table name.
-
Enter
Copilot booking
in the Booking Name field. -
Select Show all under Advanced parameters.
-
Enter
contoso_bookingrequests()
in the Property (Real Estate Properties) field, move the cursor within the parentheses, select the lightning icon, then select the PropertyId parameter. -
Select the Viewer Email field, select the lightning icon, then select the ViewerEmail parameter.
-
Select the Viewer Name field, select the lightning icon, then select the ViewerName parameter.
-
Select the Respond to Copilot action.
-
Select the Settings tab.
-
Ensure that Asynchronous Response is set to Off.
-
Select Save in the upper-right of the window.
-
Wait for the save to complete, then close the Power Automate tab.
Task 2.2 - Add a Copilot action to create a booking request
-
Select Refresh from the Copilot Studio dialog box to see the new Flow.
-
Select the Create Booking Request flow.
-
Select Next.
-
Select Next.
-
Select Finish.
Task 2.3 - Add the Create Booking Request Copilot action to the topic
-
Select the Topics tab.
-
Select the Book a Real Estate Showing topic.
-
Select the the + icon below the What date and time do you want to see the property? node, select Call an action, then select the Create Booking Request flow.
-
Select the PropertyId variable for the PropertyId input parameter.
-
Select the Name variable for the ViewerName input parameter.
-
Select the EmailAddress variable for the ViewerEmail input parameter.
-
Select the the + icon below the new Action node, select Topic management, select Go to another topic and select End of Conversation.
-
Select Save.
-
Select Publish and select Publish again.
Exercise 3 - Test the copilot actions
Task 3.1 - Make a booking request
-
If closed, select the Test button in the upper-right of the screen to open the testing panel.
-
Select the three dots at the top of the testing panel in the upper-right of the screen.
-
If it’s not enabled, enable Track between topics.
-
Select the Start a new conversation icon at the top of the testing panel.
-
When the Conversation Start message appears, your copilot will start a conversation. In response, enter a trigger phrase for the topic that you’ve created:
I want to book a real estate showing
-
Enter the following information:
Name: <Your name> Email address: <Your email address>
-
After you supply the information, an Adaptive Card displays the information that you entered and asks if the details are correct. Select Yes.
-
Select House for the type of property prompt.
-
Enter
3
for the number of bedrooms prompts. -
Enter
Tomorrow 2:00 PM
to the What date and time do you want to see the property? prompt. -
Select Yes to the Did that answer your question? prompt.
-
Select any rating.
-
Select No to the Can I help with anything else? prompt.
Task 3.2 - Verify the booking request
-
If it’s not still open, navigate to
https://make.powerapps.com
in a new tab. -
Make sure you are in the appropriate environment.
-
Select Play on the Real Estate Property Management Model-Driven App.
-
In the left navigation, select Booking Requests.