Skip to main content

Introduction

Purpose and Overview

Power Automate integration enables bidirectional communication: Inbound Triggers (Microsoft 365 → ELITEA):
  • React to Teams Messages: Automatically process incoming Teams messages using ELITEA AI agents
  • Process Emails: Route incoming emails to ELITEA agents for intelligent processing
  • Scheduled Processing: Periodically check for mentions or specific conditions
Outbound Actions (ELITEA → Microsoft 365):
  • Reply to Teams: Send messages back to Teams channels or chats
  • Send Emails: Compose and send emails via Outlook
  • Reply to Emails: Respond to email threads programmatically
This guide covers two patterns:
  1. Power Automate triggering ELITEA - Flows that send data to ELITEA agents
  2. ELITEA triggering Power Automate - Agents using OpenAPI tools to invoke Power Automate HTTP endpoints

Key Terms

Prerequisites

Before you begin, ensure you have:
  • Access to Microsoft Power Automate (Premium license recommended for HTTP triggers)
  • An ELITEA account with a configured agent
  • ELITEA Personal Access Token (PAT) for API authentication
  • The following ELITEA identifiers:
    • Project ID: Found in Settings → Configuration
    • Agent ID: The ID of your configured agent
    • Agent Version ID: The specific version of your agent to use
    • Toolkit ID: (Optional) For attachment storage configuration
Navigate to your agent in ELITEA and note the URL structure or check the agent details panel for the required IDs.

ELITEA API Overview

Power Automate communicates with ELITEA through the following API endpoints:

Core Endpoints

Base URLs

Authentication

All API requests require a Bearer token in the Authorization header:

Part 1: Power Automate → ELITEA (Inbound Triggers)

This section covers flows that send data from Microsoft 365 to ELITEA agents.

Setup and Configuration

Step 1: Prepare ELITEA Agent

  1. Navigate to Agents in your ELITEA project
  2. Create or select an existing agent for your automation
  3. Configure the agent with appropriate instructions for handling automated requests
  4. Note the following values:
    • Agent ID: Visible in agent details
    • Agent Version ID: Found in the version selector
    • Project ID: Located in Settings → Configuration
Include clear instructions in your agent about the expected input format and how to respond. For example:
  • For email processing: “You will receive email content. Reply via email using the message ID provided.”
  • For Teams: “This is a Teams request. You MUST reply via Teams.”

Step 2: Generate Personal Access Token

  1. Go to SettingsPersonal Access Tokens
  2. Click Create Token
  3. Provide a descriptive name (e.g., “Power Automate Integration”)
  4. Copy and securely store the generated token
Store your PAT securely. Never expose it in client-side code or share it publicly. Consider using environment variables or secure storage in Power Automate.

Scenario 1: React to Teams Messages

This flow automatically responds to Teams chat messages using an ELITEA agent.

Flow Overview

Step-by-Step Configuration

1. Create the Flow

  1. Navigate to make.powerautomate.com
  2. Click CreateAutomated cloud flow
  3. Name: “React on Teams message trigger”
  4. Trigger: When a new chat message is added (Microsoft Teams)

2. Initialize Variables

Add the following Initialize variable actions in sequence:

3. Process Messages

Add For each action on triggerOutputs()?['body/value']: Get Message Details:

4. Detect Chat Type

Teams has three chat types that require different handling: Get Chat Details:
Compose_chatType:

5. Detect @Mentions

For group and meeting chats, check if the bot was mentioned using the mentions array from the message details.
The Graph API returns a mentions array containing each @mention in the message:
Compose_isMentioned (using Bot User ID - most reliable):
Replace YOUR_BOT_USER_ID with your bot’s actual user ID (e.g., d346094f-19d8-48e7-b53e-fd7909afff91). Alternative (check by display name):

6. Detect Reply and Forwarded Messages

Optionally detect if a message is a reply or forwarded content: Compose_isReply:
Compose_isForwarded:
Compose_MessageContext:

7. Filter Messages (Main Condition)

Combine all checks into a single condition to determine if the message should be processed: Condition Expression (Advanced Mode):
This logic:
  • Always processes 1:1 chat messages
  • Only processes group/meeting chat messages when the bot is @mentioned
  • Filters out bot’s own messages (prevents infinite loops)
  • Filters out system events (member added/removed, etc.)
To also respond to replies in group chats (assuming they’re continuing a conversation):

8. Send Acknowledgment

9. Build Chat History

Use a Loop on recent messages to build context:

10. Check/Create Conversation

Check Existing:
Condition: If conversation exists (total > 0):
  • Get conversation details
  • Filter for agent participant
  • Extract participant ID
Else (Create New):
  1. Create conversation
  2. Configure attachment storage
  3. Add agent as participant

11. Handle Screenshots and Attachments

Screenshots pasted into Teams messages are stored as “hosted contents”. Process them as follows: List Hosted Contents:
Loop Through Each Hosted Content:
Get Screenshot Content:
Check if Image (Condition):
Generate Filename:
Convert to Binary:
Upload to ELITEA:
Append to attachment_info:
Clean Trailing Comma (after loop):

12. Send Message to Agent

Compose User Input with Context: Include message context (reply/forward indicators) and chat history:
Send to Agent:

Complete Flow Structure


Scenario 2: Process Incoming Emails

This flow processes emails sent to a monitored mailbox and routes them to ELITEA agents.

Flow Overview

Two Approaches

Option A: Email Trigger (Real-time)

Trigger: When a new email arrives (V3)
  • To: Your monitored mailbox (e.g., SupportAlita@epam.com)
  • Processes emails as they arrive

Option B: Scheduled Check (Polling)

Trigger: Recurrence (e.g., every 1 minute)
  • Get emails (V3): Fetch unread emails with specific criteria
  • Filter: Check for @mentions or keywords
  • Useful for more controlled processing

Key Configuration

Email Metadata Composition

Reply Instructions

Include the message ID so the agent can reply:

Conversation Persistence with SharePoint

Use a SharePoint list to map email conversations to ELITEA conversations:

Part 2: ELITEA → Power Automate (Outbound Actions)

This section covers HTTP-triggered flows that ELITEA agents can invoke using OpenAPI tools.

Creating HTTP-Triggered Flows

HTTP triggers create webhook endpoints that ELITEA agents can call.
HTTP Request triggers require a Power Automate Premium license.

Scenario 3: Reply to Teams Channel

Allows ELITEA agents to post replies in Teams channels.

Flow Configuration

Trigger: When an HTTP request is received Request Body Schema:
Action: Reply with a message in a channel (Teams connector) Response:

Scenario 4: Reply to Teams Chat

Allows ELITEA agents to send messages to Teams 1:1 or group chats.

Flow Configuration

Trigger: When an HTTP request is received Request Body Schema:
Action: HTTP Request (Teams connector - Graph API)
The message body must be properly escaped for JSON. Use expressions to escape quotes and newlines:

Scenario 5: Send Email

Allows ELITEA agents to compose and send new emails.

Flow Configuration

Trigger: When an HTTP request is received Request Body Schema:
Action: Send an email (V2) - Office 365 Outlook

Scenario 6: Reply to Email

Allows ELITEA agents to reply to existing email threads.

Flow Configuration

Trigger: When an HTTP request is received Request Body Schema:
Action: Reply to email (V3) - Office 365 Outlook

Configuring OpenAPI Tools in ELITEA

To enable ELITEA agents to call Power Automate flows, create an OpenAPI tool specification.

Example: Reply to Email OpenAPI Spec

Agent Instructions for OpenAPI Tools

Include clear guidance in your agent instructions:

Handling Attachments

Power Automate flows can upload attachments to ELITEA conversations for agent processing.

Step 1: Configure Attachment Storage

Before uploading, configure the attachment storage for the conversation:
The toolkit_id refers to a storage toolkit configured in your ELITEA project (e.g., Artifacts toolkit).

Step 2: Upload Attachment

Power Automate Format:
curl Example:
curl with Base64 Content (inline):
Postman Configuration:
  1. Method: POST
  2. URL: https://next.elitea.ai/api/v1/chat/attachments/prompt_lib/{{PROJECT_ID}}/{{CONVERSATION_ID}}
  3. Headers:
    • Authorization: Bearer {{YOUR_PAT}}
  4. Body: Select form-data
ELITEA supports common file types including images (PNG, JPEG, GIF), documents (PDF, DOCX, TXT), and data files (CSV, JSON). Check your agent’s configuration for specific file size limits.

Step 3: Include in Message

Reference uploaded attachments in your message:

Processing Attachments from Different Sources

Teams Hosted Content (Images)

Email Attachments


Error Handling Pattern

All HTTP-triggered flows should implement proper error handling:

Complete Flow Examples

Example 1: Teams Bot Flow Structure

The enhanced condition ensures:
  • 1:1 chats: All messages processed
  • Group chats: Only @mentioned messages processed
  • Meeting chats: Only @mentioned messages processed

Example 2: Email Processing Flow Structure

Example 3: HTTP Reply Flow Structure


Verification

After setting up your flows:

Test Inbound Flows (Power Automate → ELITEA)

  1. Trigger the Flow:
    • For Teams: Send a message to the monitored chat
    • For Email: Send an email to the monitored mailbox
    • Use the Test button in Power Automate for manual testing
  2. Check ELITEA:
    • Navigate to your ELITEA Chat
    • Verify the conversation was created
    • Confirm the agent received and processed the message
  3. Review Flow History:
    • Check the flow run history for any errors
    • Examine HTTP response bodies for debugging

Test Outbound Flows (ELITEA → Power Automate)

  1. Get the HTTP Trigger URL:
    • Open your flow
    • Copy the HTTP POST URL from the trigger
  2. Test with curl or Postman:
  3. Configure ELITEA Agent:
    • Add the OpenAPI tool to your agent
    • Test the agent with appropriate prompts

Troubleshooting

Common Issues

Debug Tips

Add Compose actions to log intermediate values during development. View outputs in the flow run history.
  • Use Run after settings to handle failures gracefully
  • Add error handling with Scope and Try-Catch patterns
  • Check Power Automate run history for detailed error messages
  • Use the Peek code feature to see raw JSON of actions
  • Test HTTP requests independently using Postman

Preventing Infinite Loops

For Teams integrations, always check:
  1. The message sender is not the bot account
  2. The message type is “message” (not system events)
  3. The eventDetail is null (not member added/removed events)
  4. For group/meeting chats: the bot is @mentioned
Basic Condition (1:1 chats only):
Enhanced Condition (with chat type filtering):
This enhanced condition:
  • Always processes 1:1 chat messages
  • Only processes group/meeting messages when @mentioned
  • Filters out all system events and bot’s own messages

Detecting @Mentions Reliably

Use the mentions array from the message details rather than parsing HTML content: By Bot User ID (most reliable):
By Display Name:
Check the mentions array in a test message. Each mention includes the user’s id field:

Security Best Practices

  1. Store Credentials Securely:
    • Use Power Automate’s Connections for Microsoft 365 authentication
    • Store ELITEA PATs securely (consider Azure Key Vault for production)
    • Never hardcode tokens in flow definitions
  2. Limit Permissions:
    • Create dedicated service accounts for automation
    • Use least-privilege principles for API tokens
    • Restrict flow access to authorized users
  3. Monitor and Audit:
    • Review flow run history regularly
    • Set up alerts for failed runs
    • Enable logging for security-sensitive operations
  4. Validate Inputs:
    • Sanitize user inputs before processing
    • Validate message sources
    • Implement rate limiting for HTTP triggers