The current activity.mentions.stripText: true option removes all structured mentions from inbound activity text. Bot command handlers commonly need different behavior: remove the bot’s leading mention while preserving mentions of other users.
For example:
Input: <at>GitHub</at> help <at>Alice</at>
Output: help <at>Alice</at>
Today this requires application code to identify the mention whose account ID matches activity.recipient.id and remove it manually:
for (const entity of activity.entities ?? []) {
if (
entity.type === 'mention' &&
entity.mentioned?.id === activity.recipient.id &&
entity.text
) {
activity.text = activity.text.replace(entity.text, '').trim();
break;
}
}
The lower-level stripMentionsText utility supports filtering by accountId, but applications must know to call it and pass the recipient ID for every activity. The app-level mention middleware could provide this common behavior directly because it already has access to the activity and its recipient.
Would you consider an option such as:
const app = new App({
activity: {
mentions: {
stripText: {
recipient: true,
leadingOnly: true,
},
},
},
});
or a dedicated utility:
stripRecipientMentionText(activity, { leadingOnly: true });
Expected behavior:
- Remove the bot/recipient mention from the beginning of the message.
- Preserve mentions of other users.
- Preserve a bot mention appearing later in the message when
leadingOnly is enabled.
- Handle mention entities that provide either
text or only the mentioned account’s name.
- Trim whitespace left by removing the leading mention.
This would cover the common Teams bot command-parsing scenario without requiring each application to implement its own mention matching and text mutation.
The current
activity.mentions.stripText: trueoption removes all structured mentions from inbound activity text. Bot command handlers commonly need different behavior: remove the bot’s leading mention while preserving mentions of other users.For example:
Today this requires application code to identify the mention whose account ID matches
activity.recipient.idand remove it manually:The lower-level
stripMentionsTextutility supports filtering byaccountId, but applications must know to call it and pass the recipient ID for every activity. The app-level mention middleware could provide this common behavior directly because it already has access to the activity and its recipient.Would you consider an option such as:
or a dedicated utility:
Expected behavior:
leadingOnlyis enabled.textor only the mentioned account’s name.This would cover the common Teams bot command-parsing scenario without requiring each application to implement its own mention matching and text mutation.