2017-05-26 156 views
1

我想實現聊天機器人內的共享按鈕。點擊分享按鈕後,該消息將與選定的聯繫人列表共享。圖片FB_ChatBot.png是什麼,我想我的聊天機器人內部實施和Share_Btn_Output在Node.js的Facebook chatbot中分享按鈕

enter image description here

PNG文件是由分享按鈕產生的輸出點擊。

+0

[共享按鈕在Facebook的信使]的可能的複製(https://stackoverflow.com/questions/42318597/share-button-in-facebook-messenger) –

+0

@EzequielJadib任何樣本代碼在節點js中可用,關於它的實現。 –

+0

@EzequielJadib我能夠實現它的單個分享按鈕,但我怎樣才能顯示2卡按鈕視圖格式的按鈕,就像上面的圖片 –

回答

1

我能夠顯示共享按鈕,下面的代碼,但仍然顯示內卡兩個按鈕(1視圖和2共享)結構。下面的解決方案將用於顯示使用Node js的chatbot平臺中的共享按鈕。

var msg = new builder.Message(session); 
     msg.sourceEvent({ 
      facebook: { 
       attachment: { 
        type: "template", 
        payload: { 
         template_type: "generic", 
         elements: [{ 
          title: "title", 
          subtitle: "subtitle", 
          image_url: "https://external.xx.fbcdn.net/safe_image.php?d=AQBIbeQ2vl8bb5tl&url=http%3A%2F%2Fimagizer.imageshack.us%2F196x92f%2F924%2FySQ7a9.png&_nc_hash=AQAv9cZ-0jAr9REX", 
          item_url: "url", 
          buttons: [{ 
           type: "element_share" 
          }] 
         }] 
        } 
       } 
      } 
     }); 
     session.send(msg); 

低於輸出圖像,enter image description here

2

這是一個遲到的更新,但會救一個人有用的時間。在下面的代碼幫助下,您可以在facebook chatbot上顯示多個按鈕。用於開發的技術是node js,botbuilder,luis。

var msg = new builder.Message(session); 
      msg.sourceEvent({ 
       "facebook": { 
        "attachment": { 
         "type": "template", 
         "payload": { 
          "template_type": "button", 
          "text": "You can either hit 'FAQ' to get the help, or head to the Mannual Help for getting help.", 
          "buttons": [ 
           { 
            "type": "web_url", 
            "url": 'https://stackoverflow.com/', 
            "title": "Mannual Help" 
           }, 
           { 
            "type": "postback", 
            "title": "FAQ", 
            "payload": "FAQ_SELECTED_BY_USER" 
           }] 
         } 
        } 
       } 
      }); 
      session.send(msg); 

enter image description here