Tutorials/Copilot Studio/Automate Email Replies with a Copilot Studio Agent
Copilot Studiointermediate

Automate Email Replies with a Copilot Studio Agent

Move beyond static out-of-office replies. Build an intelligent agent that reads emails, checks your data, and sends personalized responses.

NA
Narmer Abader
@narmer · Published June 3, 2026

Imagine a no-code bot that checks your orders, reads your company policies, and writes a perfect support email without human intervention. That’s the power of Copilot Studio agents. In this walkthrough, we’ll build an agent for the fictional company Apex Logistics that handles incoming support emails autonomously.

When a customer emails support@apexlogistics.com, the agent looks up the order status in an Excel file, consults a Word document for return policies, and crafts a polished, personalized reply—all without a human touching the keyboard.

Scenario Overview

Let’s say a customer named Sarah emails your team:

Hi, my order number is ORD-8823. It says delayed but I need it by Friday. Also, what happens if items arrive broken?

Here’s what the Copilot Studio agent will do:

  1. Parse the incoming email.
  2. Use an Excel tool to look up ORD-8823 in the Orders table and find its current status and estimated delivery.
  3. Search its Knowledge Base (a Word document) for the damaged-goods policy.
  4. Format a reply with Sarah’s name, the correct facts, and a professional sign-off.
  5. Send the email back to Sarah.

The entire process runs in seconds, and your team never has to open the inbox.

Prerequisites

  • A Copilot Studio license (standalone or bundled with Microsoft 365).
  • A SharePoint Online site with a document library.
  • A licensed mailbox (personal or shared) that will receive the emails.
  • Basic familiarity with Power Automate (flows are created automatically by Copilot Studio triggers).
Licensing (2025)

Copilot Studio requires either a Copilot Studio standalone license (capacity-based, per-message or per-agent session) or Microsoft 365 Copilot (which includes limited agent-building capabilities). A basic Microsoft 365 or Power Platform license alone is not sufficient for autonomous agent features. Check the Copilot Studio pricing page for current details.

Step 1: Create the Agent and Write the Instructions

Open Copilot Studio and create a new agent. Give it a clear description and strict formatting instructions. The instructions are the brain of the agent—they define its personality and behavior.

Key elements for the instructions:

  • How to greet the customer.
  • What sources to use.
  • What tone to adopt.
  • How to structure the email (paragraphs, lists, sign-off).
textExample Agent Instructions
You are a support agent for Apex Logistics.
Your goal is to reply to customer emails sent to the support inbox.

Response Formatting Rules:
- Begin the email with "Dear [Customer Name]," on its own line. If no name is provided, use "Hello,".
- Keep responses concise. Only provide the information explicitly requested.
- Structure the email into clear paragraphs. Do NOT use Markdown or tables.
- End the email with the following sign-off on its own line:
  Thank you for your patience.
  Best regards,
  Apex Logistics Support (Automated)
- If you must list items, use bullet points (e.g., "- Item one").
- Do not use emojis, em-dashes, or other informal stylings.
- When providing information, briefly indicate the source (e.g., "According to our shipping policy…").

Step 2: Build the Knowledge Base

The agent needs a source of truth for common questions. Instead of letting it use generic web or AI knowledge, you will upload a specific document.

Create a Word document named ApexLogistics_SupportPolicy.docx and upload it to your SharePoint document library. Populate it with a simple Q&A format:

  • Shipping & Delivery
    • Q: Why is my order delayed?
    • A: Orders can be delayed due to carrier limitations or severe weather. Standard delivery is 5–7 business days.
  • Returns & Damages
    • Q: What is your return policy for damaged items?
    • A: Damaged items must be reported within 48 hours of delivery. Refunds are processed within 5 business days.
  • Account Support
    • Q: How do I reset my password?
    • A: Go to apexlogistics.com/account and select “Forgot Password”.

Back in Copilot Studio, go to the Knowledge tab and add the file. Select the SharePoint connector, browse to your library, and pick the document.

Lock Down the Knowledge

In the agent’s SettingsGenerative AI panel, turn off the following options:

  • Allow the agent to use its own knowledge
  • Allow the agent to browse the internet for information

This forces the agent to rely strictly on your uploaded document.

Step 3: Add a Data Lookup Tool

Not all information belongs in a FAQ. Order statuses change constantly, so storing them in an Excel table is a better fit.

Create an Excel file named ShipmentTracker.xlsx and upload it to the same SharePoint library. Add a table (named Orders) with these columns:

OrderIDCustomerNameCurrentLocationCurrentStatusEstDeliveryDate
ORD-8823Sarah ConnorMemphis HubProcessing DelayJune 10, 2026
ORD-9841Kyle ReeseDallas HubIn TransitJune 7, 2026
ORD-1052John KellerLocal FacilityOut for DeliveryJune 6, 2026

In Copilot Studio, go to the Tools tab and add the Excel Online (Business) connector. Choose the action List rows present in a table.

In the configuration panel, you need to provide clear instructions for the Filter Query input. The agent uses this description to build the correct ODATA query.

textFilter Query Description
Construct an ODATA filter query that strictly uses the 'OrderID' column.
Always enclose the input in single quotes.
Example: OrderID eq 'ORD-8823'
If the user provides a messy value like 'ord 8823', correct it to the standard format 'ORD-8823'.

Step 4: Connect the Email Trigger and Create the Flow

You want the agent to start working the moment a new email lands in the inbox.

  1. On the agent’s Overview page, go to the Triggers section and click Add trigger.
  2. Choose When a new email arrives (for a personal mailbox) or When a new email arrives in a shared mailbox.
  3. Fill in the required fields (mailbox address, folder = Inbox).
  4. Click Edit trigger to open the Power Automate flow.

Split on Behavior: Inside the Power Automate trigger card, open the settings menu (...) and enable Split on. Set the value to triggerBody()['value']. This ensures the flow runs once per email and processes them individually.

Batch Processing Pitfall

If you skip the "Split on" setting, a batch of emails will be processed as a single event, causing the flow to fail silently or send garbled responses.

The next step is the Send a prompt to the specified Copilot for process action. The message field must contain a plain-text string version of the email. Use this expression:

powerautomateConvert Trigger Body to String
string(triggerBody())

This converts the entire email object (subject, body, sender, etc.) into a text format the agent can read.

Step 5: Clean Citations from the Email Response

In a chat window, citation links like [1] are helpful. In an email, they look broken and confuse the recipient. We need to remove them from the final output.

Create a new System topic named AI Generated Response. This topic fires every time the agent finishes generating a response.

Inside this topic:

  1. Set the ContinueResponse variable to false. This stops the agent from sending the raw response with citations.
  2. Add a Set variable action to create a new variable called CleanResponse.
  3. Use the following Power Fx formula to strip citation markers.
powerfxCitation Removal Logic
With(
  {
      NoFooter: First(Split(System.Response.FormattedText, "[1]:")).Value
  },
  Substitute(
      Substitute(
          Substitute(
              NoFooter,
              "[3]", ""
          ),
          "[2]", ""
      ),
      "[1]", ""
  )
)

Why this order matters: Removing [1] before [10] would change [10] into [0]. By removing [3], [2], then [1], you avoid that problem. If your knowledge often returns more than three citations, extend the chain to [6].

  1. Add a Send a message node and set the content to the CleanResponse variable.

Step 6: Route the Response to Email

We want the agent to send an email when triggered by an email, and display a chat message when tested in the conversation panel.

Inside the AI Generated Response topic, add a Condition action:

  • Condition: Trigger.Outputs.Type is equal to Email (or select the appropriate system variable).

If Yes (Triggered by Email): Use the Office 365 Outlook connector’s Send an email (V2) action.

  • To: System.User.Mail (this dynamically grabs the original sender’s address).
  • Subject: RE: {Original Subject}
  • Body: CleanResponse variable.
  • Body format: HTML.

If No (Test in Chat): Send a message node with the CleanResponse variable. This makes debugging much easier because you can see the clean output directly in the test pane.

Common Mistakes and Troubleshooting

1. ODATA Filter Query Syntax Errors The agent might write orderid eq 'ORD-8823' when the column is really OrderID. Column names are case-sensitive in ODATA. Double-check the column name in your Excel table and rewrite the instructions in the tool description field.

2. The Agent Is Ignoring the FAQ If the agent answers questions outside your uploaded document, you probably forgot to restrict the knowledge sources. Revisit Settings → Generative AI and disable the two “Allow…” checkboxes. The agent will then rely on your documents.

3. Email Is Sent but Content Is Missing This usually happens when the ContinueResponse variable isn’t set to false. The agent sends the default response (which is often empty or purely structural) instead of your custom CleanResponse. Verify the system topic is active.

4. Data Loss Prevention (DLP) Blocks Enterprise environments often restrict the Office 365 Outlook and Excel Online connectors. If your flow fails without a clear error code, check the DLP policies in the Power Platform admin center.

Security and Delegation Notes

  • Mailbox Permissions: The service account (or the person configuring the trigger) must have Read and Manage permissions on the target mailbox.
  • SharePoint Permissions: The Copilot Studio agent uses the connection of the flow’s owner. Ensure that user has at least Read access to the SharePoint library.
  • DLP Policies: Verify that the Microsoft 365 Outlook (or Outlook.com) and Excel Online (Business) connectors are allowed in the environment’s policies.

Performance Considerations

  • Excel vs. Dataverse: Excel Online can handle thousands of rows, but for millions of rows or heavy transactional load, consider migrating your data to Dataverse or SQL.
  • Knowledge File Size: Keep uploaded documents concise. A bloated 200-page Word file slows down response generation and can cause token limits to be hit.

Final Recommendation

Building an email agent in Copilot Studio shifts the burden of repetitive manual replies to an automated, intelligent system. The setup requires methodical work—clear instructions, locked-down knowledge, and proper citation handling—but the payoff is a dramatic improvement in response time and consistency.

Start with a single use case (order status checks or password resets), test thoroughly in the chat, and only then connect the email trigger. Your support team—and your customers—will thank you.

References