为了在关闭24小时后发送FB Messenger消息
此文档:https://developers.facebook.com/docs/messenger-platform/send-messages/message-tags
此代码:
const { ActivityTypes, BotFrameworkAdapter } = require('botbuilder');
const adapter = new BotFrameworkAdapter({
appId: process.env.MicrosoftAppId,
appPassword: process.env.MicrosoftAppPassword
});
module.exports = async function (context, req) {
if (!req.body) {
context.res = {
status: 400,
body: "Please pass a conversation reference in the request body"
};
return;
}
var msg = { type: ActivityTypes.Message };
msg.text = "hello"
const conversationReference = req.body;
await adapter.continueConversation(conversationReference, async turnContext => {
await turnContext.sendActivity(msg);
});
context.res = {
body: 'Message sent!'
};
};
我正在尝试添加消息标签并尝试过:
msg.sourceEvent({
facebook: {
messaging_type: 'MESSAGE_TAG',
tag: 'ACCOUNT_UPDATE'
}
});
但是我得到msg.sourceEvent不是一个函数。并且:
msg.messaging_type = 'MESSAGE_TAG';
msg.tag = 'ACCOUNT_UPDATE';
这不起作用,并且继续进行失败的保存行为,是您在24小时窗口之外发送消息。
有人知道如何进行这项工作吗?
可以通过使用活动对象的implement channel-specific functionality属性来channelData
。
await turnContext.sendActivity({
text: 'Hello!',
channelData: {
messaging_type: 'MESSAGE_TAG',
tag: 'ACCOUNT_UPDATE'
}
});