feat(msteams): add per-channel requireMention config
- Add teams/channels config structure to MSTeamsConfig - Implement requireMention check in monitor.ts - Resolution order: channel > team > global > default (true) - Update zod schema for validation - Document RSC permissions for receiving all messages without @mention - Document Graph API Proxy pattern for historical message access - Document private channel limitations - Document team/channel ID format (use URL path, not groupId)
This commit is contained in:
@@ -57,6 +57,12 @@ type TeamsActivity = {
|
||||
type?: string;
|
||||
mentioned?: { id?: string; name?: string };
|
||||
}>;
|
||||
/** Teams-specific channel data including team info */
|
||||
channelData?: {
|
||||
team?: { id?: string; name?: string };
|
||||
channel?: { id?: string; name?: string };
|
||||
tenant?: { id?: string };
|
||||
};
|
||||
};
|
||||
|
||||
type TeamsTurnContext = {
|
||||
@@ -288,6 +294,34 @@ export async function monitorMSTeamsProvider(
|
||||
}
|
||||
}
|
||||
|
||||
// Check requireMention for channels and group chats
|
||||
if (!isDirectMessage) {
|
||||
const teamId = activity.channelData?.team?.id;
|
||||
const channelId = conversationId;
|
||||
|
||||
// Resolution order: channel config > team config > global config > default (true)
|
||||
const teamConfig = teamId ? msteamsCfg?.teams?.[teamId] : undefined;
|
||||
const channelConfig = teamConfig?.channels?.[channelId];
|
||||
|
||||
const requireMention =
|
||||
channelConfig?.requireMention ??
|
||||
teamConfig?.requireMention ??
|
||||
msteamsCfg?.requireMention ??
|
||||
true;
|
||||
|
||||
const mentioned = wasBotMentioned(activity);
|
||||
|
||||
if (requireMention && !mentioned) {
|
||||
log.debug("skipping message (mention required)", {
|
||||
teamId,
|
||||
channelId,
|
||||
requireMention,
|
||||
mentioned,
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Format the message body with envelope
|
||||
const timestamp = parseTimestamp(activity.timestamp);
|
||||
const body = formatAgentEnvelope({
|
||||
|
||||
Reference in New Issue
Block a user