Description
thread.allMessages (and thread.adapter.fetchMessages()) fails with HTTP 400 for Teams DM (personal chat) conversations. The error occurs because the Bot Framework conversation ID format (a:xxxxx) is not a valid Graph API chat ID.
Steps to reproduce
- Create a Teams bot using
@chat-adapter/teams with appType: "SingleTenant"
- Grant
Chat.Read.WhereInstalled and/or Chat.Read.All Azure AD app permissions (admin consented)
- Add
ChatMessage.Read.Chat RSC permission to Teams manifest
- Send a DM to the bot
- In
onSubscribedMessage, call thread.allMessages or thread.adapter.fetchMessages(thread.id)
Expected behavior
Message history is returned for the DM conversation.
Actual behavior
Graph API returns HTTP 400. The adapter passes the Bot Framework conversation ID directly as the `chat-id` parameter to `/chats/{chat-id}/messages`.
For DMs, the conversation ID is in Bot Framework format: `a:1iuf9pNr-XOa5Q5y_Tbj6Z5NIUcrcGFEf7DkksNPQ8Q6KI...`
The Graph API expects a chat ID in format: `19:xxxxx@thread.v2` or a GUID.
Root cause
In `TeamsGraphReader.fetchMessages()`, line ~430:
```js
const response = await this.deps.graph.call(chats.messages.list, {
"chat-id": baseConversationId, // "a:1iuf9pNr..." — not valid for Graph
...
});
```
The `baseConversationId` is the raw Bot Framework conversation ID decoded from the thread ID. For channel conversations (`19:xxx`), this works because the format is the same. For DMs (`a:xxx`), Graph doesn't recognize it.
Workaround
Currently falling back to current message only, which breaks multi-turn conversations.
Environment
- `chat`: 4.24.0
- `@chat-adapter/teams`: 4.24.0
- `@chat-adapter/state-pg`: latest
- Next.js 16, Vercel deployment
- Azure Bot Service: SingleTenant
- Permissions: `Chat.Read.All` + `Chat.Read.WhereInstalled` (app), `ChatMessage.Read.Chat` (RSC)
Description
thread.allMessages(andthread.adapter.fetchMessages()) fails with HTTP 400 for Teams DM (personal chat) conversations. The error occurs because the Bot Framework conversation ID format (a:xxxxx) is not a valid Graph API chat ID.Steps to reproduce
@chat-adapter/teamswithappType: "SingleTenant"Chat.Read.WhereInstalledand/orChat.Read.AllAzure AD app permissions (admin consented)ChatMessage.Read.ChatRSC permission to Teams manifestonSubscribedMessage, callthread.allMessagesorthread.adapter.fetchMessages(thread.id)Expected behavior
Message history is returned for the DM conversation.
Actual behavior
Graph API returns HTTP 400. The adapter passes the Bot Framework conversation ID directly as the `chat-id` parameter to `/chats/{chat-id}/messages`.
For DMs, the conversation ID is in Bot Framework format: `a:1iuf9pNr-XOa5Q5y_Tbj6Z5NIUcrcGFEf7DkksNPQ8Q6KI...`
The Graph API expects a chat ID in format: `19:xxxxx@thread.v2` or a GUID.
Root cause
In `TeamsGraphReader.fetchMessages()`, line ~430:
```js
const response = await this.deps.graph.call(chats.messages.list, {
"chat-id": baseConversationId, // "a:1iuf9pNr..." — not valid for Graph
...
});
```
The `baseConversationId` is the raw Bot Framework conversation ID decoded from the thread ID. For channel conversations (`19:xxx`), this works because the format is the same. For DMs (`a:xxx`), Graph doesn't recognize it.
Workaround
Currently falling back to current message only, which breaks multi-turn conversations.
Environment