Migrate chat messages to MS Teams
I was looking at a way to migrate the content of a Rocket.chat instance to MS Teams, while preserving at much as possible (attachments, inline images, reactions, replies, etc.), and the original publication date.
Well, Microsoft provide a guide for this! The important thing to know, is that you can't add messages from the past in an existing channel, you need to create a Team and a Channel in migration mode, with the creation time as old, or older, than the first chat that you want to migrate. After the copy of the posts are added to the "migration channel", Teams need to know that migration is complete, and to finish the job, you need to add members to the team AFTER the migration is marked as complete.
If you use the Java SDK for MS Graph (the official API for almost everything MS 365), you can create the team like this:
Team teamToMigrate = new Team();
teamToMigrate.createdDateTime = OffsetDateTime.now().withDayOfMonth(1).withMonth(6).withYear(2017);
teamToMigrate.displayName = "My new team";
teamToMigrate
.additionalDataManager().put("@microsoft.graph.teamCreationMode", new JsonPrimitive("migration"));
If you migrate the posts to the General channel, you don't need to create the channel since the team's creation takes care of creating a General channel by default.
Once the publications are migrated, you need to mark the migration as completed, like this:
graphClient.teams(teamUuid).channels(channelUuid).completeMigration().buildRequest().post();
graphClient.teams(teamUuid).completeMigration().buildRequest().post();
Also, be aware that replies and reactions must be added AFTER the publications are created, you can't create them together.
Last thing: inline images must be send as base64, and it have a 4 MB limit. If you are migration inline images, you might want to add images over 4 MB as attachments instead of inline.
Pascal Robert : Thanks for sharing the details , Do you have any articles on this ?