Teams Proactive Bot Messaging at Scale Prompt
Design reliable proactive (bot-initiated) Teams messaging at scale — capturing conversation references, app installation via Graph, throttling, retries, and per-user/per-channel delivery without spam.
- Target user
- Bot developers sending notifications to thousands of users or channels
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior Bot Framework engineer who has run proactive notification systems that fan out to thousands of Teams users and channels without getting throttled into oblivion or spamming people. I want a reliable proactive-messaging design. I will provide: - The notification use case (incident broadcast, deploy notices, personal nudges) - Audience scale and shape (1:1 users, channels, group chats, counts) - My bot stack, hosting, and AAD/Graph permissions - Delivery guarantees I need (at-least-once, ordering, dedup) Your job: 1. **Conversation references** — explain that proactive messages require a stored `ConversationReference` captured from a prior `conversationUpdate`/message activity. Show how to capture, store (keyed by AAD id / channel id), and `continueConversation` against it. 2. **Bootstrapping new targets** — for users who never messaged the bot, use Graph to install the app for the user/team (`userScopeTeamsAppInstallation` / proactive install), then resolve the chat to get a conversation reference. Call out the required Graph permissions and admin consent. 3. **Fan-out architecture** — don't loop synchronously. Use a queue + workers, batch by tenant, and design for idempotent sends (dedup key per recipient per notification). 4. **Throttling & retries** — respect 429s and `Retry-After`, implement exponential backoff with jitter, a per-tenant concurrency cap, and a circuit breaker. Explain Teams/Bot service rate limits and how to stay under them. 5. **Targeting & consent** — honor quiet hours / notification preferences, suppress opt-outs, and never broadcast to a channel where the bot isn't installed (handle gracefully). 6. **Observability** — per-send status, delivery rate, throttle rate, dead-letter queue, and a reconciliation job for failed sends. Output as: (a) conversation-reference capture + store schema, (b) the proactive-install flow with Graph calls + permissions, (c) the queue/worker fan-out design, (d) throttling/retry policy with numbers, (e) an observability + dead-letter plan. Bias toward: at-least-once with idempotency, respecting 429/Retry-After religiously, and opt-outs over reach.