Custom Connectors

Scenario

In this lab, you will build a custom connector for A Datum’s Risk Score API.

High-level lab objectives

  • Build a custom connector

  • Modify the cloud flow to use the connector

Exercise #1: Create a custom connector

Task #1: Create a new solution

  1. Navigate to https://make.powerapps.com/ and make sure you are in the Dev environment.

  2. Select Solutions and click + New solution. We are creating a new solution to keep the custom connector separate from the flow that uses it which is the current requirement of using a custom connector.

  3. Enter Builder Risk Service for Display name, select Relecloud for Publisher, and click Create.

create your new solution as described

Task #2: Create custom connector

  1. Click + New and select Automation | Custom connector.

add a new custom connector

  1. Enter Builder Risk Service for Connector Name.

name the connector

  1. Enter Service for evaluating builder risk for Description, enter adatumbuilderrisktest.azurewebsites.net for Host, and click Create connector.

create the connector

Task #3: Import Open API

  1. Navigate to https://adatumbuilderrisktest.azurewebsites.net/

  2. Click Download Logo and save the logo on your machine.

  3. Click on the API Key link.

download API key

  1. Copy the API Key and save it on a notepad.

  2. Click Return to home.

  3. Click on the API documentation link.

  4. Review the documentation.

  5. Close the documentation browser tab or window, after you finish reviewing.

  6. Click on the Open API definition file link.

click to review definition

  1. On your keyboard press CTRL + S and select Save. Now the file is saved on your machine.

  2. Navigate to https://make.powerautomate.com/ and make sure you are in the Dev environment.

  3. Click More and select Discover all.

Expand more option in navifation

  1. Scroll down and select Custom connectors under data.

Find custom connectors

  1. Click on the more actions button of the Builder Risk Service custom connector and select Update from OpenAPI file.

locate and update the OpenAPI file

  1. Click Import.

  2. Select the swagger.json file you saved to your machine and click Open.

  3. Click Continue.

Import the file

  1. Click Upload under the logo.

  2. Select the logo you downloaded and click Open.

  3. Enter Service for evaluating builder risk for Description, enter

    adatumbuilderrisktest.azurewebsites.net for Host, and select Security from the breadcrumb navigation bar at the top of the screen.

enter details as described

  1. Select Definition from the breadcrumb navigation bar at the top of the screen and see the operation imported.

  2. Turn on Swagger Editor.

toggle swagger editor

  1. Have a look at the Swagger Editor and then turn off the Swagger Editor.

  2. Select Update connector and wait for the connector to be updated.

  3. Do not navigate away from this page.

Task #4: Test connector

  1. Select Test from the breadcrumb navigation bar at the top of the screen and click + New connection.

select new connection

  1. Paste your API Key and click Create connection.

  2. Click the Refresh connections button, on the right. The connection you just created should be the Selected connection.

  3. Under CalcRiskScore, enter Contoso for builderName, 7165 Brock Lane Renton, WA 61795 U.S. for propertyAddress, JG7165 for loanNumber, 645000 for loanAmount, 500000 for creditAvailable, 100000 for drawAmount, and click Test operation.

Enter details as described

  1. The test should run successfully, and you should receive a score and a reason.

review results

  1. Click Close to return to the list of Custom connectors.

Exercise #2: Modify cloud flow to use connector

Task #1: Use custom connector in flow

  1. Navigate to https://make.powerapps.com/ and make sure you are in the Dev environment.

  2. Select Solutions and open the Construction Funding solution.

  3. Select Cloud flows, select Process Construction Funding Request flow and click Edit.

locate and edit the flow

  1. Click + insert new step after the Check if loan number found condition and select Add an action.

add a new step

  1. Select Get a row by ID Microsoft Dataverse.

select get a row by ID action

  1. Select Loans for Table name, click on the Row ID field and select LoanID from the dynamic content pane.

enter details as described

  1. Rename the step Get loan.

  2. Go to the + Insert a new step button after the Run inspection process and select Add an action.

add an action

  1. Go to the Custom tab and select Builder Risk Service.

add the custom action you provided

  1. Select the Calculate Risk Score action.

  2. Enter Risk Service for Connection name, paste the API Key you copied earlier, and click Create.

enter details as described

  1. Click on the builderName field and select Builder from the dynamic content pane.

enter details as described

  1. Click on the propertyAddress field and select Address from the dynamic content pane.

  2. Click on the loanNumber field and select Loan Number from the dynamic content pane.

  3. Click on the loanDate field and select Loan Date from the dynamic content pane.

  4. Click on the loanAmount field and select Loan Amount form the dynamic content pane.

  5. Click on the creditAvailable field and select Credit Available from the dynamic content pane.

  6. Enter 80000 for drawAmount.

  7. The calculate risk score step should now look like the image below.

review the details

  1. Click on the + Insert a new step after the Calculate Risk Score step and select Add an action.

add an action

  1. Select Update a row Microsoft Dataverse.

  2. Select Loan Draws for Table name, click on the Row ID field and select Loan Draw from the dynamic content pane.

  3. Expand Show advanced options and Click on the Risk Score field and select score from the dynamic content pane.

  4. Select Risk Scored for Status reason.

  5. Rename the step Update loan draw risk score.

  6. The update loan draw step should look like the image below.

review the details

  1. Click to expand the Run inspection process step.

  2. Remove the PropertyAddress value and select Address from the dynamic content pane.

enter details as described

  1. Expand the Run funding process step.

  2. Remove the RiskScore value and select Score from the dynamic content pane.

enter details as described

  1. Click Save and wait for the flow to be saved.

Task #2: Test the flow

  1. Click Test.

  2. Select Manually and click Test.

  3. Send an email to Funding@yourdomain.onmicrosoft.com with the Subject line as PS7765.

  4. The flow test should run and succeed.

  5. On the Run History for the flow test, all steps should show a green tick. Expand the Calculate Risk Score step.

  6. The output should look like the image below:

test the flow

  1. You should receive an email with the subject Draw Approved.