Repository navigation
Description
Problem Statement
In a Google Chat direct message, the Google Chat adapter maps every message to one space-only thread ID (gchat:spaces/DM_SPACE:dm) and drops message.thread.name. A DM is therefore one endless conversation for the bot: replies always go to the top level, and a user who starts a new thread in the DM (Google Chat supports threads in DMs) still lands in the same conversation and memory as everything before it.
The Slack adapter handles this differently. In a Slack DM, a reply inside a thread keeps its thread_ts, so it stays a separate conversation, and agentView: true makes every top-level DM message its own thread root, while still routing to the openDM() subscription when that one is subscribed. Google Chat has no equivalent, so the same bot behaves differently on the two platforms.
We build internal agents for colleagues (one case = one thread) and work around this today by replacing the adapter's handleMessageEvent with a copy that keeps the thread name for DMs. That copy breaks with every adapter change.
Proposed Solution
An adapter option, for example threadedDMs: true (name open), with which a DM message is encoded with its thread name, like messages in spaces:
const threadName = isDM && !this.threadedDMs ? undefined : message.thread?.name || message.name;with the :dm marker kept so thread.isDM stays true. Like Slack's agentView bridge, a message could route to the space-only ID when that ID has a subscription from openDM(), so proactive flows keep working.
Default stays as today, so nothing changes for existing users.
Alternatives Considered
- Overriding
handleMessageEventin our own code (what we do now): works, but depends on adapter internals. - Making thread-aware DMs the default: closer to Slack's default (thread replies keep
thread_ts), but changes behaviour for existing bots.
Use Case
import { createGoogleChatAdapter } from '@chat-adapter/gchat';
const gchat = createGoogleChatAdapter({
// ...
threadedDMs: true,
});
// A new thread in a DM -> its own thread ID, its own conversation and memory;
// the bot's reply goes into that thread instead of the top level.Priority
Important
Contribution
- I am willing to help implement this feature
Additional Context
Related: #1135 (card clicks in a DM get a different thread ID than the DM's messages). With this option, a click and the messages of the same DM thread would both carry the thread name, which also removes the mismatch described there for threaded DMs.
The Teams adapter has no equivalent, but Teams 1:1 chats have no reply threads, so there is nothing to keep there.
Activity