我正在使用v4的bot框架构建bot。我有功能在频道内共享英雄卡。即如果机器人部署在Facebook,我们也需要在Skype的联系人内共享。我怎样才能做到这一点?
提前致谢。
通过Skype发送的任何卡已经具有转发给其他用户的功能。用户所要做的就是按下卡侧面显示的前进按钮。但是,Skype不支持直接在卡上添加共享按钮。
您必须通过活动的频道数据发送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"
}]
}
]
}
}
}
});
希望这可以帮助!