2017-05-17 11 views
2

私は列挙型でFormFlowを使用していくつかの質問を表示していますが、フォームフローはそれらをボタン付きのHeroCardとしてレンダリングしているようです。プロンプトを推奨アクションとしてレンダリングしたいので、FBでのクイック返信これを行う最善の方法は何でしょうか? 今のところ、私は以下のようにカスタムプロンプターを実装しましたが、カスタムコードを書く必要がないので、属性でこれを行うより良い方法があるかどうかを知りたいのです。FormFlowと推奨アクション

private static async Task<FormPrompt> Prompter(IDialogContext context, FormPrompt prompt, JObject state, IField<JObject> field) 
    { 
     IMessageActivity promptMessage; 

     // Handle buttons as quick replies when possible (FB only renders 11 quick replies) 
     if (prompt.Buttons.Count > 0 && prompt.Buttons.Count <= 11) 
     { 
      // Build a standard prompt with suggested actions. 
      promptMessage = context.MakeMessage(); 
      promptMessage.Text = prompt.Prompt; 
      var actions = prompt.Buttons.Select(button => new CardAction 
       { 
        Type = ActionTypes.ImBack, 
        Title = button.Description, 
        Value = button.Description 
       }) 
       .ToList(); 
      promptMessage.SuggestedActions = new SuggestedActions(actions: actions); 
     } 
     else 
     { 
      promptMessage = await Extensions.GetDefaultPrompter(context, prompt); 
     } 

     await context.PostAsync(promptMessage); 
     return prompt; 
    } 

答えて

0

この機能が必要な場合は、実装に固執する必要があります。 Formflowはできるだけ抽象的で、Enumオプションをボタン付きのHerocardとして提示するだけです。これはほとんどすべてのチャンネルがヘロコードをサポートしており、フェイスブックだけが迅速な返信をサポートしているためです。

+0

OK、私の実装に固執します、ありがとう。 – GaboG