ActivityTypes.Event BackChannel 通信不存在

ActivityTypes.Event does not exist for BackChannel communication

我正在尝试为我的 bot/web 页面设置一个反向通道,以便我可以在两者之间发送事件。我添加了这个问题

中显示的示例
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 框架的反向通道吗?

根据您的评论,您使用的似乎是旧版本的 BotBuilder nuget 包;这就是为什么你没有那些 properties/values.

请更新到最新版本 BotBuilder v3.5.5 即可。