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 / Microsoft.Bot.Connecto...
Copilot Studio
Suggested Answer

Microsoft.Bot.Connector.DirectLine --version 3.0.2 questions

(0) ShareShare
ReportReport
Posted on by
Hello Community, forgive me if I am asking something that has an answer, but I have searched for Microsoft.Bot.Connector.DirectLine and found several unanswered topics (some have overlap with my questions). I hope this is correct place to ask these questions.
 
Context:
I decided to ask my own question since I am worried if this feature set is unfinished/low priority and not actually ready for productive use, in which case I am wasting time and need to use a different technology.
 
My goal is to have agents in Copilot Studio, for the simple reason that they can be easily managed by users that use their capabilities (those are power users who understand the LLM configuration but aren't to be concerned with low-level technicalities like APIs, client secrets, tokens etc).
 
These agents however, should be usable from an external app (webapp/custom CRM system), and I currently have them living in Azure Foundry (where they cannot be managed by the power users).
This is why I need to access them programatically (the chat interactions are going to happen in my web app), and why my question has DirectLine nuget in the title. I am using this SDK in C#.
 
Problems:
  1. The "direct line" and "Mobile application" as described in this article do not seem to exist in the Agent -> Connections. I did find similar endpoint under "Direct Line Speech" Channel - it looks like "https://{tenantid}.environment.api.powerplatform.com/powervirtualagents/botsbyschema/{agentname}/directline/token?api-version=2022-03-01-preview" - This might be a bit outdated documentation, I was able to figure it out.
  2. The token endpoint from #1 seems to be working for most of the time, but there were situations where about half of requests I make in 10 seconds would produce an error (unfortunately I did not save the json response, will try to update if I reproduce it again), and when I am able to get a token, the behavior of the API is very inconsistent. This snippet might get conversation, or might fail silently and have conversation end up being null:
    var token = await GetDirectLineTokenAsync();
    using var client = new Microsoft.Bot.Connector.DirectLine.DirectLineClient(token);
    var conversation = await client.Conversations.StartConversationAsync();
    This is very weird since I never know if API is going to work, or just return null with no error. It is even more confusing when I wrote a test for my agent and it works about 3/10 times.
    Other times I can see an $exception in locals with the 403 error (Response status code indicates server error: 403 (Forbidden).), coming from Microsoft.Rest.ClientRuntime.
    How is it possible that same code with same url has undeterministic outcomes? 
  3. Above is with unsecured endpoint/bot. I want to use secured, but again, I am only able to get the token about 3/10 times, and the remainder the response is:
    {
      "error": {
        "code": "ResourceNotFound",
        "message": "Site missing. 1:Learn more about sites  https://docs.microsoft.com/azure/bot-service/bot-service-channel-connect-directline?view=azure-bot-service-4.0#add-new-site. 2:If you are using regional bot, please make sure you are using <[region].*.botframework.com>. Learn more https://docs.microsoft.com/azure/bot-service/rest-api/bot-framework-rest-direct-line-3-0-authentication?view=azure-bot-service-4.0#generate-a-direct-line-token"
      }
    }
    Again, how is that possible for same client secret? My code is based on the snippet from this article, which does POST to https://directline.botframework.com/v3/directline/tokens/generate with the Authorization header set to the client secret of the bot. And the worst thing is that I actually get the token, sometimes
    It feels like this endpoint is hitting a load balancer which sometimes passes request to upstream server of Copilot Studio where it works, and sometimes to upstream server hosting bots configured manually in Azure (at least that is what the error message points at).
     
    So, I am wondering if there is some kind of outage that is not indicated anywhere in the Copilot Studio, or is this api a joke? Is there anyone actually using this in production system?
     
    Thank you for your time.
I have the same question (0)
  • Suggested answer
    Sayali Profile Picture
    Microsoft Employee on at
    Hello ,
    Direct Line integration with Copilot Studio is supported but not the primary or most stable approach for modern implementations, as Microsoft now recommends using the Agents SDK or Copilot Studio client for better reliability and simplified authentication. The inconsistent behavior you are experiencing—such as intermittent token generation failures, 403 errors, and “Site missing” responses—is typically caused by configuration issues rather than random API instability. Common root causes include mismatched regional endpoints, incorrect mixing of Power Platform token endpoints with Bot Framework Direct Line endpoints, improper token lifecycle handling, and potential throttling or routing inconsistencies when using global endpoints. Direct Line remains a lower-level integration path that requires careful handling of token generation, retries, and region-specific configuration to achieve stable behavior. For production scenarios, it is generally more reliable to use the newer SDK-based integration or introduce a backend proxy layer to manage authentication, routing, and resiliency more effectively.
    Reference Document:
    1.Configure web and Direct Line channel security - Microsoft Copilot Studio | Microsoft Learn
    2.Integrate with web or native apps using Microsoft 365 Agents SDK - Microsoft Copilot Studio | Microsoft Learn
    3.API reference - Direct Line API 3.0 - Bot Service | Microsoft Learn
    4.Error: Site Missing code 403 from https://directline.botframework.com/v3/directline/conversations · Issue #100 · microsoft/CopilotStudioSamples

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Copilot Studio

#1
Valantis Profile Picture

Valantis 802

#2
Vish WR Profile Picture

Vish WR 331

#3
Haque Profile Picture

Haque 292

Last 30 days Overall leaderboard