- Home
- Guides
- AI Builder & AI
- How to auto-reply to customer emails in Outlook with AI Builder and Power Automate
How to auto-reply to customer emails in Outlook with AI Builder and Power Automate
Build a Power Automate flow that reads each new Outlook email, checks it against your own knowledge base PDFs with an AI Builder prompt, and replies only when it is a real customer question it can answer. Replied emails get an `AI replied` category so you can review them.
Jump to a step (13)
Small support teams spend hours a day answering the same questions about products, pricing, returns and warranties. A basic auto reply is no help because it answers everything, including internal emails and newsletters.
The build has two parts. First you create a custom prompt in AI Builder that knows which emails to answer, reads five knowledge base files, and writes a reply in your tone with your signature. If the email is not a customer query, or the files do not hold the answer, it returns exactly no.
Then a Power Automate flow runs on every new email. It pulls the PDF files from OneDrive, sends them and the email to the prompt, and replies only when the output is not no. A small expression turns the AI's line breaks into proper HTML breaks so the reply looks clean.
What you need
- Microsoft 365 Business Basic or Standard with Outlook and Power Automate
- AI Builder credits for the Run a prompt action (a premium AI Builder capability)
- A OneDrive for Business folder with your knowledge base files (the video uses five PDFs)
- A written set of instructions for what to answer and what to ignore
Step by step
0 of 13 done-
01
Put your knowledge base files in OneDrive
Create a folder in OneDrive for Business (the video uses
Email Support KB) and add the files the AI should answer from. The demo has five PDFs: business policies, customer support reference, product catalog, service offerings and a technical support manual.The customer support reference file holds guidelines and standard response templates, which helps the AI match your house style. You can use as many files as you need, but the prompt needs one input per file.
-
02
Create a custom prompt in AI Builder
In Power Automate, go to AI hub and select Prompts, then Build your own prompt. Paste your instructions. The video's instructions cover:
- Only respond to emails about product specifications, pricing, tech support, returns, warranty and similar customer topics
- Do not reply to internal company emails, personal conversations or marketing emails
- Search the knowledge base files, and only answer if they fully answer the question
- Tone, language, content and format guidelines, plus a response structure: greet professionally, acknowledge the question, give a direct answer with details
- A signature to add to every reply
- Output exactly
nowhen the email should not get a reply or there is not enough information
That
norule is what the flow checks later. -
03
Add the file and email inputs
Where the instructions mention the knowledge base, click Add content, select Image or document and name the input
File 1. Repeat forFile 2toFile 5.Replace the email placeholders with Text inputs named
Email sender,Email subjectandEmail body. Power Automate fills these inputs when the flow runs. -
04
Test the prompt with sample emails
For testing, upload your five files into the file inputs and paste a sample email subject and body. Change the model to the standard
GPT 4.1, which gave better answers than the defaultGPT 4.1 miniin the video. Click Test.Try a support question, a product enquiry and an internal message such as a meeting reminder. The first two should get full replies built from your files, and the meeting reminder should return
no. Name the promptCustomer email supportand save it. -
05
Create the flow with the new email trigger
Go to Create, select Automated cloud flow, name it
Customer email support, and pick the Office 365 Outlook triggerWhen a new email arrives (V3). The flow now runs for every email that lands in your inbox. -
06
Get the content of each knowledge base file
Add
Get file contentfrom OneDrive for Business. Rename itFile 1, click the folder icon, open theEmail Support KBfolder under root and pick the first file. Add four moreGet file contentactions for the other files, namedFile 2toFile 5. -
07
Send the files and email to the prompt
Add
Run a promptfrom AI capabilities and selectCustomer email support. The inputs may appear in a different order, which is fine because they are named. Map them:Email body:Bodyfrom the triggerEmail subject:Subjectfrom the triggerFile 1toFile 5:File contentfrom the matchingGet file contentactionEmail sender:Fromfrom the trigger
The sender is optional, but it gives the AI more context.
-
08
Test the flow and look at the raw output
Save, click Test, choose Manually, and send a test email to the mailbox. When the run finishes, open
Run a prompt, select Show raw outputs and find the text in the body. The reply is good, but the line breaks show as\ncharacters. If you drop that text straight into an HTML email, the breaks disappear and the reply becomes one block. -
09
Create a line break variable
Edit the flow and add
Initialize variable. Name itLine breaks, setTypetoString, click inValueand press Enter once. The value is simply a new line. You will swap each new line for an HTML<br>tag in the reply body. -
10
Only reply when the output is not no
Add a
Condition. On the left, pick theTextoutput fromRun a prompt. Chooseis not equal toand typenoon the right. Everything that should get a reply goes into the True branch. Internal emails and questions the files cannot answer go to False, where nothing happens. -
11
Reply with a formatted body
In the True branch, add
Reply to email (V3). SetMessage Idto the trigger'sMessage Id. Open Advanced parameters and addBody(you can also add CC or BCC here).For
Body, open the expression editor and build:replace(outputs('Run_a_prompt')?['body/responsev2/predictionOutput/text'], variables('Line breaks'), '<br>')Type
replace(, pickTextfromRun a promptin the dynamic content (Power Automate inserts the reference for you), add a comma, pick theLine breaksvariable, add a comma and'<br>'. This replaces every new line with an HTML break. -
12
Tag replied emails with a category
Add
Assign an Outlook category. SetMessage Idto the trigger'sMessage Idand typeAI repliedas the category. You can now see in Outlook which emails the flow answered.If you would rather check each answer first, use
Draft an email messageinstead ofReply to email (V3). The flow then saves a draft with the AI text, and the category tells you which drafts to review. -
13
Test with real scenarios
Save and test again. Send a support question and check that a reply with step by step instructions and your signature goes out, and that the original email shows the
AI repliedcategory. Then send a customer enquiry and an internal email one after the other. The flow should answer the enquiry from the product catalog and ignore the internal email.
Tips and common problems
- The prompt must return exactly
nowhen it should not reply. The condition compares the text tono, so any extra words will cause a reply to go out. - AI output uses
\nfor new lines, which HTML emails ignore. Replace them with<br>using theLine breaksvariable and thereplace()expression. - The standard
GPT 4.1model wrote better replies than the defaultGPT 4.1 miniin the video's tests. - Use
Draft an email messageinstead ofReply to email (V3)if you want to review every AI answer before it is sent. - The trigger runs on every new email, so every email calls the prompt and uses AI Builder credits, even the ones that end in
no.
Expression used in this flow
| Where | Expression | What it does |
|---|---|---|
Reply to email (V3) body | replace(outputs('Run_a_prompt')?['body/responsev2/predictionOutput/text'], variables('Line breaks'), '<br>') | Turns each new line in the AI reply into an HTML line break. |
Questions
Can Outlook automatically reply to customer emails with AI?
Yes, with Power Automate and AI Builder. A When a new email arrives (V3) trigger sends each email to a custom AI Builder prompt, and Reply to email (V3) sends the answer when the prompt decides it should reply.
How do I stop the AI replying to internal or marketing emails?
Tell the prompt which topics to answer and which to ignore, and make it output exactly no otherwise. Then add a condition in the flow so it only replies when the output is not equal to no.
Does AI Builder need a premium licence?
The Run a prompt action is an AI Builder feature and uses AI Builder credits, which are not part of the standard connectors. Check that your tenant has AI Builder capacity before you build this.
Why does my AI reply lose its line breaks?
Power Automate passes new lines as \n, and HTML emails do not render them. Wrap the prompt output in replace() to swap each new line for <br>.
