Automating Email Classification in Power Platform Using AI Prompts and Power Automate

Overview:
In this blog, we’ll walk through how to build an intelligent email classification system using Power Apps AI Prompts and Power Automate. This solution automatically categorizes incoming emails based on their content and assigns Outlook categories for easy organization.
This approach is ideal for organizations that deal with large volumes of emails and need quick, automated sorting without manual intervention.
Who Will Benefit?
Finance Teams: Automatically classify invoices, billing queries, and payment confirmations.
IT & Security Teams: Instantly flag security alerts or vulnerability notifications.
HR Departments: Sort resumes, onboarding emails, and recruitment-related communication.
Marketing Teams: Identify PR requests, campaign updates, and media inquiries.
Operations & Procurement: Organize vendor communications, RFPs, and purchase orders.
Executives & Managers: Reduce clutter and prioritize critical emails like meeting requests or urgent alerts.
Implementation Guide
Create a Power Apps AI Prompt
Go to Power Apps > Prompts > Build your own prompt
Define your prompt clearly.


Example Prompt:
Classify the email body into one of 10 predefined categories based on specific keywords or phrases.
Apply the following rules:
- Perform case-insensitive substring matching (exact phrase or partial match).
- Use only the email body text for matching; ignore attachments.
- Assign a single category per email, based on the first match found in the category list (precedence order matters).
- Return only the category name (e.g., 'Security Alert'). Do not include explanations or extra text.
- If no keywords match, return 'Uncategorized'.
- Matching must follow first match wins logic.
Categories and Matching Rules:
1. Security Alert
Match if body contains:
"phishing", "security incident", "breach", "compromised", "unauthorized access", "malware", "ransomware", "cve", "security advisory", "rotate credentials", "patch urgently", "critical vulnerability", "suspicious login"
2. Invoice & Billing
Match if body contains:
"invoice", "billing", "payment due", "overdue", "remit to", "billing address", "purchase order", "invoice attached", "bill to", "credit note", "debit note", "po number"
3. Feature Request
Match if body contains:
"feature request", "enhancement", "would be helpful if", "add support for", "can you add", "improvement", "suggestion", "new capability", "request for feature", "roadmap item"
4. Product Support
Match if body contains:
"bug", "error", "issue", "crash", "not working", "fails to", "broken", "support ticket", "troubleshoot", "steps to reproduce", "unexpected behavior", "defect"
5. Meeting Scheduling
Match if body contains:
"schedule a call", "set up a meeting", "availability", "calendar invite", "reschedule", "postpone", "time works", "meeting link", "teams call", "zoom call", "meeting tomorrow"
6. HR & Recruiting
Match if body contains:
"resume", "cv", "candidate", "interview", "job opening", "role description", "offer letter", "onboarding", "background check", "salary", "compensation", "joining date"
7. Marketing & PR
Match if body contains:
"press release", "media inquiry", "pr", "case study", "blog post", "social media", "campaign", "webinar", "newsletter", "brand guidelines", "marketing collateral"
8. Procurement & Vendor Management
Match if body contains:
"vendor", "supplier", "rfp", "rfq", "bid", "quote", "pricing", "contract renewal", "sla", "msa", "purchase order", "po number", "evaluation", "shortlist", "vendor onboarding", "vendor registration"
9. Travel & Expense
Match if body contains:
"travel", "flight", "hotel", "itinerary", "book", "reimburse", "expense report", "per diem", "receipts", "mileage", "travel request", "trip", "ticket"
10. Data & Analytics Request
Match if body contains:
"dashboard", "report", "metrics", "kpi", "dataset", "data pull", "export", "analysis", "csv", "tableau", "power bi", "refresh schedule", "data extract"
Make sure email body is an input parameter.
Add your Categories and Matching Rules (e.g., Security Alert, Invoice & Billing, Feature Request, etc.) based on the requirement.
Create a Power Automate Flow
Navigate to Power Automate > Create Flow.
Select Trigger: When a new email arrives (V3).
Configure the trigger to monitor the desired mailbox or folder.
Add an Action: Run a prompt.
Select the Prompt you created earlier.
Pass the email body from the trigger to the prompt input.
Add an Action: Assigns an Outlook category.
Use the output from the AI Prompt (Text) to set the category for the email.

Test the Flow
Send sample emails with content (e.g., invoices, security alerts, meeting requests).
Verify that the flow correctly classifies the email. Ensure the appropriate category is assigned to the email.


Benefits of This Approach
Time Savings: Automates manual sorting of emails.
Accuracy: Uses AI-based keyword matching for consistent classification.
Scalability: Works across departments and can handle large volumes of emails.
Integration: Seamlessly integrates with Outlook and Power Platform.



