2017-05-26 35 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