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:
- Log in to Azure Portal (Ensure you're signed in as an admin).
- Navigate to Microsoft Entra ID:
- Click on Microsoft Entra ID in the sidebar (or search for it)
- Select App registrations from the left navigation
- Create New Registration:
- Click + New registration
- Enter a descriptive name for your application (e.g., "Leena AI Power Automate Integration")
- Select "Accounts in this organizational directory only" for Supported account types
- Click Register
- Note Application Details:
- Copy the Application (client) ID - this will be your Client ID
- Copy the Directory (tenant) ID - this will be your Tenant ID
- Create Client Secret:
- Navigate to Certificates & secrets in the left menu
- Click + New client secret
- Enter a description and select expiration period
- Click Add
- Important: Copy the secret value immediately (it won't be shown again) - this will be your Client Secret
- Configure API Permissions:
- Navigate to API permissions
- Click + Add a permission
- Select Dynamics CRM
- Select Delegated permissions
- Check "user_impersonation"
- Click Add permissions
- Click "Grant admin consent" for your tenant
- Enable Public Client Flow:
- Navigate to Authentication
- Under Advanced settings, set "Allow public client flows" to Yes
- Click Save
- Get Organizational URI:
- Navigate to Power Platform Admin Center
- Select your environment
- Copy the Environment URL (e.g., https://yourorg.crm.dynamics.com)
Add connection
Here is how to add a connection on Leena AI:
- Log in to your Leena AI workspace
- Navigate to Settings > Integrations
- Search for "Power Automate" and select it from the list to add its new connector
- Start configuring the connector
- Auth Type: Select "Power Automate OAuth 2.0"
- Tenant ID: The Directory (tenant) ID from Azure app registration
- Client ID: The Application (client) ID from Azure app registration
- Organizational URI: The Power Platform environment URL (e.g., https://yourorg.crm.dynamics.com)
- Client Secret: The client secret value from Azure app registration
- Username: The username of a Power Platform user with appropriate permissions
- Password: The password for the specified user
- Save Connection
- Click Save to store the connector configuration
- The connector will authenticate using the provided credentials
- 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
| Name | Description |
|---|---|
| Workflow ID | The unique identifier of the desktop flow to trigger |
| Connection Name | The name of the machine connection to use for running the desktop flow |
| Timeout | Maximum time (in seconds) to wait for the flow to complete |
Optional
| Name | Description |
|---|---|
| Run Mode | The execution mode for the desktop flow; options: attended (default) - runs with user interaction, unattended - runs in background |
| Run Priority | The priority level for the flow execution; options: low, normal (default), high |
| Callback URL | URL to receive notifications when the flow completes |
| Inputs | Dynamic 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
| Name | Description |
|---|---|
| FilterBy | OData filter expression to filter the desktop flows (e.g., "name eq 'MyFlow'") |
| Select | Comma-separated list of fields to return (e.g., "name,workflowid,createdon") |
| orderBy | Field 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
| Name | Description |
|---|---|
| Flow Session ID | The unique identifier of the flow session to check |
Optional
| Name | Description |
|---|---|
| Select | Comma-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
| Name | Description |
|---|---|
| Flow Session ID | The 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
| Name | Description |
|---|---|
| Flow Session ID | The 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
Updated 1 day ago
