C# 如何在bot框架中获取单击按钮的标题

C# 如何在bot框架中获取单击按钮的标题,c#,botframework,C#,Botframework,当用户点击任何一个按钮时,我想得到按钮的标题。我如何才能做到这一点。我试图找到解决方案,但没有找到合适的解决方案。 我知道了 IActionActivity 用于在按钮单击时执行操作,但我不知道如何实现该界面,以便在用户单击时获得按钮的标题 下面给出了图像链接 [BotAuthentication] public class MessagesController : ApiController { public async Task<HttpResponseMes

当用户点击任何一个按钮时,我想得到按钮的标题。我如何才能做到这一点。我试图找到解决方案,但没有找到合适的解决方案。 我知道了

 IActionActivity
用于在按钮单击时执行操作,但我不知道如何实现该界面,以便在用户单击时获得按钮的标题

下面给出了图像链接

  [BotAuthentication]
  public class MessagesController : ApiController
  {

    public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
    { 
        ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));

        if (activity.Type == ActivityTypes.Message)
        {   
             Options(activity);
        }

        var response = Request.CreateResponse(HttpStatusCode.OK);
        return response;
    }




      private void Options(Activity reply)
      {
        reply.Attachments = new List<Attachment>();
        List<CardAction> cardButtons = new List<CardAction>();
        CardAction Button1 = new CardAction()
        {
            Value = "Product is an interesting career choice.",
            Type = "postBack",
            Title = "Product"

        };

        CardAction Button2 = new CardAction()
        {
            Value = "Design is an interesting career choice.",
            Type = "postBack",
            Title = "Design"

        };

        CardAction Button3 = new CardAction()
        {
            Value = "Development is an interesting career choice.",
            Type = "postBack",
            Title = "Development"
        };

        CardAction Button4 = new CardAction()
        {
            Value = "Marketing is an interesting career choice.",
            Type = "postBack",
            Title = "Marketing"
        };

        CardAction Button5 = new CardAction()
        {
            Value = "Sales is an interesting career choice.",
            Type = "postBack",
            Title = "Sales"
        };
        CardAction Button6 = new CardAction()
        {
            Value = "Administration is an interesting career choice.",
            Type = "postBack",
            Title = "Administration"
        };
        cardButtons.Add(Button1);
        cardButtons.Add(Button2);
        cardButtons.Add(Button3);
        cardButtons.Add(Button4);
        cardButtons.Add(Button5);
        cardButtons.Add(Button6);
        HeroCard jobCard = new HeroCard()
        {
            Buttons = cardButtons
        };

        Attachment jobAttachment = jobCard.ToAttachment();
        reply.Attachments.Add(jobAttachment);
        reply.AttachmentLayout = AttachmentLayoutTypes.Carousel;

    }
}
[BotAuthentication]
公共类消息控制器:ApiController
{
公共异步任务发布([FromBody]活动)
{ 
ConnectorClient连接器=新的ConnectorClient(新Uri(activity.ServiceUrl));
if(activity.Type==ActivityTypes.Message)
{   
备选方案(活动);
}
var response=Request.CreateResponse(HttpStatusCode.OK);
返回响应;
}
专用作废选项(活动回复)
{
reply.Attachments=新列表();
列表卡片按钮=新列表();
CardAction按钮1=新的CardAction()
{
Value=“产品是一个有趣的职业选择。”,
Type=“postBack”,
Title=“产品”
};
CardAction按钮2=新的CardAction()
{
Value=“设计是一个有趣的职业选择。”,
Type=“postBack”,
Title=“设计”
};
CardAction按钮3=新的CardAction()
{
Value=“发展是一个有趣的职业选择。”,
Type=“postBack”,
Title=“开发”
};
CardAction按钮4=新的CardAction()
{
Value=“营销是一个有趣的职业选择。”,
Type=“postBack”,
Title=“营销”
};
CardAction按钮5=新的CardAction()
{
Value=“销售是一个有趣的职业选择。”,
Type=“postBack”,
Title=“销售”
};
CardAction按钮6=新的CardAction()
{
Value=“管理是一个有趣的职业选择。”,
Type=“postBack”,
Title=“管理”
};
卡片按钮。添加(按钮1);
卡片按钮。添加(按钮2);
卡片按钮。添加(按钮3);
卡片按钮。添加(按钮4);
卡片按钮。添加(按钮5);
卡片按钮。添加(按钮6);
HeroCard作业卡=新HeroCard()
{
按钮=卡片按钮
};
附件jobAttachment=jobCard.ToAttachment();
回复.附件.添加(工作附件);
reply.AttachmentLayout=attachmentlayoututypes.Carousel;
}
}

单击后,您将获得按钮的
值<代码>活动。文本
应包含该值


在任何情况下,我看到你在控制器中做所有的工作。我建议使用
对话框

不客气。请将问题标记为已回答。看看那里,你会发现很多使用对话框的示例