Forum Discussion

Leo9's avatar
Leo9
Copper Contributor
Apr 30, 2026

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.

2 Replies

  • 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:

    1. Add a Compose action to remove HTML before you apply any conditions, using an expression like:

    replace( regexReplace(triggerBody()?['text'], '<[^>]*>', ''), '&nbsp;', ' ' )

        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