我正在尝试为我的机器人/网页设置一个反向通道,以便我可以在两者之间发送事件。我添加了此问题Bot framework get the ServiceUrl of embedded chat control page
中显示的示例public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
if (activity.Type == ActivityTypes.Event &&
string.Equals(activity.Name, "buttonClicked", StringComparison.InvariantCultureIgnoreCase))
{
ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
// return our reply to the user
Activity reply = activity.CreateReply("I see that you just pushed that button");
await connector.Conversations.ReplyToActivityAsync(reply);
}
if (activity.Type == ActivityTypes.Message)
{
ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
// return our reply to the user
var reply = activity.CreateReply();
reply.Type = ActivityTypes.Event;
reply.Name = "changeBackground";
reply.Value = activity.Text;
await connector.Conversations.ReplyToActivityAsync(reply);
}
else
{
HandleSystemMessage(activity);
}
var response = Request.CreateResponse(HttpStatusCode.OK);
return response;
}
但是ActivityTypes.Event和activity.Name不存在。我是否需要一个特殊的软件包来处理使用bot框架的反向通道?
答案 0 :(得分:3)
根据您的评论,您似乎使用的是旧版本的BotBuilder nuget包;这就是为什么你没有这些属性/价值观。
请更新到最新版本的BotBuilder v3.5.5,这样就可以了。