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#.
- 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.
- 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? -
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.

Report
All responses (
Answers (