2016-07-24 4 views
0

タイトルに記載されているように、フェイスブックメッセンジャーのボタンをタップ/クリックしてポストバックを処理する方法を理解する必要があります。私はこのカードがボットビルダーカードで処理できることを認識していますが、テストしたい他の要素もあります。ユーザーは、アクションに私がしたいノードで別のダイアログを「GO」ボタンをクリックするカードは動作しますが、私はちょうどそれを処理する方法がわからない一度そこで、基本的Facebookからのポストバックを処理する方法sourceEvent botframeworkノード

bot.dialog('/', [ 
function (session) { 
    var msg = new builder.Message(session).sourceEvent({ 
      facebook: { 
        notification_type: "REGULAR", 
        attachment: { 
         type: "template", 
         payload: { 
          template_type: "generic", 
          elements: [{ 
           title: "Title here", 
           image_url: "http://docs.botframework.com/images/demo_bot_image.png", 
           subtitle: "Subtitle here", 
           buttons: [{ 
            type: "postback", 
            title: "GO", 
            payload: "dosomething" 
           }] 
          }] 
         } 
        } 
       } 
     }); 
    session.send(msg); 
}, 
function(session, results){ 
    session.send(JSON.stringify(results)); 
    session.send(JSON.stringify(session)); 
} 
]); 

:以下のコードを参照してください。私はそれが滝で動作するかもしれないと思ったが、示されたコードは何も返さなかった。

多くのありがとう、

答えて

2

私は雲の中から頭を引っ張って自分の質問に答えました。ヒントは、ボタンのタイプ:​​でした。

以下を参照してください。

bot.dialog('/', [ 
    function (session) { 
     var msg = new builder.Message(session).sourceEvent({ 
       facebook: { 
         notification_type: "REGULAR", 
         attachment: { 
          type: "template", 
          payload: { 
           template_type: "generic", 
           elements: [{ 
            title: "Great title", 
            image_url: "http://docs.botframework.com/images/demo_bot_image.png", 
            subtitle: "Even better subtitle", 
            buttons: [{ 
             type: "postback", 
             title: "GO", 
             payload: "action?stacktest" 
            }] 
           }] 
          } 
         } 
        } 
      }); 
     session.send(msg); 
    } 
]); 

だから私はやったすべてのアクション「stacktest」をポストバックし、次でそれを処理されます。

bot.beginDialogAction('stacktest', '/stacktest'); 
bot.dialog('/stacktest', function(session){ 
    session.send("Woot, stacktest worked a treat."); 
}); 

・ホープこれは誰かに役立ちます。

乾杯。

関連する問題