获得botframework中建议操作的值

时间:2019-03-13 12:49:47

标签: azure c#-4.0 botframework

在botframework中使用建议的操作时如何访问用户所喜欢的值

// Create the activity and add suggested actions.
   var activity = MessageFactory.SuggestedActions(
       new CardAction[]
       {
           new CardAction(title: "red", type: ActionTypes.ImBack, value: "red"),
           new CardAction( title: "green", type: ActionTypes.ImBack, value: "green"),
           new CardAction(title: "blue", type: ActionTypes.ImBack, value: "blue")
       }, text: "Choose a color");

   // Send the activity as a reply to the user.
   await context.SendActivity(activity);

1 个答案:

答案 0 :(得分:0)

如本示例所示:https://github.com/Microsoft/BotBuilder-Samples/blob/master/samples/csharp_dotnetcore/08.suggested-actions/SuggestedActionsBot.cs#L69用户响应的 context.Activity.Text 属性将包含用户的选择。

string userChoice = turnContext.Activity.Text;