Skip to content

fix(adapter-teams): resolve DM conversation IDs for Graph API#403

Merged
bensabic merged 2 commits into
vercel:mainfrom
heyitsaamir:fix/teams-dm-fetchmessages
Apr 20, 2026
Merged

fix(adapter-teams): resolve DM conversation IDs for Graph API#403
bensabic merged 2 commits into
vercel:mainfrom
heyitsaamir:fix/teams-dm-fetchmessages

Conversation

@heyitsaamir
Copy link
Copy Markdown
Contributor

Summary

  • fetchMessages was returning 404 for DM conversations — the opaque Bot Framework conversation ID (a:...) doesn't work with Graph's /chats/{chat-id}/messages
  • Introduced TeamsGraphContext discriminated union (channel | dm) to cache the resolved Graph chat ID (19:{aadId}_{botId}@unq.gbl.spaces) from activity.from.aadObjectId
  • getChannelContextgetGraphContext now handles both channels and DMs through a single cache key

Test plan

  • DM the bot with "history" — fetchMessages returns messages instead of 404
  • Channel fetchMessages still works (unchanged code path)
  • pnpm validate passes (build, typecheck, lint, tests)
  • New unit tests for chatIdFromContext (DM, null, channel contexts)

…ssages

DM conversation IDs from Bot Framework are opaque and don't work with
Graph's /chats/{chat-id}/messages endpoint. Cache the user's AAD object
ID from incoming activities and construct the correct Graph chat ID
(19:{aadId}_{botId}@unq.gbl.spaces) via a new TeamsGraphContext union.

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 20, 2026

@heyitsaamir is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

Remove redundant type checks — DMs never have threadMessageId so the
channel guard doesn't need an explicit DM exclusion.

Co-Authored-By: Claude <noreply@anthropic.com>
@bensabic bensabic merged commit 4c24c94 into vercel:main Apr 20, 2026
6 of 8 checks passed
grundmanise pushed a commit to grundmanise/vercel-chat-sdk that referenced this pull request Apr 22, 2026
…#403)

* fix(adapter-teams): resolve DM conversation IDs for Graph API fetchMessages

DM conversation IDs from Bot Framework are opaque and don't work with
Graph's /chats/{chat-id}/messages endpoint. Cache the user's AAD object
ID from incoming activities and construct the correct Graph chat ID
(19:{aadId}_{botId}@unq.gbl.spaces) via a new TeamsGraphContext union.

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(adapter-teams): simplify graph context branching

Remove redundant type checks — DMs never have threadMessageId so the
channel guard doesn't need an explicit DM exclusion.

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
dancer pushed a commit that referenced this pull request Apr 30, 2026
* fix(adapter-teams): resolve DM conversation IDs for Graph API fetchMessages

DM conversation IDs from Bot Framework are opaque and don't work with
Graph's /chats/{chat-id}/messages endpoint. Cache the user's AAD object
ID from incoming activities and construct the correct Graph chat ID
(19:{aadId}_{botId}@unq.gbl.spaces) via a new TeamsGraphContext union.

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(adapter-teams): simplify graph context branching

Remove redundant type checks — DMs never have threadMessageId so the
channel guard doesn't need an explicit DM exclusion.

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
patrick-chinchill added a commit to Chinchill-AI/chat-sdk-python that referenced this pull request May 28, 2026
…IDs (#85)

Two small upstream bug-fix ports.

fix(slack): interactive-payload team_id through streaming context (vercel/chat#330)
- Slack carries the workspace ID in different shapes for interactive payloads vs message events
- Old extraction returned the entire team dict for block_actions, breaking streaming routing
- New _extract_slack_recipient_team_id helper walks each shape in order

fix(teams): canonical DM conversation ID for Microsoft Graph API (vercel/chat#403)
- Bot Framework opaque DM IDs are rejected by Graph's /chats/{chat-id}/messages endpoint
- Cache the user's AAD object ID into a new TeamsDmContext keyed by base conversation ID
- Discriminated union TeamsGraphContext for DM vs channel dispatch
- Backwards-compatible with pre-existing cached entries
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.

2 participants