Teams Bot Mention Parsing & Command Grammar Prompt
Design robust @-mention stripping and a forgiving command grammar for a ChatOps bot so noisy channel mentions, formatting entities, and typos still resolve to the right action.
- Target user
- Developers building command-driven ChatOps bots in Teams channels
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior ChatOps engineer who has built Teams bots whose command parsing just works, even when users mangle the syntax. I will provide: - My intended commands (e.g. deploy, rollback, ack, silence, status) and their args - Whether the bot runs in channels, group chats, or 1:1 - Example messy real-world messages users actually send - My current naive parser and where it breaks Your job: 1. **Strip the mention correctly** — explain that in channels the bot's display name appears in the text with a matching `entities[]` mention object, and that you must remove it using the mention entity offsets/text, not a brittle string replace. Show code that strips all `mention` entities (including replies that mention other users) before parsing. 2. **Normalize** — collapse whitespace, decode HTML entities Teams injects, drop trailing punctuation, and lowercase the verb while preserving arg casing. 3. **A forgiving grammar** — define a small command grammar (verb + flags + positional args), with aliases (`rollback`/`undo`), and fuzzy matching for near-miss verbs that asks "did you mean rollback?" instead of failing silently. 4. **Arg parsing** — handle `--flag value`, `--flag=value`, quoted multi-word values, and sensible defaults; validate enums (env must be one of dev/stage/prod) with helpful errors. 5. **Disambiguation + help** — when a command is ambiguous or incomplete, reply with an Adaptive Card prompting for the missing arg rather than dumping a usage wall. Provide a `help` that lists commands contextually. 6. **Safety gates** — require explicit confirmation for destructive verbs (rollback prod), and ignore mentions of the bot that are clearly not commands (someone quoting it). 7. **Tests** — turn my messy examples into a table of input → parsed intent, including the cases that currently break. Output: (a) the mention-stripping function using entity offsets, (b) the normalize + parse pipeline, (c) the grammar/alias/fuzzy-match spec, (d) the disambiguation card, (e) a test table built from my real messages. Bias toward: resilience to messy input, never executing destructive commands on ambiguous parses, helpful nudges over silent failures.
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 Action Planner for Ops Bot Prompt
Design a Teams AI Library bot that uses the Action Planner, prompt templates, and a registered action set to turn natural-language ops requests into safe, confirmed tool calls.
-
Teams Adaptive Card Action.Execute Backend Wiring Prompt
Design the bot-side backend that handles Adaptive Card Action.Execute invoke activities — returning refreshed cards, inline errors, and auto-loading indicators without bouncing users to a browser.
-
Teams Bot Waterfall Dialog for Incident Intake Prompt
Design a stateful, multi-step conversational dialog that walks a reporter through structured incident intake — severity, affected service, impact, and reproduction — then files the ticket.
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.