I'm using Microsoft Bot Framework, Webchat channel, NodeJS
Also using Bot-Trees to manage my conversations.
How can I send the user proactively messages? I'm saving in my DB the user Address, which includes the user ID, bot ID, conversation ID, etc.
I've tried this solution, sending the last user's address I saved, the request went well without any errors but the messages didn't arrive to the client (webchat).
Any suggestions?
Thanks
The proactive message route, bot-trees project :
var connector = new builder.ChatConnector({
appId: client.id,
appPassword: client.password,
});
var bot = new builder.UniversalBot(connector);
app.post(`/proactiveTest`, (req, res, next) => {
if (!req.query.addressId ||!req.query.userId || !req.query.convId || !req.query.botId){
res.send("Missing params")
}
let channelId = 'webchat';
let id = req.query.addressId;
var user = {id : req.query.userId, name : req.query.userName};
let conversation = {id : req.query.convId};
let botDetails = {id : req.query.botId , name : req.query.botName};
let serviceUrl = "https://directline.botframework.com/";
let address = {id, channelId, user, conversation, botDetails, serviceUrl};
var msg = new builder.Message().address(address);
msg.text("This is a test");
msg.textLocale('en-US');
bot.send(msg);
res.send("Message sent");
});