Copilot chat custom engine agents no attachments

Karlis R 15 Reputation points
2025-05-22T04:55:23.9+00:00

Hi,

Built custom copilot agent using teams-ai python sdk, published agent, when using it in copilot chat in Teams and user sends file, the request I get in backend has no information about the uploaded file, only the file name in text, type is message.

Could you advise how to get the files user sent to agent? Or how the files should be attached to get them?

Microsoft Teams | Development
{count} vote

2 answers

Sort by: Most helpful
  1. Karan Shewale 170 Reputation points Microsoft External Staff
    2025-05-23T04:15:46.7033333+00:00

    Hi Karlis R,

    Thanks for getting in touch with your question about handling file uploads in a custom Copilot agent using the Teams-AI Python SDK.

    You noted that when users upload files through Microsoft Teams, your backend only receives the file name as plain text, without any associated metadata or file content.

    Steps.

    How Teams Handles File Uploads Teams doesn't send the actual file to the bot directly. Instead, it typically sends metadata or a file consent card. Your bot must recognize the attachment and retrieve the file using the included downloadUrl.

    Python SDK Constraints Currently, the Python SDK doesn't fully support all Teams features, including comprehensive file handling in custom Copilot agents. This limitation could be why your bot isn’t receiving complete file data.

    Steps to Properly Handle File Uploads:

    1. Confirm that your bot is set up to accept file attachments.

    Inspect incoming activities for an attachments array.

    Identify file-type messages by checking for content types like application/vnd.microsoft.teams.file.download.info.

    Use the content.downloadUrl to retrieve the file (note: authentication may be required).


    Useful Resources

    Sending and receiving files with bots in Teams

    File upload and download scenarios with bots

    If you're looking for full file handling support with Copilot, I’d recommend using the Node.js SDK, which currently offers more complete integration.

    Thanks,  

    Karan Shewale. 

    *************************************************************************  

    If the response is helpful, please click "Accept Answer" and upvote it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate. 

    0 comments No comments

  2. Karan Shewale MSFT 0 Reputation points
    2025-05-30T10:23:09.78+00:00

    Hi Karlis R,

    When using the Teams AI Python SDK, file uploads from users in Teams are sent as attachments, not as plain text. If your backend only receives the file name, it likely means the bot isn’t handling attachments correctly.

    To access uploaded files:

    Check for attachments in the incoming activity:

    if turn_context.activity.attachments:

    for attachment in turn_context.activity.attachments:
    
        content_url = attachment.content_url
    
        file_name = attachment.name
    
        # Use bot token to download the file
    

    Use the content_url with a valid bot token to download the file contents.

    Ensure your bot has permission to access files and is hosted in a Teams-compatible context.

    For reference, see Microsoft’s Python file upload bot sample.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.