[Python] Having trouble sending excel file to personal teams chat with botbuilder

Discussão em 'Python' iniciado por Stack, Julho 31, 2025.

  1. Stack

    Stack Membro Participativo

    So i have a bot / backend that creates and is able to serve basic excel files through some simple routing. However for some reason I am unable to use the teams api to send this file without running into an error. The following is my current implementation of the attachment response.

    if "EXCEL" in final_answer:
    match = re.search(r'\b[\w\-]+\.(xlsx)\b', final_answer)

    if match:
    filename = match.group()
    print(f"This is the filename -> {filename}")
    attachment = Attachment(
    name = filename,
    content_type="application/vnd.microsoft.teams.file.download.info",
    content = {
    "downloadUrl": f"myworkingdomain/files/{filename}",
    "uniqueId": filename,
    "fileType": "xlsx"
    }
    )
    activity = Activity(
    type=ActivityTypes.message,
    attachments=[attachment],
    text="Here is your excel file"
    )
    await turn_context.send_activity(activity)
    else:
    print("nothing found smh")


    I'm not sure if the issue is im using the attachment methods wrong or if its the wrong methods.

    Any help is appreciated!!

    Continue reading...

Compartilhe esta Página