C# DirectLineAPI从不返回对话
所以我使用MicrosoftsBot框架和他们的DirectLineAPI来与它对话。我这样做是因为我需要向机器人发送通知。下面的类由后端中的端点调用。因此,当我调用我的notify端点时,这个类被调用,并且应该启动与bot的对话以触发其中的某些事件。问题是,它似乎没有像预期的那样工作。当我运行代码并向我的端点发出请求时,它被卡在C# DirectLineAPI从不返回对话,c#,direct-line-botframework,C#,Direct Line Botframework,所以我使用MicrosoftsBot框架和他们的DirectLineAPI来与它对话。我这样做是因为我需要向机器人发送通知。下面的类由后端中的端点调用。因此,当我调用我的notify端点时,这个类被调用,并且应该启动与bot的对话以触发其中的某些事件。问题是,它似乎没有像预期的那样工作。当我运行代码并向我的端点发出请求时,它被卡在var conversation=wait client.Conversations.StartConversationAsync()上 wait关键字会停止执行,直到
var conversation=wait client.Conversations.StartConversationAsync()上代码>
wait关键字会停止执行,直到它完成为止,问题是它永远不会完成。但我可以在调试窗口中看到,请求是用201创建的状态码发送的,因此它应该完成,但从来没有完成。我不知道该怎么办
private static async Task StartBotConversation()
{
string directLineSecret = "SECRECT";
string fromUser = "DirectLineSampleClientUser";
DirectLineClient client = new DirectLineClient(directLineSecret);
Debug.WriteLine("Before starting con ");
var conversation = await client.Conversations.StartConversationAsync();
Debug.WriteLine("After starting con");
Activity userMessage = new Activity
{
From = new ChannelAccount(fromUser),
Text = "ERROR1337",
Type = ActivityTypes.Trigger
};
Debug.WriteLine("Before posting activity");
await client.Conversations.PostActivityAsync(conversation.ConversationId, userMessage);
Debug.WriteLine("After posting activity");
}
执行此操作:BotConversation=wait Client.Conversations
.StartConversationAsync().ConfigureAwait(false)代码>
它对我有用,我希望它能帮助你。这个样本对你有用吗?