Skip to content

Add Teams message history API#491

Draft
heyitsaamir wants to merge 11 commits into
microsoft:mainfrom
heyitsaamir:heyitsaamir-add-history-api
Draft

Add Teams message history API#491
heyitsaamir wants to merge 11 commits into
microsoft:mainfrom
heyitsaamir:heyitsaamir-add-history-api

Conversation

@heyitsaamir

@heyitsaamir heyitsaamir commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a Microsoft Graph-backed Teams message history API for app-level and context-level callers, plus a focused example app for manual testing.

API

Reactive context API

history = await ctx.get_history(10)

ctx.get_history(n) infers the current scope from the inbound activity:

  • Chat/group chat: calls Graph GET /chats/{chat-id}/messages
  • Team channel: calls Graph GET /teams/{team-aad-group-id}/channels/{channel-id}/messages
  • Threaded context: detects reply_to_id or ;messageid=<root> and calls .../messages/{root-message-id}/replies

For channel history, the SDK requires the Teams activity to include team.aad_group_id; this is the Graph team resource ID used by RSC.

App-level API

chat_history = await app.get_history(n=10, chat_id=chat_id)

channel_history = await app.get_history(
    n=10,
    team_aad_group_id=team_aad_group_id,
    channel_id=channel_id,
)

thread_history = await app.get_history(
    n=10,
    team_aad_group_id=team_aad_group_id,
    channel_id=channel_id,
    thread_id=message_id,
)

Invalid target combinations raise ValueError; Graph errors propagate unchanged. The helper requests up to Graph's 50-message page limit per call and follows @odata.nextLink until it returns n messages or Graph runs out of pages.

Caveats

  • 1:1 chat history depends on service-side support that is expected to be picked up very soon by the service team.

Example

Adds examples/history with commands to test:

  • history / history ctx <n>
  • history chat <chat-id> [n]
  • history channel <team-aad-group-id> <channel-id> [n]
  • history thread <team-aad-group-id> <channel-id> <thread-id> [n]

heyitsaamir and others added 11 commits June 30, 2026 16:25
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

1 participant