Forum Discussion
Copilot Studio in Teams sometimes wraps user input with HTML tags (e.g., <div>)
I’m using Copilot Studio deployed to Microsoft Teams, and I noticed that user messages are occasionally received with HTML tags.
For example, when a user sends "get me the onboarding status", sometimes it displays in the dialog box as "<div>get me the onboarding status</div>"
This does not happen consistently.
I’m not sure whether this is caused by how Teams renders or sends messages (e.g., HTML vs plain text), or if it is something specific to Copilot Studio.
Is this expected behavior for the Teams channel?
Any clarification or recommended handling would be appreciated.
4 Replies
- Prasad_Das-MSFT
Microsoft
Hi Leo9 thanks for raising your issue.
Teams may internally send messages in HTML format, but raw HTML tags such as <div>...</div> should not normally be displayed directly in the Teams chat UI for end users. There is currently no supported setting in Teams or Copilot Studio to force all incoming messages to plain-text format at the source. However, if HTML tags are visibly rendered in the chat window itself, this is not generally expected behavior and may indicate a rendering/client-side issue or that message content is being echoed back without sanitization.
It would help to confirm whether the tags are appearing in the actual Teams conversation UI versus debug traces/variables, and whether the issue is reproducible across Teams desktop/web/mobile clients.
- Leo9Copper Contributor
Hi Sajeda,
Thanks for the explanation. My main question is actually not about how to clean or process the input inside the agent/flow. I’m trying to understand whether there is any way to prevent the HTML tags from appearing in the Teams chat UI itself, so that messages are consistently displayed as plain text instead of sometimes showing things like: <div>get me the onboarding status</div>
Is there any supported way to achieve this in the Teams channel, or is this behavior currently unavoidable?
Thanks!
Hi Leo9,
Just following up to check if everything is working now. Let me know if you still need any help - I’m happy to assist.
If the issue has been resolved, please consider marking the answer as solved so it can help others with a similar question.
Thanks, and have a great day!
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