Bot Framework v4英雄卡共享按钮

时间:2019-02-21 16:39:36

标签: c# botframework facebook-messenger-bot skype-bots

我正在使用Bot框架v4构建Bot。我具有在频道内共享英雄卡的功能。即如果该机器人已部署在Facebook中,我们也需要在Skype的联系人中共享该机器人。我该如何实现?

Desired output like this

谢谢。

1 个答案:

答案 0 :(得分:0)

Skype

通过Skype发送的任何卡已经具有可以转发给其他用户的功​​能。用户要做的就是按下显示在卡侧面的前进按钮。但是,Skype不支持直接在卡上添加共享按钮。

enter image description here

Facebook

您必须通过活动的频道数据发送Messenger Template才能包括Facebook Messenger上的共享功能。在模板的元素中,您必须添加一个类型为element_share的按钮。请参见下面的示例。

await turnContext.sendActivity({
  channelData: {
    "attachment": {
      "type": "template",
      "payload": {
        "template_type": "generic",
        "elements": [
          {
            "title": "Three Strategies for Finding Snow",
            "subtitle": "How do you plan a ski trip to ensure the best conditions? You can think about a resort’s track record, or which have the best snow-making machines. Or you can gamble.",
            "image_url": "https://static01.nyt.com/images/2019/02/10/travel/03update-snowfall2/03update-snowfall2-jumbo.jpg?quality=90&auto=webp",
            "default_action": {
              "type": "web_url",
              "url": "https://www.nytimes.com/2019/02/08/travel/ski-resort-snow-conditions.html",
              "messenger_extensions": false,
              "webview_height_ratio": "tall"
            },
            "buttons": [{
              "type":"element_share"
            }]
          }
        ]
      }
    }
  }
});

enter image description here

希望这会有所帮助!