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.
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
| Variable | Schema Name | Type | Default | Purpose |
|---|---|---|---|---|
| FlowLibs AOAI Endpoint | flowlibs_AOAIEndpoint | String | (none) | Azure OpenAI resource endpoint |
| FlowLibs AOAI Deployment Name | flowlibs_AOAIDeployment | String | (none) | Chat-completion deployment name |
| FlowLibs AOAI API Version | flowlibs_AOAIApiVersion | String | 2024-02-15-preview | API version string |
| FlowLibs AOAI API Key | flowlibs_AOAIApiKey | Secret | (none) | Azure OpenAI API key (Secret) |
| Teams Group ID | flowlibs_TeamsGroupId | String | (none) | GUID of the target M365 Group/Team |
| Teams Channel ID | flowlibs_TeamsChannelId | String | (none) | Channel ID where the summary is posted |
Connectors & Connections
| Connector | API Name | Connection Format | Usage |
|---|---|---|---|
| Office 365 Outlook | shared_office365 | new_sharedoffice365_ac201 | OnFlaggedEmail trigger |
| Microsoft Teams | shared_teams | flowlibs_sharedteams_8ba46 | PostMessageToChannel |
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