public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
if (activity.Type == ActivityTypes.Message)
{
await Conversation.SendAsync(activity, () => new DialogsHelper.EchoDialog());
}
else
{
this.HandleSystemMessage(activity);
}
var response = Request.CreateResponse(HttpStatusCode.OK);
return response;
我正在使用visual studio 2015和microsoft bot模拟器。 这是机器人模拟器的响应。 我试着安装
Install-Package Microsoft.Bot.Builder
我收到此错误:
Install-Package:无法安装包'Microsoft.Bot.Builder 3.4.0' 。您正在尝试将此软件包安装到以“.NETFramework,Version = v4.5”为目标的项目中,但该软件包不包含 任何与之兼容的程序集引用或内容文件 那个框架。有关更多信息,请与软件包作者联系。在 line:1 char:1 + Install-Package Microsoft.Bot.Builder + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo:NotSpecified:(:) [Install-Package],Exception + FullyQualifiedErrorId:NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
评论此行时,
await Conversation.SendAsync(activity, () => new DialogsHelper.EchoDialog());
模拟器响应为200,即可。
在这个dialogshelper命名空间中,我有这个简单的类:
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Connector;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
namespace MessengerBot.Helpers
{
public class DialogsHelper
{
[Serializable]
public class EchoDialog : IDialog<object>
{
public async Task StartAsync(IDialogContext context)
{
context.Wait(MessageReceivedAsync);
}
public async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> argument)
{
var message = await argument;
await context.PostAsync("You said: " + message.Text);
context.Wait(MessageReceivedAsync);
}
}
}
}
这个想法:我想使用Microsoft Bot Dialogs。 我正在学习本教程here。
如何解决这个问题?