1. Home
  2. Guides
  3. AI Builder & AI
  4. How to auto-reply to customer emails in Outlook with AI Builder and Power Automate
AI Builder & AI

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.

  • By Nur Islam
  • 16:55 video
  • 13 steps
  • 5.5K views
Jump to a step (13)
Who this is for

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
  1. 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.

  2. 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 no when the email should not get a reply or there is not enough information

    That no rule is what the flow checks later.

  3. 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 for File 2 to File 5.

    Replace the email placeholders with Text inputs named Email sender, Email subject and Email body. Power Automate fills these inputs when the flow runs.

  4. 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 default GPT 4.1 mini in 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 prompt Customer email support and save it.

  5. 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 trigger When a new email arrives (V3). The flow now runs for every email that lands in your inbox.

  6. 06

    Get the content of each knowledge base file

    Add Get file content from OneDrive for Business. Rename it File 1, click the folder icon, open the Email Support KB folder under root and pick the first file. Add four more Get file content actions for the other files, named File 2 to File 5.

  7. 07

    Send the files and email to the prompt

    Add Run a prompt from AI capabilities and select Customer email support. The inputs may appear in a different order, which is fine because they are named. Map them:

    • Email body: Body from the trigger
    • Email subject: Subject from the trigger
    • File 1 to File 5: File content from the matching Get file content action
    • Email sender: From from the trigger

    The sender is optional, but it gives the AI more context.

  8. 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 \n characters. If you drop that text straight into an HTML email, the breaks disappear and the reply becomes one block.

  9. 09

    Create a line break variable

    Edit the flow and add Initialize variable. Name it Line breaks, set Type to String, click in Value and 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. 10

    Only reply when the output is not no

    Add a Condition. On the left, pick the Text output from Run a prompt. Choose is not equal to and type no on 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. 11

    Reply with a formatted body

    In the True branch, add Reply to email (V3). Set Message Id to the trigger's Message Id. Open Advanced parameters and add Body (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(, pick Text from Run a prompt in the dynamic content (Power Automate inserts the reference for you), add a comma, pick the Line breaks variable, add a comma and '<br>'. This replaces every new line with an HTML break.

  12. 12

    Tag replied emails with a category

    Add Assign an Outlook category. Set Message Id to the trigger's Message Id and type AI replied as 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 message instead of Reply to email (V3). The flow then saves a draft with the AI text, and the category tells you which drafts to review.

  13. 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 replied category. 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 no when it should not reply. The condition compares the text to no, so any extra words will cause a reply to go out.
  • AI output uses \n for new lines, which HTML emails ignore. Replace them with <br> using the Line breaks variable and the replace() expression.
  • The standard GPT 4.1 model wrote better replies than the default GPT 4.1 mini in the video's tests.
  • Use Draft an email message instead of Reply 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.
Still stuck? Ask AI to help you fix itChatGPTClaudeGeminiCopilotPerplexityGrok

Expression used in this flow

WhereExpressionWhat it does
Reply to email (V3) bodyreplace(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>.

Video chapters
Ask a question in the comments Last checked 26 Sep 2026. Screens change: if a step looks different, tell me in the comments.