Build your next OutSystems app Microsoft Power Automate enabled

Microsoft Power Automate

Power Automate’s ease of use truly allows any user to automate repetitive tasks. The creation of a Power Automate flow starts with the selection of a trigger. There are three types of triggers: manual, automatic and scheduled. The trigger determines when subsequent activities in the flow — actions — are run — manually initiated by a user, automatically after an event occurred or periodically based on a schedule.

OutSystems Integration

An action in a Power Automate flow is a request to a REST API. So, for every action we want to have in our Power Automate Flow we have to expose an endpoint in OutSystems.

Demo Application — Overview

To show how to integrate Power Automate with an OutSystems application i have prepared a demo application available on the forge: Power Automate Integration Demo.

  • any expense entry is created
  • Retrieve details of an expense entry for a given id
  • Retrieve all expense entries of a given category
  • Create a new expense entry

Demo Application — Exposed REST APIs

The PowerAutomateExpensesAPI module exposes REST API endpoints. Note that Authentication is set to Basic Authentication. The implementation in the OnAuthentication handler contains the default implementation using User_Login from the System module.

  • Basic — Username and Password authentication as shown in the demo application
  • API Key — any key in the header or url of a request
  • OAuth — a central identity service (Azure AD, Okta etc.) supporting the OAuth authentication flow. (my recommendation in public facing environments).
Exposed REST APIs
  • Query a static entity if the registration event type matches an entry and throw a 400 Bad Request if not
  • Register the webhook target url with the CloudEvents Notification service and throw a 429 Conflict if not successful
  • Return a 201 Created Status
Callback register

Demo Application — Notifying registered webhook subscribers

Emitting an event to our webhook subscribers is done in the AddExpense server action:

  • Create the expense entry
  • Builds and serializes the event payload (in our case that is just the Expense Identifier)
  • Calls the CloudEvents_EventPush service action with the serialized payload and the Expense.Created event type.
AddExpense server action

Custom Connector — Definition

I already prepared a custom connector definition. You can find the completed definition file in this github repository

Import OpenAPI file

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Stefan Weber

Stefan Weber

Head of Citizen Development & Low Code Practice at ISD FENIQS.