Let's Do DevOps

Let's Do DevOps

🔥Building a Teams Bot with AI Capabilities - Part 6 - Reading Teams Attachments🔥

aka, file location and permissions aren't reliable, and are critically important. Great.

Kyler Middleton's avatar
Kyler Middleton
Aug 04, 2025
∙ Paid
1
Share

This blog series focuses on presenting complex DevOps projects as simple and approachable via plain language and lots of pictures. You can do it!

These articles are supported by readers, please consider subscribing to support me writing more of these articles <3 :)

This article is part of a series of articles, because 1 article would be absolutely massive.

  • Part 1: Create an Azure Bot and App Registration

  • Part 2: Register Bot in Teams with Teams Developer Portal

  • Part 3: Delegated Permissions and Making Lambda Stateful for Oauth2

  • Part 4: Building the Receiver lambda to store tokens and state

  • Part 5: Finding messages, reading conversations in Teams

  • Part 6 (this article): Finding attachments and reading them into Bedrock

Hey all!

In the last article we talked about how to find the root of messages to build our conversational context in Teams. That is an incredibly challenging task, as the Teams client is several raccoons in a trench coat (well, service APIs behind a front-end, same difference). Those services are generally:

  • Azure Entra/AD API - Authentication and Authorization (is Teams license assigned)

  • OneDrive API - personal files. Files are shared to the person they are sent to automatically in Teams.

There is some weird behavior because of this. When building a multi-person chat, and sharing files, files are shared to each person in the chat at the time of sharing the file. If a person is added later, they can see previous messages (Teams API) but not previous files (OneDrive API), as files are not batch retroactively shared. #WeirdTeams

  • SharePoint API - Team/Channel files. When files are uploaded to a Channel, they are shared with that Team automatically.

Teams stores files wherever it feels like, thank you. Image credit.

To solve this, we have a robust couple functions that find, download, and encode properly the attachments that need to be added to the conversation context.

Lets walk through it.

Keep reading with a 7-day free trial

Subscribe to Let's Do DevOps to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Kyler Middleton
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture