2017-12-19 7 views
0

私はMSFTボットフレームワークでボットを作成するためにnodejs SDKを使用しています。 コードスニペットは、次のとおりです。botframeworkの選択肢が無効です。

  1. が、私は「(当時場合には別のダイアログフローにAAAをオプションを他のユーザーが何かをナビゲートしたいと思います:

    function(session, args, next){ 
    builder.Prompts.choice(session, "Please select one of the options:", ['AAA', 'BBB','CCC'], {retryPrompt: "Invalid choice, Please pick below listed choices", 
          listStyle: builder.ListStyle.button, 
          maxRetries: 1 
          }); 
    }, 
    function(session,results){ 
        if (results.response) { 
         //Do something 
        } 
    } 
    

    私は2つの質問を持っています"、" BBB "、" CCC ")。それは可能ですか?

  2. retryPromptを毎回変更して、リストから発言を選択するとします。それは可能ですか?

答えて

0

あなたはretryPromptで関数を呼び出すことができますとして、あなたはそれらの両方を行うことができます:上記で

builder.Prompts.choice(
    session, 
    'This is just a question?', 
    'Yes|No', 
    { retryPrompt: particularRetry() } 
); 

を、あなたはparticularRetry機能でやりたいことができます。 たとえば、2番目の質問では、新しいpropmtを新しい選択肢と呼ぶことができます。 詳しくはthis postをご覧ください。

+0

ありがとうございます。 –

1

ユーザがオプション(「AAA」、「BBB」、「CCC」)以外を入力した場合は、別のダイアログフローに移動したいと思います。それは可能ですか?

はい、可能です。選択肢に関連する必要なウォーターフォールステップを含むいくつかのダイアログを定義することができます。同様に:新しいダイアログにユーザーをリダイレクトする

bot.dialog('AAA',[...]) 

レバレッジreplaceDialogの流れ:

(session,result)=>{ 
     //result.response.entity should be one of string `AAA`,`BBB`,`CCC` 
     session.replaceDialog(result.response.entity); 
    } 

私はretryPrompt毎回リストから発話を選ぶと言うことができます変更したいです。それは可能ですか?

はい、可能です。 choice定義よると、我々はオプションを設定することができ、[IPromptOptions][2]を拡張IPromptChoiceOptionsを拡張し、我々はretryPrompt?: TextOrMessageType;は、TextOrMessageTypeの定義のためのソースコードに掘ることを見つけることができます:

/** 
* Flexible range of possible prompts that can be sent to a user. 
* * _{string}_ - A simple message to send the user. 
* * _{string[]}_ - Array of possible messages to send the user. One will be chosen at random. 
... 
... 
*/ 
export type TextOrMessageType = string|string[]|IMessage|IIsMessage; 

だから我々はretryPromptの文字列のリストを設定することができ、ボットビルダーはランダムに1つを選択します。以下を試してください:

builder.Prompts.choice(session, "Please select one of the options:", ['AAA', 'BBB', 'CCC'], { 
      listStyle: builder.ListStyle.button, 
      maxRetries: 1, 
      retryPrompt:['utterance 1','utterance 2','utterance 3','utterance 4'] 
     }); 
+0

本当に助けてくれてありがとう。 –

+0

こんにちは@AIMCognitiveGurgaonBigData、あなたの良いニュースを見てうれしく思います。あなたの問題を解決した場合は、それを回答としてマークすることもできます。同じ問題に直面している他のコミュニティにとってもメリットがあります。 –

関連する問題