2016-07-23 31 views
0

我想显示为用户在选择城市的按钮像我有以下城市选择: 克利夫兰,哥伦布,特拉华州,梅菲尔德显示按钮,用户在botframework

怎样才能将它们显示为botframework按钮?我能做到这一点与像的形式:

[Prompt("Please select what {&} you are in? {||}")] 
public City? City; 
public static IForm<SandwichOrder> BuildForm() 
{ 
    return new FormBuilder<SandwichOrder>() 
      .Message("Welcome to the simple City bot!") 
      .Build(); 
} 

但我创建的应用程序是不是一种形式,没有更多的同步问题。那么,显示城市供用户选择的其他更简单的方法是什么?

回答

0

取决于你使用的频道,如果你的财产是枚举,网络聊天中会显示为一个列表中进行选择和松弛将显示按钮

1

可以使用卡。

Jast将一些添加到您的活动对象并等待用户响应。

他们有一些特殊的收据卡(让用户提供发票或收据的卡)。

Activity reply = activity.CreateReply($""); 
    reply.Recipient = activity.From; 
    reply.Type = "message"; 
    reply.Attachments = new List<Attachment>(); 

    List<CardAction> cardButtons = new List<CardAction>(); 
    CardAction cityBtn1 = new CardAction() 
    { 
     Value = "cleveland", 
     Type = "postBack", 
     Title = "Cleveland" 
    }; 
    cardButtons.Add(cityBtn1); 

    CardAction cityBtn2 = new CardAction() 
    { 
     Value = "columbus", 
     Type = "postBack", 
     Title = "Columbus" 
    }; 
    cardButtons.Add(cityBtn2); 

    HeroCard plCard = new HeroCard() 
    { 
     Title = "Please select what city you are in?", 
     Buttons = cardButtons 
    }; 
    Attachment plAttachment = plCard.ToAttachment(); 
    reply.Attachments.Add(plAttachment); 
:如何添加对按钮

博特生成器.NET /连接器服务/附件,卡和操作

https://docs.botframework.com/en-us/csharp/builder/sdkreference/attachments.html

样品