Hello @Nguyen Nhu Phuc,You only get a ConversationFileReference
(an opaque file reference/token) in Activity.Attachments
. You do NOT get the file content or a direct download URL. There is no built-in way to forward the actual file content to your backend via HTTP from a declarative agent.
Declarative agents and Copilot Studio are currently not suitable for this use case.
If you need to process file content, Build a custom Teams bot using the Bot Framework SDK (C# or Python). This bot can receive file uploads, download the file using the contentUrl
, and send it to your backend.
Reference Document-https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/bots-filesv4?tabs=csharp1%2Ccsharp
import aiohttp
async def download_teams_file(content_url, token):
headers = {"Authorization": f"Bearer {token}"}
async with aiohttp.ClientSession() as session:
async with session.get(content_url, headers=headers) as resp:
if resp.status == 200:
return await resp.read()
else:
raise Exception(f"Failed to download file: {resp.status}")