gpt4 book ai didi

node.js - 使用Bot框架node.js V4的FB列表模板

转载 作者:太空宇宙 更新时间:2023-11-03 23:16:37 25 4
gpt4 key购买 nike

任何人都可以帮助我使用 Bot 框架在 Facebook channel 中包含 ListView 吗?我看到了如下所示的示例 List template 。我不知道这是否是我们需要提供附件的确切方式。我也不知道 Bot 框架 v4 中的 sourceEvent 方法的等效项。另一个有用的链接如下FB Messenger Message Template 。请参见下面给出的图像。我需要放置图像的链接,一旦我们单击该链接,它应该打开另一个页面,并且该图像应该是可单击的图像,如 C# Clickable HeroCard images 的示例中所示。使用点击属性。这两个功能都应该有效。我尝试使用HeroCard(但是需要打开的网址有CORS起源问题。我尝试使用Adaptive卡,但目前Facebook不支持它。所以,我想使用Facebook的列表模板。有没有办法实现这一点?

This is the actual requirement.

最佳答案

您可以通过 Microsoft BotFramework 将 Facebook 附件添加到事件的 channel 数据来发送 Facebook 列表模板。似乎不支持 list 模板类型,但您可以将类型设置为 generic 并向附件添加多个元素以获得相同的结果。请参阅下面的示例。

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"
}]
},
{
"title": "Viewing the Northern Lights: ‘It’s Almost Like Heavenly Visual Music’",
"subtitle": "Seeing the aurora borealis has become a must-do item for camera-toting tourists from Alaska to Greenland to Scandinavia. On a trip to northern Sweden, the sight proved elusive, if ultimately rewarding.",
"image_url": "https://static01.nyt.com/images/2019/02/17/travel/17Northern-Lights1/17Northern-Lights1-superJumbo.jpg?quality=90&auto=webp",
"default_action": {
"type": "web_url",
"url": "https://www.nytimes.com/2019/02/11/travel/northern-lights-tourism-in-sweden.html",
"messenger_extensions": false,
"webview_height_ratio": "tall"
},
"buttons": [{
"type":"element_share"
}]
},
{
"title": "Five Places to Visit in New Orleans",
"subtitle": "Big Freedia’s rap music is a part of the ether of modern New Orleans. So what better authentic travel guide to the city that so many tourists love to visit?",
"image_url": "https://static01.nyt.com/images/2019/02/17/travel/17NewOrleans-5Places6/17NewOrleans-5Places6-jumbo.jpg?quality=90&auto=webp",
"default_action": {
"type": "web_url",
"url": "https://www.nytimes.com/2019/02/12/travel/big-freedia-five-places-to-eat-and-visit-in-new-orleans.html",
"messenger_extensions": false,
"webview_height_ratio": "tall"
},
"buttons": [{
"type":"element_share"
}]
}]
}
}
}
});

希望这有帮助!

关于node.js - 使用Bot框架node.js V4的FB列表模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54663088/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com