5
votes

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");
 });
2
What occurs when you send a message to the user's last address? You mentioned there is no error, but the message does not arrive. Do you send a message from WebChat, then (without closing the webchat control) send a proactive message some time later? Or, do you refresh the webchat control before sending the proactive message?Eric Dahlvang
Nothing occurs. Yes, exactly didn't refreshSahar Ben-Shushan
Proactive Messaging works with the WebChat channel. If it isn't working for you, I think you'll need to provide more information so we can help you track down the problem. Do you have ApplicationInsights configured for the bot? Do you see anything there, after attempting to send the proactive message?Eric Dahlvang
Thanks @EricDahlvang, There is ApplicationInsights configured, but there is no errors or anything unusual after sending the proactive message.Sahar Ben-Shushan
Maybe post the code you are using. Otherwise, there's no way to diagnose the problem.Eric Dahlvang

2 Answers

0
votes

Please try changing this line:

let address = {id, channelId, user, conversation, botDetails, serviceUrl};

To this:

let address = {id, channelId, user, conversation, bot: botDetails, serviceUrl};

Also, you're setting the channel to webchat, but using https://directline.botframework.com/ for the service url.

-1
votes

please go to your bot service and look for the Channels Tab, There you are going to see your chatbot opened channels, inspect "issues" link close to Web chat row.