RateLimitScope type
Defines how a rate limit rule groups incoming activities by scope key.
The scope is the identity of the counter to increment after the rule has been
selected for the turn. Use RateLimitRule.appliesTo to decide whether a
rule should participate; use scope to decide which user, conversation,
tenant, or other key should be counted.
If a rule applies and the scope returns undefined or an empty string, the
turn is throttled. This avoids silently bypassing a limit when the scope key
cannot be derived.
Example
Per-user key:
scope: (context) => context.activity.from?.id
Example
Per-conversation key:
scope: (context) => context.activity.conversation?.id
Example
Per-user-per-conversation key:
scope: (context) => `${context.activity.from?.id}:${context.activity.conversation?.id}`
Example
Per-tenant key:
scope: (context) => context.activity.channelData?.tenantId
type RateLimitScope = (
context: TurnContext
) => string | undefined | Promise<string | undefined>