Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to migrate file attachments in third party message apps to Teams? #11926

Open
virajkanwade opened this issue Dec 11, 2024 · 2 comments
Open
Assignees

Comments

@Nivedipa-MSFT
Copy link

Nivedipa-MSFT commented Dec 12, 2024

@virajkanwade - Thank you for your inquiry about your Teams app development issue!
To migrate file attachments from third-party message apps to Teams, you'll need to use Microsoft Graph APIs and perform several key steps:

1. Analyze and Prepare Message Data
Review the third-party data: Decide which data and file attachments you want to migrate.
Extract data: Extract the selected data and file attachments from the third-party chat system.
Map chat structure: Map the chat structure of the third-party system to the Teams structure.
Convert data format: Ensure the data is in the format needed for migration to Teams.

2. Set Up Your Microsoft 365 Tenant
Ensure a Microsoft 365 tenant exists: Make sure your tenant is set up for the import data.
Add team members: Ensure that team members are in Microsoft Entra ID.

3. Use Graph APIs to Post Messages with File Attachments
Obtain access tokens: Use the standard OAuth 2.0 authorization flow to obtain access tokens.
Access OneDrive/SharePoint: Access the files in OneDrive or SharePoint, depending on the type of files (personal, group chat, or channel files).

4. Send Files to Teams
Using the Graph API, you can post messages with file attachments. Here is an example on how to send a file attachment to a Teams chat:

POST https://graph.microsoft.com/v1.0/me/chats/{chat-id}/messages
Content-Type: application/json

{
  "body": {
    "content": "Here is the file you requested"
  },
  "attachments": [
    {
      "id": "1",
      "contentType": "reference",
      "contentUrl": "https://contoso.sharepoint.com/sites/Example/SharedDocuments/Example.xlsx",
      "name": "Example.xlsx"
    }
  ]
}

Doc References:

  1. https://learn.microsoft.com/en-us/microsoftteams/platform/graph-api/import-messages/import-external-messages-to-teams#prerequisites

  2. https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/bots-filesv4#use-the-graph-apis

Please let us know if you have any further query here.

@virajkanwade
Copy link
Author

virajkanwade commented Dec 17, 2024

@Nivedipa-MSFT You again assumed, my files are in sharepoint. My question was more about, how do I transfer the files from the other chat to the MS environment in the first place!
Anyways, just yesterday, I managed to figure it out.

  • Create team in migration mode
  • Create channel in migration mode
  • Get filesFolder location with the API (For some reason, out of the 1230 channels, 57 don't have filesFolder. It says the folder is not yet ready. The channels were all created together 3 days ago.)
  • Download the file from the third party and upload it to the filesFolder.
  • Then link the file in the message as per the docs.

@Prasad-MSFT Prasad-MSFT added needs-author-feedback Needs more info from the customer. and removed needs-triage 🔍 needs-author-feedback Needs more info from the customer. labels Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants