我开始学习Microsoft Bot Framework,但是当我尝试使用Connector时,它总是返回:
“message”: “An error has occurred.”,
“exceptionMessage”: “Unable to deserialize the response.”,
“exceptionType”: “Microsoft.Rest.RestException”,
这是代码
public async Task<Message> Post([FromBody]Message message)
{
try
{
if (message.Type == "Message")
{
// calculate something for us to return
//int length = (message.Text ?? string.Empty).Length;
// return our reply to the user
// return message.CreateReplyMessage($"You sent {length} characters");
//var counter = message.GetBotPerUserInConversationData<int>("counter");
//// create a reply message
//Message replyMessage = message.CreateReplyMessage($"{++counter} You said:{message.Text}");
//// save our new counter by adding it to the outgoing message
//replyMessage.SetBotPerUserInConversationData("counter", counter);
//// return our reply to the user
////return replyMessage;
// return message.CreateReplyMessage("Yo, I got it.", "en");
// var replyMessage = message.CreateReplyMessage("Yo, I heard you.", "en");
// var connectorr = new ConnectorClient();
// connectorr.BaseUri = new Uri("http://localhost:3978/");
//return await connectorr.Messages.SendMessageAsync(replyMessage);
var connector = new ConnectorClient();
connector.BaseUri = new Uri("http://localhost:3978/api/messages");
await connector.Messages.SendMessageAsync(message.CreateReplyMessage($"You said:{message.Text}"));
await connector.Messages.SendMessageAsync(message.CreateReplyMessage("Yo 2.", "en"));
await connector.Messages.SendMessageAsync(message.CreateReplyMessage("Yo 3.", "en"));
return null;
}
else
{
return HandleSystemMessage(message);
}
}
catch (Exception ex)
{
throw;
}
}
最佳答案 您应该将其升级到最新版本3.8.0.
看看:
https://docs.microsoft.com/en-us/bot-framework/resources-upgrade-to-v3