1. Home
  2. Guides
  3. AI Builder & AI
  4. How to auto-reply to Outlook emails with a trained OpenAI assistant and Power Automate
AI Builder & AI

How to auto-reply to Outlook emails with a trained OpenAI assistant and Power Automate

Build a Power Automate flow that sends each new Outlook email to an OpenAI Assistant trained on your own documents, then replies to the sender with the answer. Questions your documents do not cover get a polite hand-off message instead.

  • By Nur Islam
  • 19:01 video
  • 15 steps
  • 5.4K views
Jump to a step (15)
Who this is for

Support inboxes fill up with the same questions, and the answers already sit in a troubleshooting guide or company document. Someone still has to read each email, find the right section and type a reply by hand. That slows response times and ties up staff on repeat questions.

This build connects three pieces. An OpenAI Assistant holds your instructions and your documents. A Power Automate flow starts when a new email arrives in Outlook, sends the subject and body to the Assistant through the API, waits for the answer, and replies to the same email.

The Assistant only answers from the files you upload. When an email asks something outside those files, such as "Who is the president of the US?", it replies that it cannot help and that an agent will get back to the sender.

What you need

  • A Microsoft 365 mailbox in Outlook
  • Power Automate with a license that includes the premium HTTP action (Power Automate Premium or a trial)
  • An OpenAI platform account with prepaid API credit
  • The documents you want the bot to answer from, such as a troubleshooting guide and company information

Step by step

0 of 15 done
  1. 01

    Create an OpenAI platform account and add credit

    Go to platform.openai.com and sign in or create an account. Add a payment method and buy some credit. OpenAI charges by usage, so set a usage limit on the account in case something goes wrong in the flow and it keeps calling the API.

  2. 02

    Create the Assistant

    Open the Dashboard menu and select Assistants, then create a new assistant. In the video I name it Automated customer support replies.

    Under the name you see the assistant's unique ID (it starts with asst_). Copy it. The flow needs it later.

  3. 03

    Add the instructions and pick a model

    Paste your instructions into the Instructions box. The instructions in the video tell the Assistant to:

    • Expect an email subject and an email body in every message
    • Reply only with information from the uploaded documents
    • Write professional, precise replies and begin by greeting the sender
    • Reply that it cannot help and an agent will get back to them when the answer is not in the documents
    • Use <br> tags where a new line starts, so the email reply keeps its line breaks

    For the model I select gpt-4o.

  4. 04

    Turn on File search and upload your documents

    Switch on File search, then use Files and Click to upload to add your documents. In the video I upload two files: company information and a list of technical issues and solutions. These files are the only knowledge the bot will use.

  5. 05

    Test the Assistant in the Playground

    Select Playground and send a test prompt that looks like a real email, with an Email subject: and an Email body:. Select Run. The answer should match your document and include <br> tags for line breaks.

    Then send an unrelated question, such as who the president of the US is. The Assistant should reply that it cannot help with that. If it answers anyway, tighten the instructions.

  6. 06

    Create the automated cloud flow

    In Power Automate, select Create and then Automated cloud flow. Name it something like Outlook email replies with OpenAI Assistant. Search for email and pick the Office 365 Outlook trigger When a new email arrives (V3), then select Create.

    If you already have an older version of this flow running, turn it off first so two flows do not reply to the same email.

  7. 07

    Store the API key and Assistant ID in variables

    Add an Initialize variable action named OpenAI API, type String. For the value, go back to the OpenAI dashboard, open API keys, select Create new secret key, and copy the key. You cannot view the key again after you close the dialog, so save it somewhere safe.

    Add a second Initialize variable action named Assistant ID, type String, and paste the assistant ID you copied earlier. Renaming each action to match its variable makes the flow easier to read.

  8. 08

    Create a thread and send the email with an HTTP action

    The Assistants API normally takes five calls: create an assistant, create a thread, add a message, create a run and read the output. The assistant already exists, and you can create the thread and add the message in one call, so the flow only needs three HTTP requests.

    Add an HTTP action and set:

    • URI: https://api.openai.com/v1/threads
    • Method: POST
    • Headers: Content-Type = application/json, Authorization = Bearer followed by the OpenAI API variable, OpenAI-Beta = assistants=v2
    • Body: a JSON object with one user message, for example {"messages":[{"role":"user","content":"Email subject: [Subject], Email body: [Body]"}]}

    Replace [Subject] and [Body] with the Subject and Body dynamic content from When a new email arrives (V3).

  9. 09

    Test once and parse the thread ID

    Save the flow, select Test, choose Manually, and send any email to the mailbox to trigger it. Open the HTTP action's output and copy the whole Body. It contains the new thread id.

    Back in edit mode, add a Parse JSON action. Set Content to the Body of the HTTP action, select Use sample payload to generate schema, paste the copied body and select Done. Rename the action to Thread ID so you can find it later.

  10. 10

    Start a run with a second HTTP action

    Add another HTTP action and rename it Run. Set:

    • URI: https://api.openai.com/v1/threads/ followed by the id from the Thread ID Parse JSON action, then /runs
    • Method: POST
    • The same three headers as before
    • Body: {"assistant_id":"[Assistant ID]","instructions":"[your instructions]"}

    Use the Assistant ID variable for [Assistant ID]. In the video I paste the same instructions from the Assistant into this body so the run follows them.

    Save and test with Automatically and a recently used trigger. Copy the run's output body and add a second Parse JSON action (rename it Run ID) using that sample, with Content set to the Body of Run.

  11. 11

    Add a delay while the Assistant writes the answer

    Add a Delay action set to 1 Minute. In my tests the Assistant needs around 30 to 40 seconds to generate a reply, so one minute gives it room. If you read the messages too early, the reply will not be there yet.

  12. 12

    Retrieve the reply with a third HTTP action

    Add a final HTTP action and rename it Output. Set:

    • URI: https://api.openai.com/v1/threads/ followed by the thread id, then /messages
    • Method: GET, because you are reading data, not sending it
    • The same three headers
    • No body

    Save and test with the last successful trigger. In the output body, the Assistant's answer sits inside data, then content, then text, then value.

  13. 13

    Reply to the email with the Assistant's answer

    Add the Office 365 Outlook action Reply to email (V3). For Message Id, pick Message Id from When a new email arrives (V3) (select See more if you do not see it).

    Under Advanced parameters, add Body and enter this expression:

    body('Output')?['data'][0]?['content'][0]?['text']?['value']

    It takes the first message in the data array (the newest one, which is the Assistant's reply), then the first text item in its content, then its value. Save the flow.

  14. 14

    Test with a real question

    Select Test, choose Manually, and send an email about an issue covered in your documents. The run waits on the Delay action for a minute, reads the output and sends the reply. In the video the bot replies with the exact fix steps from the troubleshooting guide.

  15. 15

    Fine-tune the replies

    Sometimes the bot mentions the name of the source document in the reply. To stop that, edit the first HTTP action and add an instruction to the message content, next to the email subject and body. In the video I add: if the information is not available in the document, reply that you cannot help and an agent will get back to you soon, and do not mention the document reference.

    Save the flow and send another test email. Keep adjusting the instructions until the replies read the way you want.

Tips and common problems

  • The API secret key is shown only once. Copy it into the variable right away, and create a new key if you lose it.
  • When you test the Run action, check that you replaced the sample assistant ID in the request body with your Assistant ID variable. In the video the first test fails with an error because the demo ID was still there.
  • If the reply comes out as one long block of text, add an instruction telling the Assistant to use <br> tags for new lines. Outlook renders them as line breaks.
  • If the bot mentions the source file name, add "do not mention the document reference" to the message you send in the first HTTP request.
  • Set a monthly usage limit in your OpenAI account so a looping or misfiring flow cannot run up a large bill.
  • OpenAI has announced that the Assistants API is being retired in favor of its newer Responses API. Check the current OpenAI API documentation before you build, because the endpoints shown in this video may stop working.
Still stuck? Ask AI to help you fix itChatGPTClaudeGeminiCopilotPerplexityGrok

The three API requests in this flow

ActionMethodURIWhat it does
HTTP (create thread)POSThttps://api.openai.com/v1/threadsCreates a thread and adds the email subject and body as a user message
RunPOSThttps://api.openai.com/v1/threads/{thread_id}/runsTells your Assistant to process the thread with your instructions
OutputGEThttps://api.openai.com/v1/threads/{thread_id}/messagesReads the messages, including the Assistant's reply

All three use the headers Content-Type: application/json, Authorization: Bearer [your API key] and OpenAI-Beta: assistants=v2.

Expression used in the reply

body('Output')?['data'][0]?['content'][0]?['text']?['value'] returns the text of the newest message in the thread, which is the Assistant's answer.

Questions

Can Power Automate reply to Outlook emails automatically with ChatGPT?

Yes. A flow triggered by When a new email arrives (V3) can send the email to the OpenAI API with HTTP actions, wait for the answer, and use Reply to email (V3) to send it back to the sender.

Do I need a premium Power Automate license for this flow?

Yes. The HTTP action is a premium connector in Power Automate, so you need Power Automate Premium or a trial. The Outlook trigger and reply action are standard. You also pay OpenAI separately for API usage.

Will the bot answer questions that are not in my documents?

Not if the instructions say so. In the video the Assistant is told to reply only from the uploaded files, so a question like "Who is the president of the US?" gets a reply saying it cannot help and an agent will get back to the sender.

Why does the flow wait one minute before reading the reply?

The Assistant needs time to process the run. In the video it takes around 30 to 40 seconds, so a one-minute Delay makes sure the answer is ready before the flow requests the thread's messages.

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.