Skip to main content
Version: 8.1

Power Automate Connector

The Power Automate Connector allows you to orchestrate a Power Automate flow from your BPMN process with Power Automate.

Prerequisites

To use the Power Automate Connector, ensure you have configured the following:

  1. Azure AD application with proper permissions. Visit the official documentation to see how you can create one.
  2. Create an application user and add security roles.
  3. Power Automate desktop application, and sign in to create your Power Automate Flow.
  4. Power Automate machine runtime desktop application to manage and troubleshoot machine settings, and enable the on-premise data gateway to access your machine data.
  5. Power Automate on-premises data gateway desktop application to create a connection between the cloud environment and your desktop app.

Create a Power Automate Connector task

To use a Power Automate Connector in your process, either change the type of existing task using the wrench-shaped Change type context menu, or create a new Connector task using the Append Connector context menu. Follow our guide on using Connectors to learn more.

Operation types

The Power Automate Connector currently supports three operation types in the Operation type dropdown list: Get the status of a flow run, Get flow outputs, and Trigger a flow run.

Power Automate Connector operations

Authentication

You can choose among the available Power Automate Connector authentication types according to your authentication requirements.

Power Automate Connector (bearer token)

Create a new Connector secret

We advise you to keep your Bearer Token safe and avoid exposing it in the BPMN xml file by creating a secret:

  1. Follow our guide for creating secrets.
  2. Name your secret (i.e POWER_AUTOMATE_BEARER_TOKEN) so you can reference it later in the Connector.

Configure the bearer token

Click here to see how to get the Bearer token with Postman.

Select the Power Automate Connector and fill out the following properties under the Authentication section:

  1. Click Bearer Token in the Authentication section.
  2. Set Bearer to the secret you created (i.e. secrets.POWER_AUTOMATE_BEARER_TOKEN).

Power Automate Connector bearer token

OAuth 2.0

Create a new Connector secret

We advise you to keep your Client ID safe and avoid exposing it in the BPMN xml file by creating a secret:

  1. Follow our guide for creating secrets.
  2. Name your secret (i.e POWER_AUTOMATE_CLIENT_ID) so you can reference it later in the Connector.

Configure the OAuth Token

Select the Power Automate Connector and fill out the following properties under the Authentication section:

  1. Click OAuth 2.0 in the Authentication section.
  2. Set Client Id to the secret you created (i.e. secrets.POWER_AUTOMATE_CLIENT_ID).
  3. Set Client secret to the secret you created (i.e. secrets.POWER_AUTOMATE_CLIENT_SECRET).
  4. Set OAuth Token Endpoint to the secret you created (i.e. secrets.POWER_AUTOMATE_TOKEN_ENDPOINT).

Power Automate Connector oauth token

OAuth Token Endpoint

You should provide the OAuth Token Endpoint in the following format: https://login.microsoftonline.com/{tanantID}/oauth2/v2.0/token

Read more on how you can find your tenantID.

Trigger a flow run

This operation allows you to trigger a Power Automate desktop flow. To execute it, take the following steps:

  1. Select the operation Trigger a flow run from the Operation type dropdown list.
  2. Configure authentication as described in the authentication section.
  3. Fill out the input fields as described in the configuration section.
  4. Fill out the input fields as described in the input section.
  5. Fill out the response mapping as described in the trigger a flow run response section.

Power Automate Connector - Trigger a flow run

Trigger a flow run response

The operation Trigger a flow run returns information about the triggered flow.

You can use an output mapping to map the response:

  1. Use Result Variable to store the response in a process variable. For example, myResultVariable.
  2. Use Result Expression to map fields from the response into process variables. It comes with a pre-filled value of = {flowSessionId: response.body.flowsessionId}. To use operation Get the status of a flow run, you need a flowSessionId. This expression will add it in the context for you. Learn more in get the status of a flow run.

Response example:

= {
"@odata.context": "https://org11aaa11a.crm4.dynamics.com/api/data/v9.2/$metadata#Microsoft.Dynamics.CRM.RunDesktopFlowResponse",
"flowsessionId": "bb2a1f33-e5b9-ed11-83fe-000d3ab4f483",
"licenseCheck": {
"@odata.context": "#Microsoft.Dynamics.CRM.expando",
"code": "ValidLicenseCoverage",
"message": "Valid License Coverage"
}
}

Configuration

For this section, you must fill out the Organization URI. This is your dynamics 365 URL. Visit the docs or learn about environments to see how to find it.

Input

For this section, you must fill out the following fields:

  1. Workflow ID (Flow ID): The ID of the Power Automate desktop flow.
  2. Connection name: Connection to be used with the desktop flow script. You can specify it as connection name or as Connection Reference Logical Name. In the latter case, you have to set the connectionType accordingly. See how to get the connection name.
  3. Connection type: Identifies which type of connection is used in the connection name parameter. Connection type (default), or a connection reference type.
  4. Run mode: Choose between attended or unattended.
  5. Run priority: Choose an option (normal, high) or add your own.
  6. (Optional) Inputs: The desktop flow script input parameters (JSON serialized string).
  7. (Optional) Callback URL: URL that will be called once the desktop flow script is complete. See how to use the Webhook Connector as a callback endpoint.

Get the status of a flow run

The operation Get the status of a flow run returns information about the newly triggered flow session.

Configuration

For this section, you must fill out Organization URI. This is your dynamics 365 URL. Visit the docs or learn about environments to see how to find it.

Input

For this section, you must fill out Flow session ID. This is the unique identifier for entity instances. You can find this in the response of the 'Trigger a flow run' method.

Output

You can use an output mapping to map the response:

  1. Use Result Variable to store the response in a process variable. For example, myResultVariable.
  2. Use Result Expression to map fields from the response into process variables. It comes with a pre-filled value of = {statusCode: response.body.statuscode}.

Response example:

= {
"@odata.context": "https://[Organization URI]/api/data/v9.2/$metadata#flowsessions(statuscode,statecode,startedon,completedon)/$entity",
"@odata.etag": "W1276122",
"statuscode": 4,
"statecode": 0,
"startedon": "2022-06-16T12:54:40Z",
"completedon": "2022-06-16T12:57:46Z",
}

Meaning of the different status codes based on the official documentation:

StatusStatuscode
0NotSpecified
1Paused
2Running
3Waiting
4Succeeded
5Skipped
6Suspended
7Cancelled
8Failed
9Faulted
10TimedOut
11Aborted
12Ignored
13Deleted
14Terminated

Get flow outputs

The operation Get flow outputs returns the output of the triggered Power Automate flow.

Configuration

For this section, you must fill out Organization URI. This is your dynamics 365 URL. Visit the docs or learn about environments to see how to find it.

Input

For this section, you must fill out Flow session ID. This is the unique identifier for entity instances. You can find this in the response of the 'Trigger a flow run' method.

Output

You can use an output mapping to map the response:

  1. Use Result Variable to store the response in a process variable. For example, myResultVariable.
  2. Use Result Expression to map fields from the response into process variables. It comes with a pre-filled value of = {flowOutputs: response.body}.

Response example:

= {
"Output1": "My output value"
}

Appendix

Using Power Automate Connector best practice

Using Webhook Connector as callback endpoint

Oftentimes, it is desired to continue the process after a Power Automate flow run finished. You can use the Callback URL field if you select the Trigger a flow run to specify a URL which will be called after the flow is finished.

If you wish to continue the Camunda process or start a new one, the Webhook Connector is a good next step. For this, take the following steps:

  1. Create a Webhook Connector and specify the Webhook ID.

  2. Create a Power Automate Connector, select the Trigger a flow run method, and fill in the fields.

    If you use Camunda Platform 8 SaaS, you can use the following pattern for the Callback URL: {zeebe.client.cloud.region}.{zeebeHostUrl}/{zeebe.client.cloud.clusterId}/inbound/{webhookId}.

    If you use Camunda Platform 8 SaaS you can find the Zeebe-specific values in you cluster details on the API tab under Client Credentials. The webhookId is the id you specified in the first step, and the zeebeHostUrl is connectors.camunda.io.

    Power Automate Connector - Azure AD app allow implicit flow

Get Bearer token with Postman

  1. Allow implicit flow in your Azure AD app. Power Automate Connector - Azure AD app allow implicit flow
  2. Visit the official site to see how to set up the Postman environment.
  3. Generate an access token and use it in the Bearer token field.

How to get the connection name

  1. Go to you Power Platform admin center, and select Power Automate app from the top left menu.

  2. In the left menu bar under Data, select Connections > New connection.

  3. Select Desktop flows and provide the domain and username of the user on the machine where the desktop flows are running, and also provide the password belongs to this user.

  4. Click Create.

    Power Automate Connector - Create connection

  5. Click on the newly created connection, and you can find your connection name in the URL as shown in the picture below. This is a default connection type.

    Power Automate Connector - Connection name