CloudEmail & Graph APIAutomatedPremium connectors

Email Thread Summarizer & Reply Drafter

On a flagged Outlook email, walks the entire thread, generates a concise summary plus a draft reply, and posts to a Teams channel for team visibility.

Members OnlySign in or create a free account to download this solution.

Overview

Triggers when the connection owner flags an email, sends the body to AOAI for summarization + reply suggestion, and posts the result as formatted HTML to a Teams channel. AI triage pattern — flag a thread, get the digest in your team channel seconds later.

**Flow ID:** 235ee112-6437-f111-88b3-6045bd0052fe • **State:** Off

Use Case

Long email threads chew up time when sharing status with a wider audience. People summarize manually before forwarding — slow, error-prone, inconsistent. This flow lets anyone flag a thread to trigger an AOAI summary that lands in a Teams channel with a suggested reply.

**Key Benefits:** trigger is just "flag an email" — no new UX; AOAI handles summary + draft in one call; Teams output for team visibility; structured-reply parsing splits summary, action items, draft.

Flow Architecture

Trigger: **When An Email Is Flagged** (Office 365 Outlook).

1. Init 7 vars (AOAI endpoint/deployment/api version/key, Teams group + channel, system prompt)
2. Compose AOAI Request Body — system prompt + flagged email body
3. **Call Azure OpenAI** (HTTP)
4. Parse AOAI Completion → extract content
5. Parse Structured Reply → summary, actionItems, draftReply
6. Compose Teams Message HTML
7. **Post Summary To Teams** (PostMessageToChannel)

Environment Variables

VariableSchema NameTypeDefaultPurpose
FlowLibs AOAI Endpointflowlibs_AOAIEndpointString(none)Azure OpenAI resource endpoint
FlowLibs AOAI Deployment Nameflowlibs_AOAIDeploymentString(none)Chat-completion deployment name
FlowLibs AOAI API Versionflowlibs_AOAIApiVersionString2024-02-15-previewAPI version string
FlowLibs AOAI API Keyflowlibs_AOAIApiKeySecret(none)Azure OpenAI API key (Secret)
Teams Group IDflowlibs_TeamsGroupIdString(none)GUID of the target M365 Group/Team
Teams Channel IDflowlibs_TeamsChannelIdString(none)Channel ID where the summary is posted

Connectors & Connections

ConnectorAPI NameConnection FormatUsage
Office 365 Outlookshared_office365new_sharedoffice365_ac201OnFlaggedEmail trigger
Microsoft Teamsshared_teamsflowlibs_sharedteams_8ba46PostMessageToChannel

Customization Guide

1. Import; set 6 env vars; update Outlook + Teams connection refs; tweak varSystemPrompt; turn on.

**Common Modifications:** save draft to Outlook Drafts via Reply to email V3 with Save Draft=true; adaptive card instead of HTML; walk entire thread via List emails filter on conversationId; promote system prompt to env var; switch to shared mailbox trigger; add @mention via adaptive card; log summaries to Dataverse.

Key Expressions

- @triggerOutputs()?['body/body/content'] — flagged email body
- @body('Call_Azure_OpenAI')?['choices'][0]?['message']?['content'] — AOAI content
- @json(outputs('Parse_AOAI_Completion')) — parse structured reply