我正在尝试使用信使平台文档中描述的通用模板在 Facebook 工作平台上发送水平滚动的轮播消息(参考: https ://developers.facebook.com/docs/messenger-platform/reference/template/generic )
我正在使用的模板看起来像这样:
[
{
"text": "Hi!!!!"
},
{
"attachment": {
"type": "template",
"payload": {
"template_type": "generic",
"elements": [
{
"title": "Some Title 1",
"image_url": "some image url",
"buttons": [
{
"title": "button_title1",
"type": "postback",
"payload": "Title 1"
}
]
},
{
"title": "Some Title 2",
"image_url": "some image url",
"buttons": [
{
"title": "button_title2",
"type": "postback",
"payload": "Title 2"
}
]
},{
"title": "Some Title 3",
"image_url": "some image url",
"buttons": [
{
"title": "button_title3",
"type": "postback",
"payload": "Title 3"
}
]
},
]
}
}
}
]
一切都按我的预期工作,但是从过去两周左右开始,轮播元素的顺序(在我的例子中是卡片)不是我所期望的(即 Title1、Title2、Title3)。每次我使用轮播时,轮播中的元素都会以不同的顺序显示。我只是想知道其他人是否有同样的问题,或者它与我的代码有关?
我最后用来发送消息的代码是:
return new Promise((resolve, reject) => {
//(async ref:https://www.npmjs.com/package/async)
async.eachSeries(
//facebookMessages is the message template that I am using(posted above)
facebookMessages,
(msg, callback) => {
//sendFBSenderAction sends the message to FB using api(https://graph.facebook.com/v2.6/me/messages?access_token=<PAGE_ACCESS_TOKEN>)
this.sendFBSenderAction(sender, 'typing_on')
.then(() => this.sleep(this.messagesDelay))
.then(() => {
facebookMessages.attachment ? this.sendFbAttachment(msg) : this.sendFBMessage(sender, msg);
facebookMessages.attachment = false;
})
.then(() => callback())
.catch(callback);
},
err => {
if (err) {
console.error(err);
reject(err);
} else {
console.log('Messages sent');
resolve();
}
}
);
});