我正在尝试使用Direct Line v3.0 NuGet 包向我的机器人发送消息。我正在关注 Github 上的示例,但没有得到我期望的行为。
这是示例代码:
DirectLineClient client = new DirectLineClient(directLineSecret);
var conversation = await client.Conversations.StartConversationAsync();
while (true)
{
string input = Console.ReadLine().Trim();
if (input.ToLower() == "exit")
{
break;
}
else
{
if (input.Length > 0)
{
Activity userMessage = new Activity
{
From = new ChannelAccount(fromUser),
Text = input,
Type = ActivityTypes.Message
};
await client.Conversations.PostActivityAsync(conversation.ConversationId, userMessage);
}
}
}
这是我的代码:
var directLineSecret = "MY_SECRET";
var client = new DirectLineClient(directLineSecret);
var conversation = await client.Conversations.StartConversationAsync();
var testActivity = new Activity
{
From = new ChannelAccount(name: "Proactive-Engine"),
Type = ActivityTypes.Message,
Text = "Hello from the PCE!"
};
var response = await client.Conversations.PostActivityAsync(conversation.ConversationId, testActivity);
我正在记录我的机器人收到的所有消息。我可以使用 Bot Emulator 在 Azure 上的端点与 bot 对话,因此我确信它正在通过 Web 聊天 API 工作。但是,当我运行上面的代码时,机器人只记录一条conversationUpdate
消息。我发送的消息没有被记录,response
值为null
.
我希望有人能帮我找出我哪里出错了。谢谢!