Power Automate

Overview

The Power Automate connector enables your AI Colleagues to integrate with Microsoft Power Automate platform, facilitating automated desktop flow management, triggering RPA workflows, and monitoring flow executions.

Microsoft Power Automate is a cloud-based service that enables users to create automated workflows between applications and services. It includes Power Automate Desktop, which allows for robotic process automation (RPA) by automating repetitive desktop tasks. The Power Automate connector allows Leena AI to trigger desktop flows, monitor their execution status, retrieve outputs, and manage flow lifecycles seamlessly.

API Details

Leena AI integrates with Power Automate via Microsoft Dataverse Web APIs (REST APIs).

Documentation link: https://learn.microsoft.com/en-us/power-automate/developer/desktop-flow-public-apis

Setup

The Power Automate connector uses OAuth 2.0 authentication with the Resource Owner Password Credentials (ROPC) grant type.


Prerequisites

Before setting up the Power Automate connector, ensure you have:

  • Administrator access to Microsoft Azure Portal
  • Access to Microsoft Entra ID (Azure Active Directory)
  • A Power Platform environment with desktop flows configured
  • Power Automate Desktop installed and configured on target machines
  • Access to your Leena AI workspace with connector management permissions

Get credentials

Here is how to create an application registration in Microsoft Entra ID:

  1. Log in to Azure Portal (Ensure you're signed in as an admin).
  2. Navigate to Microsoft Entra ID:
    1. Click on Microsoft Entra ID in the sidebar (or search for it)
    2. Select App registrations from the left navigation
  3. Create New Registration:
    1. Click + New registration
    2. Enter a descriptive name for your application (e.g., "Leena AI Power Automate Integration")
    3. Select "Accounts in this organizational directory only" for Supported account types
    4. Click Register
  4. Note Application Details:
    1. Copy the Application (client) ID - this will be your Client ID
    2. Copy the Directory (tenant) ID - this will be your Tenant ID
  5. Create Client Secret:
    1. Navigate to Certificates & secrets in the left menu
    2. Click + New client secret
    3. Enter a description and select expiration period
    4. Click Add
    5. Important: Copy the secret value immediately (it won't be shown again) - this will be your Client Secret
  6. Configure API Permissions:
    1. Navigate to API permissions
    2. Click + Add a permission
    3. Select Dynamics CRM
    4. Select Delegated permissions
    5. Check "user_impersonation"
    6. Click Add permissions
    7. Click "Grant admin consent" for your tenant
  7. Enable Public Client Flow:
    1. Navigate to Authentication
    2. Under Advanced settings, set "Allow public client flows" to Yes
    3. Click Save
  8. Get Organizational URI:
    1. Navigate to Power Platform Admin Center
    2. Select your environment
    3. Copy the Environment URL (e.g., https://yourorg.crm.dynamics.com)

Add connection

Here is how to add a connection on Leena AI:

  1. Log in to your Leena AI workspace
  2. Navigate to Settings > Integrations
  3. Search for "Power Automate" and select it from the list to add its new connector
  4. Start configuring the connector
    1. Auth Type: Select "Power Automate OAuth 2.0"
    2. Tenant ID: The Directory (tenant) ID from Azure app registration
    3. Client ID: The Application (client) ID from Azure app registration
    4. Organizational URI: The Power Platform environment URL (e.g., https://yourorg.crm.dynamics.com)
    5. Client Secret: The client secret value from Azure app registration
    6. Username: The username of a Power Platform user with appropriate permissions
    7. Password: The password for the specified user
  5. Save Connection
    1. Click Save to store the connector configuration
    2. The connector will authenticate using the provided credentials
    3. Upon successful authentication, the connector will be ready to use

Actions

The following actions are supported for the Power Automate connector:

Trigger Desktop Flow

Triggers a desktop flow run in Microsoft Power Automate. The Agent can leverage the skill (workflow), which has been designed to initiate a desktop flow execution, once the user raises a request to run an automated process.


Input Parameters

Here are the input parameters required to set up this action:

Mandatory

NameDescription
Workflow IDThe unique identifier of the desktop flow to trigger
Connection NameThe name of the machine connection to use for running the desktop flow
TimeoutMaximum time (in seconds) to wait for the flow to complete

Optional

NameDescription
Run ModeThe execution mode for the desktop flow; options: attended (default) - runs with user interaction, unattended - runs in background
Run PriorityThe priority level for the flow execution; options: low, normal (default), high
Callback URLURL to receive notifications when the flow completes
InputsDynamic input parameters defined by the desktop flow (varies based on the selected flow)

Here is a sample JSON input:

//Basic Trigger

{
  "workflowId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "connectionName": "Desktop-Machine-01",
  "timeout": 7200,
  "runMode": "attended",
  "runPriority": "normal"
}

//Trigger with Inputs

{
  "workflowId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "connectionName": "Desktop-Machine-01",
  "timeout": 3600,
  "runMode": "unattended",
  "runPriority": "high",
  "Input1": "Value1",
  "Input2": "Value2"
}

//Trigger with Callback

{
  "workflowId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "connectionName": "Desktop-Machine-01",
  "timeout": 7200,
  "runMode": "attended",
  "runPriority": "normal",
  "callbackUrl": "https://your-callback-endpoint.com/webhook"
}

Response

Upon successful trigger, the action returns:

  • Flow Session ID (unique identifier for tracking the flow run)
  • HTTP status code
  • Execution initiation timestamp

Get Desktop flows

Retrieves a list of desktop flows from Power Automate. This action can be leveraged by Leena AI Orchestrator/Agent to discover available desktop flows in the environment. Here are some common use cases:

  • Flow Discovery: List all available desktop flows
  • Flow Search: Find specific flows by name or properties
  • Inventory Management: Catalog all RPA automations
  • Workflow Selection: Help users choose the right flow to execute

Input Parameters

Here are the input parameters required to set up this action:

Mandatory

None - all parameters are optional for this action.

Optional

NameDescription
FilterByOData filter expression to filter the desktop flows (e.g., "name eq 'MyFlow'")
SelectComma-separated list of fields to return (e.g., "name,workflowid,createdon")
orderByField name to sort results by (default: "name")

Here is a sample JSON input:

//List All Desktop Flows

{
  "orderby": "name"
}

//Filter by Name

{
  "filter": "contains(name, 'Invoice')",
  "select": "name,workflowid,createdon",
  "orderby": "createdon"
}

//Select Specific Fields

{
  "select": "name,workflowid,description,modifiedon",
  "orderby": "modifiedon"
}

Response

The action returns a list of desktop flows, each containing:

  • Workflow ID
  • Flow name
  • Description
  • Created date
  • Modified date
  • Owner information
  • Category and type details

Get Desktop flow status

Retrieves the execution status of a specific desktop flow run. The Agent can leverage this action to monitor the progress of a triggered desktop flow and report status back to users. Here are some common use cases:

  • Progress Monitoring: Check if a flow is still running
  • Completion Verification: Confirm when a flow has finished
  • Error Detection: Identify failed flow executions
  • Status Reporting: Provide updates to users about their automation requests

Input Parameters

Here are the input parameters required to set up this action:

Mandatory

NameDescription
Flow Session IDThe unique identifier of the flow session to check

Optional

NameDescription
SelectComma-separated list of fields to return in the response

Here is a sample JSON input:

//Basic Status Check

{
  "flowSessionId": "d9687093-d0c0-ec11-983e-0022480b428a"
}

//Status with Specific Fields

{
  "flowSessionId": "d9687093-d0c0-ec11-983e-0022480b428a",
  "select": "statuscode,statecode,startedon,completedon"
}

Response

The action returns the flow session details including:

  • Status Code (1: Running, 2: Succeeded, 3: Failed, 4: Suspended, 5: Canceling, 6: Canceled, 7: Resuming, 8: Terminated)
  • State Code
  • Started On timestamp
  • Completed On timestamp
  • Error details (if applicable)

Get Desktop flow output

Retrieves the output data from a completed desktop flow execution. The Agent can leverage this action to obtain results and data produced by a desktop flow after it has finished running. Here are some common use cases:

  • Result Retrieval: Get data generated by the automation
  • Data Processing: Use flow outputs in subsequent workflow steps
  • Report Generation: Collect results for reporting purposes
  • Integration: Pass flow outputs to other systems

Input Parameters

Here are the input parameters required to set up this action:

Mandatory

NameDescription
Flow Session IDThe unique identifier of the completed flow session

Here is a sample JSON input:

{
  "flowSessionId": "d9687093-d0c0-ec11-983e-0022480b428a"
}

Response

Upon successful retrieval, the action returns:

  • Output variables defined by the desktop flow
  • Data values produced during execution
  • Any files or structured data generated by the flow

Cancel Desktop flow

Cancels a running or queued desktop flow execution. The Agent can leverage this action to stop a desktop flow that is currently running or waiting in queue. Here are some common use cases:

  • Emergency Stop: Immediately halt a misbehaving automation
  • Resource Management: Free up machine resources by stopping unnecessary flows
  • Error Recovery: Cancel flows that are stuck or taking too long
  • User Request: Stop a flow when a user no longer needs the automation

Input Parameters

Here are the input parameters required to set up this action:

Mandatory

NameDescription
Flow Session IDThe unique identifier of the flow session to cancel

Here is a sample JSON input:

{
  "flowSessionId": "d9687093-d0c0-ec11-983e-0022480b428a"
}

Response

Upon successful cancellation, the action returns:

  • Confirmation of cancellation request
  • HTTP status code
  • Updated flow session status