web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Copilot Studio / Using Activity.Channel...
Copilot Studio
Answered

Using Activity.ChannelId to conditionally format responses in Teams vs. Copilot app

(0) ShareShare
ReportReport
Posted on by 4

I've built a Copilot Studio agent deployed to both Microsoft Teams (DM) and the Copilot app. The default citation format renders beautifully in the Copilot app but shows as raw [turn1doc12] style tags in Teams DM, which is a bad experience for users.

I want to detect which channel the user is on and conditionally apply different formatting instructions. I tried resolving ${Activity.ChannelId} in the behavior prompt but Cliff confirmed it comes through as a literal string, not a resolved value.

My setup: GPT-5.5 Chat, SharePoint/OneDrive/Teams/Mail MCP tools connected.

Questions:


  1. Can Activity.ChannelId be captured in a topic at conversation start and stored as a variable Cliff can reference?

  2. If yes, can that variable conditionally affect response formatting?

  3. Is there a better approach entirely?
CItation format i...
Citation format i...

Your file is currently under scan for potential threats. Please wait while we review it for any viruses or malicious content.

I have the same question (0)
  • Verified answer
    sannavajjala87 Profile Picture
    515 Super User 2026 Season 1 on at
    Hi,
     
    what you’re trying to do is conceptually right, but not fully supported in the new agent experience today. While Activity.ChannelId is part of the underlying activity context, it isn’t reliably resolved inside behavior prompts (which is why you’re seeing it as a literal string), and in practice it’s also not exposed in a way that Cliff/instructions can dynamically branch on during response generation.
    In theory, you can capture System.Activity.ChannelId inside a topic at runtime and store it in a variable (this is a known pattern for channel-aware behavior), but the limitation is that those topic variables don’t influence the behavior prompt or model formatting decisions directly, so you can’t use them to conditionally change citation formatting at the instruction level.
    Given that, most people end up using workarounds instead of true channel detection in prompts. The more reliable approaches today are: (1) handle formatting after generation (e.g., using System.Response.FormattedText + custom citation rendering), (2) normalize output so it works acceptably in both channels, or (3) apply post-processing via topics like OnGeneratedResponse or OnPlanComplete where you can reshape citations into links or plain text depending on what renders correctly in Teams.
    So overall: capturing the channel is possible at the topic level, but using it to dynamically drive formatting in the new Copilot response pipeline isn’t fully wired yet, which is why you’re hitting that gap.
  • mnamvar Profile Picture
    4 on at
    Thanks, that's the confirmation I needed. We ended up implementing a normalized citation format that works in both channels. Appreciate the thorough explanation.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Copilot Studio

#1
Valantis Profile Picture

Valantis 277

#2
11manish Profile Picture

11manish 206

#3
sannavajjala87 Profile Picture

sannavajjala87 156 Super User 2026 Season 1

Last 30 days Overall leaderboard