Exercise - Create an approval flow with Copilot in Power Automate

Completed

In this exercise, you'll create an automation by using Copilot in Power Automate to automate the approval process for a real estate showing. You'll use Copilot to create a flow that sends an email to the real estate agent when a new showing is requested. Then, the agent can approve or reject the showing request from within the email.

Prerequisite

Create a flow with Copilot

  1. Sign in to Power Automate.

  2. In the center of the Home page within Power Automate, in the text field under Create your automation with Copilot, enter the following prompt:

    Start and wait for an approval when a Dataverse record is created and then update the record based on one of two approval outcomes

    Select the Generate button.

  3. From the prompt, Copilot provides the outline for a suggested flow that you can review. Expect your flow to have two basic steps, the Dataverse When a row is added, modified, or deleted trigger and the Start and wait for an approval step. To accept the flow, select Next, alternatively, you can rewrite the prompt to show a different suggestion. See if Copilot will suggest a flow similar to the image below.

    Screenshot displaying the suggested Power Automate flow.

  4. Review the connected apps and services. If a connection hasn't been made, edit or fix it and then select Create flow.

    Screenshot of the Review your connected apps and services page.

    The Edit with Copilot designer opens with your flow, with a few Invalid parameter warnings, prompting us to fix these areas for our flow to work.

Modify flow with Copilot

  1. Let's begin fixing our parameters. Select the When a row is added, modified, or deleted trigger.

    A panel opens on the left side of the screen showing the trigger details.

  2. Notice the prompt at the Table Name parameter showing: 'Table name' is required.

    Screenshot displaying the When a row is added, modified or deleted trigger details.

    From the Table Name dropdown menu, search for and select Showings, or whatever your table name is for "Real estate showings".

  3. Select the Start and wait for an approval action.

  4. From the Approval Type dropdown menu, select Approve/Reject - First to respond. You may need to delete anything else that Copilot has added first.

    After you select the Approval Type, more parameters are now available.

    Screenshot displaying the extra parameters after you select the approval type.

  5. Let's use Copilot to help edit this step. Open the Copilot chat by selecting the Copilot button on the top right of the command bar. In the input field at the bottom of the chat, enter the following prompt:

    Add "New Request for Real Estate Showing" as the Title parameter for the Start and wait for an approval action

    It takes a few seconds for Copilot to process the prompt. When processing is complete, the Title parameter is populated with the prompt text.

    Screenshot displaying how the Title parameter is populated with the prompt text.

  6. Select Switch to Advanced Mode in the Start and wait for an approval action details pane.

    Screenshot displaying the Switch to Advanced Mode button.

  7. For the Assigned To parameter, enter the email address that you're using for this lab. This email address is the one that will receive the approval request.

  8. For the Details parameter, enter the following text:

    A new request for a real estate showing has been created. Please review the details below and approve or reject the request:

    Property:
    Client Name:
    Date:

  9. Place your cursor next to Property: in the Details parameter and then, select the blue lightning button to open the Dynamic content pane.

  10. In the Dynamic content pane, you can select See More to expand the list of available dynamic content.

  11. Scroll down your dynamic content until you find a property or address or location field (depends on how your data was created) and then select it. You can also type the field name in the search field to find it quickly.

    The added dynamic content field is now part of the Details parameter of the approval.

  12. Complete the same steps for the Client Name and Date fields.

    When you're done with the rest of the fields, the values should resemble the following image.

    Screenshot displaying how the Client, Client Email, Date, and Time dynamic fields are added to the details parameter.

  13. Select the Condition action. If your flow doesn't have a Condition action, go ahead and add it now by selecting the Insert a new step... (+) button under the approval step.

    Screenshot showing the Condition action selected.

  14. Ensure that the left side of the condition includes Outcome (or body/outcome) from Dynamic content.

  15. Ensure is equal to is the condition and that Approve is the Value.

    Screenshot showing the condition set to Approve.

  16. Ensure that you have an Update a row action from Dataverse under both the True and False branches of the condition. You might need to add it to your flow if Copilot hasn't already put it there.

  17. From the Table Name dropdown, search for and select the same Dataverse table that you used for the trigger.

  18. Select the Row ID field and remove the placeholder value. Select the icon for Dynamic content then search for identifier to find the unique identifier field from your table (it usually includes the table name).

    Screenshot highlighting the Row ID field in the Update a row action.

    Whenever you create a table in Microsoft Dataverse, a column is automatically created with the same name of the table. This column serves as the unique lookup ID (or identifier) for the record (or row) that was created.

  19. Next let's update a field based on the approval. Look for a column in your data table where you can confirm this. It may be in the advanced parameters. (You can select Show all under Advanced parameters to show the existing columns.)

  20. In the example below we're updating our Showing field as Confirmed.

    Screenshot displaying the Status property as Confirmed.

    When a showing is approved, an appropriate field in your table is updated to Confirmed.

  21. Select your Update a row action for Dataverse under the False branch of the condition. (Add this action if it's missing.)

  22. From the Table Name dropdown menu, search for and select the same table used in your flow's trigger.

  23. Select the Row ID field and then search for and select your table's unique identifier field from the Dynamic content pane.

  24. Update the field where you want to record that a showing has been "Canceled" or "Disapproved".

    When a showing is rejected, the appropriate field in our table is updated to Canceled or Disapproved.

  25. In the Copilot chat window, enter the following prompt and then submit:

    Under the "Update a row" action for both branches in the condition, add a new "Send an email (V2)" action

    After a few seconds, Copilot should explain what it did, as shown in the following image.

    Screenshot displaying how Copilot explains what it did.

    The updated flow should display. You might need to fix a connection in a previous step to continue. Go ahead and fix any errors before continuing.

    Screenshot of the updated flow with a new Send an email action.

  26. Select the Send an email action under the True branch of the condition.

  27. Select the To field, remove the content, and then select a field from your data that includes an email field from the Dynamic content pane. If you don't have one, enter a valid email recipient.

  28. Verify what Copilot has entered for the Subject and Body fields. You can modify these with your dynamic content. Enter the following content after the Body text:

    Property:

    Showing Date:

    Add the appropriate fields from the Dynamic content pane to the appropriate lines in the Body text.

  29. Also, you can add the Response summary field from the Dynamic content pane to the end of the Body text, as well as a personal closing message.

    Screenshot displaying how the Response summary field is added to the Body text.

  30. Select the Send an email action under the False branch of the condition.

  31. Check the To field. You can remove the content and then select any email field available from the Dynamic content pane, or you can hardcode an email address.

  32. Check the Subject and Body fields. Copilot usually shows some fields that it thinks might work for this, but you may need to update this. You can copy the fields from the "approved" email and add them here, as well.

  33. Rename the flow to Request Approval for Real Estate Showing by selecting the Start and wait for an approval when a Dataverse record is created and then update the record based on one of two approval outcomes text in the upper-left corner of the screen.

  34. Save the flow by selecting the Save button in the upper-right portion of the screen command bar.

Test the flow

  1. Test the flow by selecting the Test button in the upper-right corner of the screen. Select Manually and then select Test.

  2. To submit a real estate showing request, go to your "Real Estate Showings" app in Power Apps.

  3. Run the app and then select + New to create a new showing request.

  4. Fill in the fields with a request.

  5. Select the check mark in the upper-right corner of the screen to submit the request.

    Once this is done you can close Power Apps.

  6. Sign in to the email account that you're using for this lab and then wait for the email to arrive.

    Note

    If the flow doesn't run immediately, make sure that you wait for it. It might take up to 10 minutes for the flow to be triggered, especially on the first try.

    The approval should look something like the following image. Your table and dynamic content may be different, but the format will look like this.

    Screenshot displaying the approval email in Outlook.

  7. Select Approve.

  8. Add a comment and then select Submit.

    Screenshot of the approval in Outlook.

    The flow continues to run; it updates the row and sends an email to the requestor. The email that's sent to the requester resembles the following image.

    Screenshot of the approval email that's sent to the client.

  9. Check the flow and notice that the flow is now marked as Succeeded in the run history.

    Screenshot displaying how the flow is marked as succeeded.

  10. In the top-left corner of the screen, select Back. This will take you to the Request Approval for Real Estate Showing flow details page.

Add the flow to the Real Estate Solution

  1. On the left navigation pane, select Solutions.

  2. Select the Real Estate Solution.

  3. On the top command bar, select Add existing > Automation > Cloud flow.

  4. Select the Outside Dataverse tab and then select the Request Approval for Real Estate Showing flow.

    Screenshot of the Request Approval for Real Estate Showing flow.

    Select Add.

    It will take a couple of seconds for the flow to be added to the solution but once it's added, you'll see one Cloud flow and three Connection references in the solution.

    Screenshot of the cloud flow and connection references in the solution.

    Note

    The connection references are added to the solution because the flow uses connections to Dataverse, Office 365 Outlook, and Approvals. This ensures that the flow works correctly when it's exported and imported into another environment.