Home

Teams API: Read Messages and Threads + Sample App

%3CLINGO-SUB%20id%3D%22lingo-sub-225541%22%20slang%3D%22en-US%22%3ETeams%20API%3A%20Read%20Messages%20and%20Threads%20%2B%20Sample%20App%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-225541%22%20slang%3D%22en-US%22%3E%3CP%3EDisclosure%3A%20I%20work%20for%20Microsoft%2C%20but%20not%20in%20the%20Teams%20group.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20APIs%20to%20read%20messages%20and%20threads%20(message%20replies)%20from%20a%20Microsoft%20Teams%20channel%20are%20now%20available%20in%20preview!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAccordingly%26nbsp%3B-%20I've%26nbsp%3Bupdated%20my%20multi-platform%2C%20.NET%20Core-based%20Teams%20sample%20application%2C%20QuickTeams%2C%26nbsp%3Bto%20demonstrate%20how%20you%20can%20use%20these%20APIs.%20You%20can%20use%26nbsp%3BQuickTeams%20to%20download%20all%20of%20the%20messages%26nbsp%3Bin%20a%20specific%20channel%2C%20or%20across%20all%20channels%20in%20a%20single%20Team.%26nbsp%3B%20Feel%20free%20to%20use%20QuickTeams%20as-is%20or%20as%20a%20starter%20kit%20for%20your%20own%20needs.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Ftamhinsf%2FQuickTeams%22%20target%3D%22_blank%22%20rel%3D%22noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Ftamhinsf%2FQuickTeams%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHere's%20a%20quick%20summary%20on%20how%20QuickTeams%20works%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EYou%20can%20download%20all%20messages%20on%20a%20per%20channel%20or%20Team-wide%20basis%3C%2FSPAN%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EWe'll%20create%20a%20folder%20called%20quickteams%2C%20which%20contains%20subfolders%20that%20correspond%20to%20the%20channel(s)%20downloaded.%3CUL%3E%0A%3CLI%3EEach%20message%20will%20be%20contained%20in%20an%20individual%20JSON%20file%2C%20whose%20name%20corresponds%20to%20the%20internally%20generated%20message%20ID%3C%2FLI%3E%0A%3CLI%3EEach%20reply%20will%20also%20be%20contained%20in%20an%20individual%20JSON%20file%2C%20whose%20name%20corresponds%20to%20the%20ID%20of%20the%20parent%20message%20and%20the%20ID%20of%20the%20reply%3C%2FLI%3E%0A%3CLI%3EA%20file%20called%20channelSettings%20will%20contain%20metadata%20about%20the%20channel%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3ETeam-wide%20downloads%20will%20include%20metadata%20about%20Team%20and%20underlying%20O365%20group%20in%20the%20quickteams%20folder%3CUL%3E%0A%3CLI%3EteamSettings%20-%20metadata%20about%20the%20team%3C%2FLI%3E%0A%3CLI%3EgroupSettings%20-%20metadata%20about%20the%20underlying%20O365%20group%3C%2FLI%3E%0A%3CLI%3EgroupMembers%20-%20group%20member%20list%3C%2FLI%3E%0A%3CLI%3EgroupOwners%20-%20group%20owner%20list%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHere%20are%20the%20underlying%20APIs%20that%20it%20uses%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERead%26nbsp%3Bmessages%20in%20a%20given%20channel.%20This%20will%20return%20a%20paginated%20list%20of%20messages%2C%20each%20with%20a%20unique%20ID.%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdeveloper.microsoft.com%2Fen-us%2Fgraph%2Fdocs%2Fapi-reference%2Fbeta%2Fapi%2Fchannel_list_messages%22%20target%3D%22_blank%22%20rel%3D%22noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdeveloper.microsoft.com%2Fen-us%2Fgraph%2Fdocs%2Fapi-reference%2Fbeta%2Fapi%2Fchannel_list_messages%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EGiven%20a%20unique%20message%20ID%2C%26nbsp%3Bget%20the%20replies%20to%20the%20message.%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdeveloper.microsoft.com%2Fen-us%2Fgraph%2Fdocs%2Fapi-reference%2Fbeta%2Fapi%2Fchannel_list_messagereplies%22%20target%3D%22_blank%22%20rel%3D%22noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdeveloper.microsoft.com%2Fen-us%2Fgraph%2Fdocs%2Fapi-reference%2Fbeta%2Fapi%2Fchannel_list_messagereplies%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EEnjoy!%26nbsp%3B%20Look%20forward%20to%20your%20collective%20feedback.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-225541%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAPI%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EREST%20API%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ETeams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Highlighted
Tam Huynh
Microsoft

Disclosure: I work for Microsoft, but not in the Teams group.

 

The APIs to read messages and threads (message replies) from a Microsoft Teams channel are now available in preview!

 

Accordingly - I've updated my multi-platform, .NET Core-based Teams sample application, QuickTeams, to demonstrate how you can use these APIs. You can use QuickTeams to download all of the messages in a specific channel, or across all channels in a single Team.  Feel free to use QuickTeams as-is or as a starter kit for your own needs.

 

https://github.com/tamhinsf/QuickTeams

 

Here's a quick summary on how QuickTeams works:

 

You can download all messages on a per channel or Team-wide basis

  • We'll create a folder called quickteams, which contains subfolders that correspond to the channel(s) downloaded.
    • Each message will be contained in an individual JSON file, whose name corresponds to the internally generated message ID
    • Each reply will also be contained in an individual JSON file, whose name corresponds to the ID of the parent message and the ID of the reply
    • A file called channelSettings will contain metadata about the channel
  • Team-wide downloads will include metadata about Team and underlying O365 group in the quickteams folder
    • teamSettings - metadata about the team
    • groupSettings - metadata about the underlying O365 group
    • groupMembers - group member list
    • groupOwners - group owner list

 

Here are the underlying APIs that it uses:

 

Read messages in a given channel. This will return a paginated list of messages, each with a unique ID.

https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/channel_list_messages

 

Given a unique message ID, get the replies to the message.

https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/channel_list_messagereplies

 

Enjoy!  Look forward to your collective feedback.

Related Conversations
Modify Outlook invite links
arifC in Microsoft Teams on
4 Replies
software dock
pluem540 in Publisher on
0 Replies
Anyone else had Teams vanish from the apps list?
PhilC42 in Surface Hub on
1 Replies