How to handle Microsoft Teams chat message attachments and upload them to SharePoint via AI agent in n8n?

Hi! I’m using n8n to process incoming chat messages from Microsoft Teams.

When a user sends a message with one or more attachments, I want to catch those attachments in my AI Agent and upload them to a SharePoint folder (where I store things like customer invoices).

But I have absolutely no clue how this should look like. Right now the AI agent is only capable to see if an attachment has been added, but it’s not able to upload it in the sharepoint tool.

There are two main problems here:

  • Every attachments gets its own object: ‘attachments[0]’ ‘attachments[1]’ etc.
  • How to get the message attachment download and paste it to the ai agent so it can upload it to sharepoint

Any tips or example flows would be great!

*See screenshots (sorry I erased any sensitive data). The attachment input generated by the ‘Get Chat Message1’ output.


Thanks :folded_hands:

Hi, as far as i know the ai agent node cant process binary files.
I would try to convert the files to base64 string and convert it back to files before uploading.

Hi! Were you able to solve this problem? I’m in the same situation…

1 Like

I was able to solve this problem as follows:
I convert the contentURL to base64 and then use the Graph endpoint “https://graph.microsoft.com/v1.0/shares/u!{{ $json.encoded }}/driveItem/content” to download the file.
For authentication, I use the generic Microsoft Teams credential, since I had issues with the Refresh Token when using the Graph credential.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.