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
-
Navigate to https://make.powerapps.com/ and make sure you are in the Dev environment.
-
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.
-
Enter Builder Risk Service for Display name, select Relecloud for Publisher, and click Create.
Task #2: Create custom connector
- Click + New and select Automation | Custom connector.
- Enter Builder Risk Service for Connector Name.
- Enter Service for evaluating builder risk for Description, enter adatumbuilderrisktest.azurewebsites.net for Host, and click Create connector.
Task #3: Import Open API
-
Navigate to https://adatumbuilderrisktest.azurewebsites.net/
-
Click Download Logo and save the logo on your machine.
-
Click on the API Key link.
-
Copy the API Key and save it on a notepad.
-
Click Return to home.
-
Click on the API documentation link.
-
Review the documentation.
-
Close the documentation browser tab or window, after you finish reviewing.
-
Click on the Open API definition file link.
-
On your keyboard press CTRL + S and select Save. Now the file is saved on your machine.
-
Navigate to https://make.powerautomate.com/ and make sure you are in the Dev environment.
-
Click More and select Discover all.
- Scroll down and select Custom connectors under data.
- Click on the … more actions button of the Builder Risk Service custom connector and select Update from OpenAPI file.
-
Click Import.
-
Select the swagger.json file you saved to your machine and click Open.
-
Click Continue.
-
Click Upload under the logo.
-
Select the logo you downloaded and click Open.
-
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.
-
Select Definition from the breadcrumb navigation bar at the top of the screen and see the operation imported.
-
Turn on Swagger Editor.
-
Have a look at the Swagger Editor and then turn off the Swagger Editor.
-
Select Update connector and wait for the connector to be updated.
-
Do not navigate away from this page.
Task #4: Test connector
- Select Test from the breadcrumb navigation bar at the top of the screen and click + New connection.
-
Paste your API Key and click Create connection.
-
Click the Refresh connections button, on the right. The connection you just created should be the Selected connection.
-
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.
- The test should run successfully, and you should receive a score and a reason.
- 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
-
Navigate to https://make.powerapps.com/ and make sure you are in the Dev environment.
-
Select Solutions and open the Construction Funding solution.
-
Select Cloud flows, select Process Construction Funding Request flow and click Edit.
- Click + insert new step after the Check if loan number found condition and select Add an action.
- Select Get a row by ID Microsoft Dataverse.
- Select Loans for Table name, click on the Row ID field and select LoanID from the dynamic content pane.
-
Rename the step Get loan.
-
Go to the + Insert a new step button after the Run inspection process and select Add an action.
- Go to the Custom tab and select Builder Risk Service.
-
Select the Calculate Risk Score action.
-
Enter Risk Service for Connection name, paste the API Key you copied earlier, and click Create.
- Click on the builderName field and select Builder from the dynamic content pane.
-
Click on the propertyAddress field and select Address from the dynamic content pane.
-
Click on the loanNumber field and select Loan Number from the dynamic content pane.
-
Click on the loanDate field and select Loan Date from the dynamic content pane.
-
Click on the loanAmount field and select Loan Amount form the dynamic content pane.
-
Click on the creditAvailable field and select Credit Available from the dynamic content pane.
-
Enter 80000 for drawAmount.
-
The calculate risk score step should now look like the image below.
- Click on the + Insert a new step after the Calculate Risk Score step and select Add an action.
-
Select Update a row Microsoft Dataverse.
-
Select Loan Draws for Table name, click on the Row ID field and select Loan Draw from the dynamic content pane.
-
Expand Show advanced options and Click on the Risk Score field and select score from the dynamic content pane.
-
Select Risk Scored for Status reason.
-
Rename the step Update loan draw risk score.
-
The update loan draw step should look like the image below.
-
Click to expand the Run inspection process step.
-
Remove the PropertyAddress value and select Address from the dynamic content pane.
-
Expand the Run funding process step.
-
Remove the RiskScore value and select Score from the dynamic content pane.
- Click Save and wait for the flow to be saved.
Task #2: Test the flow
-
Click Test.
-
Select Manually and click Test.
-
Send an email to Funding@yourdomain.onmicrosoft.com with the Subject line as PS7765.
-
The flow test should run and succeed.
-
On the Run History for the flow test, all steps should show a green tick. Expand the Calculate Risk Score step.
-
The output should look like the image below:
- You should receive an email with the subject Draw Approved.