2017-11-09 218 views
0

ボットフレームワークでアダプティブカードとして入力フォームを使用しています。 これで、ユーザーがフォームで指定したデータを取得し、ユーザーが「送信」ボタンをクリックした後にそのデータを画面に表示したいとします。入力フォームからデータを取得アダプティブカード

私はそれが動作するように見えないので、誰かが私にコードの例を教えてもらえますか?

私は次の適応カードを使用しています:http://adaptivecards.io/samples/InputForm.html

{ 
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", 
    "type": "AdaptiveCard", 
    "version": "1.0", 
    "body": [ 
    { 
     "type": "ColumnSet", 
     "columns": [ 
     { 
      "type": "Column", 
      "width": 2, 
      "items": [ 
      { 
       "type": "TextBlock", 
       "text": "Tell us about yourself", 
       "weight": "bolder", 
       "size": "medium" 
      }, 
      { 
       "type": "TextBlock", 
       "text": "We just need a few more details to get you booked for the trip of a lifetime!", 
       "isSubtle": true, 
       "wrap": true 
      }, 
      { 
       "type": "TextBlock", 
       "text": "Don't worry, we'll never share or sell your information.", 
       "isSubtle": true, 
       "wrap": true, 
       "size": "small" 
      }, 
      { 
       "type": "TextBlock", 
       "text": "Your name", 
       "wrap": true 
      }, 
      { 
       "type": "Input.Text", 
       "id": "myName", 
       "placeholder": "Last, First" 
      }, 
      { 
       "type": "TextBlock", 
       "text": "Your email", 
       "wrap": true 
      }, 
      { 
       "type": "Input.Text", 
       "id": "myEmail", 
       "placeholder": "[email protected]", 
       "style": "email" 
      }, 
      { 
       "type": "TextBlock", 
       "text": "Phone Number" 
      }, 
      { 
       "type": "Input.Text", 
       "id": "myTel", 
       "placeholder": "xxx.xxx.xxxx", 
       "style": "tel" 
      } 
      ] 
     }, 
     { 
      "type": "Column", 
      "width": 1, 
      "items": [ 
      { 
       "type": "Image", 
       "url": "https://upload.wikimedia.org/wikipedia/commons/b/b2/Diver_Silhouette%2C_Great_Barrier_Reef.jpg", 
       "size": "auto" 
      } 
      ] 
     } 
     ] 
    } 
    ], 
    "actions": [ 
    { 
     "type": "Action.Submit", 
     "title": "Submit" 
    } 
    ] 
} 

答えて

0

https://github.com/Microsoft/BotBuilder-Samples/tree/master/Node/cards-AdaptiveCardsでのNode.js上AdaptiveCardsの使用についてのサンプルがあります。あなたは詳細を参照することができます。 Submitメソッドを使用している場合

、ボットフレームワークは、提出を処理すると、あなたのボットは、JSONオブジェクトとしてフォームデータで埋めそのvalueフィールドで新しいメッセージを受信します。

このサンプルでは、​​送信メッセージを処理するために関数processSubmitActionを作成します。出力するには

var bot = new builder.UniversalBot(connector, function (session) { 

    if (session.message && session.message.value) { 
     // A Card's Submit Action obj was received 
     processSubmitAction(session, session.message.value); 
     return; 
    } 

    // ... 
}); 

ユーザーの入力値は、単に参照のためsession.send()を使用することができます。

function processSubmitAction(session, value) { 
    session.send(JSON.stringify(value)); 
} 
+0

は、あなたの反応をありがとう、しかし、私が実装したときに私のコードがクラッシュするようです。私はあなたに連絡できる方法はありますか? – KHaemels

+0

@KHaemels、あなたが直接私に連絡するのはとても便利ではありません。申し訳ありません。しかし、問題とコードスニペットを使用してSO上に新しいスレッドを開くことができます。コミュニティは常にあなたを助けます。 –

関連する問題