我怎样才能在机器人框架中点击按钮的标题

how can i get the title of button on click in bot framework

我想在用户单击任何按钮时获取按钮的标题 button.How 我可以实现吗 this.I 我正在尝试找到解决方案,但没有找到合适的解决方案。 我才知道

 IActionActivity

用于在按钮单击时执行操作,但我不知道如何实现该接口以在用户单击时获取按钮的标题

图像 link 如下

  [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;

    }
}

点击后您将获得按钮的ValueActivity.Text 应包含该值。

无论如何,我看到您正在控制器中完成所有工作。我建议改用 Dialog