Skip to content

Teams adapter: fetchMessages returns 400 for DM conversations (Bot Framework conversation ID not valid for Graph API) #358

@maremj

Description

@maremj

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

  1. Create a Teams bot using @chat-adapter/teams with appType: "SingleTenant"
  2. Grant Chat.Read.WhereInstalled and/or Chat.Read.All Azure AD app permissions (admin consented)
  3. Add ChatMessage.Read.Chat RSC permission to Teams manifest
  4. Send a DM to the bot
  5. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions