Building and customizing solutions using Microsoft 365 Copilot APIs and tools
Use the file from System.Activity.Attachments and pass both the file name and file content explicitly to the Outlook action. The corruption happens when only the file name is passed and contentBytes is empty or mapped incorrectly.
Recommended setup:
- In the topic, first capture the uploaded file.
- Use a Set variable value node with:
First(System.Activity.Attachments) - This returns the attached file as a record.
- Use a Set variable value node with:
- Extract the two fields needed for email attachment handling:
- File name:
.Name - File content:
.Content
- File name:
- If the user might start the conversation with or without a file, combine both patterns:
- Check
First(System.Activity.Attachments)first. - If no file is present, route to a Question node with Identify = File.
- In the Question properties panel, enable Include file metadata.
- Check
- For Send an email (V2), the attachment input must be wrapped as a record with
contentBytesandnamekeys.- Use this shape:
{ contentBytes: Topic.userReceipt.Content, name: Topic.userReceipt.Name } - If filling from
System.Activity.Attachmentsdirectly for a tool, use:If( IsEmpty(System.Activity.Attachments), [], [{ contentBytes: First(System.Activity.Attachments).Content, name: First(System.Activity.Attachments).Name }]) )
- Use this shape:
- On the Tools page, file inputs must be set with Custom value and a Power Fx formula.
- Do not use Dynamically fill with AI for file inputs.
- If the file still appears empty, verify channel and environment support:
- File input is supported on Microsoft Teams, custom website/demo website, Facebook, Omnichannel for Customer Service, Microsoft 365 Copilot, and the Test your agent panel.
- File input is not supported on voice, telephony, or SharePoint channels.
- In a customer managed key enabled environment, files can be added as input, but the agent does not process them.
- Check file limits and behavior:
- Maximum attachment size is 16 MiB per file.
- Failed attachments are skipped and the message still continues.
For the scenario described, the most likely fix is:
- store
First(System.Activity.Attachments)in a variable, - map
.ContenttocontentBytes, - map
.Nametoname, - and pass the attachment object to Send an email (V2) using Custom value.
If only the name is available in the current topic path, the file was not captured through the file input path correctly, or the attachment input was mapped in the wrong format.
References: