Teams Bot Conversation State Management Prompt
Design durable, scalable state for a Teams bot — choosing storage providers, scoping user vs conversation state, and handling concurrency so multi-turn incident workflows survive restarts and parallel responders.
- Target user
- Backend engineers building stateful Bot Framework bots for Teams
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior bot engineer who has run stateful Teams bots that survive restarts, scale-out, and two responders acting on the same incident at once. I will provide: - The bot's multi-turn flows (incident intake, approvals, runbook execution) - Current state storage (MemoryStorage? Blob? Cosmos?) and hosting model - Concurrency reality (shared channels, multiple responders, scale-out instances) - Any data-retention/compliance constraints Your job: 1. **Scope the state correctly** — separate UserState (per-user prefs, auth), ConversationState (per-channel/chat flow position), and PrivateConversationState; explain what belongs in each and why putting flow state in UserState breaks shared channels. 2. **Pick the provider** — compare MemoryStorage (dev only — lost on restart, not shared across instances), Azure Blob storage, and Cosmos DB; recommend Cosmos for production scale-out and explain partition-key choice for even distribution. 3. **Concurrency & optimistic concurrency** — Bot Framework storage uses ETags; show how to handle the 412/precondition-failed when two responders mutate the same conversation state, with a read-modify-write retry and a last-writer-wins vs merge decision per field. 4. **Dialog state** — for waterfall/component dialogs, where the dialog stack lives, and how to make resumption idempotent so a redelivered activity doesn't advance the dialog twice. 5. **TTL & cleanup** — set TTL on transient incident state so closed incidents don't accumulate; keep long-lived prefs separate from ephemeral flow state. 6. **Secrets & PII** — never store tokens in conversation state; reference a Key Vault secret or use the token service. Mask PII at rest if compliance requires. 7. **Testing** — simulate restart mid-flow, concurrent mutations, and redelivered activities; assert no double-execution. Output as: (a) a state-scope table (what lives where), (b) the provider recommendation with partition-key rationale, (c) the ETag conflict-handling pseudocode, (d) the dialog-resumption idempotency design, (e) the TTL/cleanup policy, (f) a test matrix. Bias toward: Cosmos for production, ETag-aware writes, ephemeral state with TTL over unbounded growth.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Bot Card Update vs New Message Strategy for Channel Noise Prompt
Decide, per ChatOps interaction, whether a Teams bot should update an existing activity in place or post a new message — keeping incident channels readable instead of drowning responders in a wall of bot cards.
-
Teams AI Library Vector Data Source RAG Grounding Prompt
Wire a vector data source into a Teams AI Library bot so the planner grounds answers in your runbooks and incident history via retrieval augmentation, with citations and freshness control.
-
Teams Proactive App Install for Users via Graph Prompt
Programmatically install a Teams app for a list of users via Graph so a bot can proactively message them — fetching the conversation reference without waiting for the user to find the app.
-
Teams Bot CLU Intent Dispatch and Command Routing Prompt
Design a natural-language command router for a Teams bot that uses Conversational Language Understanding to classify intents and dispatch to ChatOps handlers with a deterministic fallback
More Microsoft Teams prompts & error guides
Browse every Microsoft Teams prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.