Forum Discussion
Copilot Studio in Teams sometimes wraps user input with HTML tags (e.g., <div>)
Hi Leo9
Yes - this is expected behavior when using Copilot Studio with the Teams channel, and it isn’t a bug in your copilot.
Teams often represents user messages as simple HTML behind the scenes, so a plain message like:
get me the onboarding status
may sometimes arrive as:
<div>get me the onboarding status</div>
Exactly when you see tags can vary (desktop vs web vs mobile, typed vs pasted, rich text, etc.), which is why it feels intermittent. Copilot Studio just receives the text in whatever format Teams sends, so the HTML can show up in dialog traces, variables, or any flows you trigger.
To avoid issues when checking or processing user messages, it’s best to normalize or clean the input before applying logic:
- Strip HTML tags from the input (for example, in a variable or in a Power Automate step).
- Use “contains” instead of exact matches when evaluating text.
- Normalize text early (clean it once, then reuse the cleaned value everywhere).
You can solve this issue using Power automate.
In your flow triggered by the copilot:
- Add a Compose action to remove HTML before you apply any conditions, using an expression like:
replace( regexReplace(triggerBody()?['text'], '<[^>]*>', ''), ' ', ' ' )
2. Store that output as cleanedText (or similar), and then use it in your conditions, for example:
contains(cleanedText, 'sample_question')
This ensures your logic works whether the original message arrives as plain text or HTML‑wrapped.
✅ If this helped solve your issue, please Accept as Solution so others can find it quickly.
❤️ If it didn’t fully solve it but was still useful, please click “Yes” on “Was this reply helpful?” or leave a Like :).
🏷️ For follow-ups @Sajeda_Sultana