我可以通过 botframework 向 facebook messenger 用户发送主动消息的小时数或天数范围是多少?
NodeJS SDK - botbuilder 3.14 版
我正在使用下面的代码示例
// send simple notification
function sendProactiveMessage(address) {
var msg = new builder.Message().address(address);
msg.text('Hello, this is a notification');
msg.textLocale('en-US');
bot.send(msg);
}
var savedAddress;
server.post('/api/messages', connector.listen());
// Do GET this endpoint to delivey a notification
server.get('/api/CustomWebApi', (req, res, next) => {
sendProactiveMessage(savedAddress);
res.send('triggered');
next();
}
);
// root dialog
bot.dialog('/', function(session, args) {
savedAddress = session.message.address;
var message = 'Hello! In a few seconds I\'ll send you a message proactively to demonstrate how bots can initiate messages.';
session.send(message);
message = 'You can also make me send a message by accessing: ';
message += 'http://localhost:' + server.address().port + '/api/CustomWebApi';
session.send(message);
setTimeout(() => {
sendProactiveMessage(savedAddress);
}, 5000);
});