简体   繁体   English

如何在 Microsoft Bot Framework v.3 (Node.js) 中发送欢迎消息并自动加载特定对话框?

[英]How to send welcome message AND load a specific dialog automatically in Microsoft Bot Framework v.3 (Node.js)?

I'm trying both to show a welcome message when my bot starts up and also load a specific dialog.我正在尝试在我的机器人启动时显示欢迎消息并加载特定对话框。 We are using version 3 in the company where I'm working (I know, it's old and not supported).我们在我工作的公司中使用第 3 版(我知道,它很旧且不受支持)。

As far as the welcome message, https://docs.microsoft.com/en-us/azure/bot-service/nodejs/bot-builder-nodejs-handle-conversation-events?view=azure-bot-service-3.0 says to use on conversationUpdate , which works fine, but this seems to be contradicted by https://blog.botframework.com/2018/07/12/how-to-properly-send-a-greeting-message-and-common-issues-from-customers/ , which suggests one should not use conversationUpdate , except when using DirectLine, but instead send an event.至于欢迎消息, https://docs.microsoft.com/en-us/azure/bot-service/nodejs/bot-builder-nodejs-handle-conversation-events?view=azure-bot-service-3.0说要on conversationUpdate上使用,效果很好,但这似乎与https://blog.botframework.com/2018/07/12/how-to-properly-send-a-greeting-message-and-common相矛盾-issues-from-customers/ ,这表明不应使用conversationUpdate ,除非使用 DirectLine,而是发送事件。 Is this the final word on the matter?这是对此事的最终决定吗? Is there a better way?有没有更好的办法?

I'd also like to load a dialog automatically after the welcome message.我还想在欢迎消息之后自动加载一个对话框。 How do I do this?我该怎么做呢? Can I access the session during the 'on conversationUpdate' event above and load the dialog directly there?我可以在上面的“on conversationUpdate”事件期间访问 session 并直接在那里加载对话框吗? Is there a better way?有没有更好的办法?

Thanks for any help!谢谢你的帮助!

It is contradictory, but conversationUpdate is likely your best bet in most situations.这是矛盾的,但在大多数情况下, conversationUpdate可能是您最好的选择。 However, because channels handle this differently, you should be aware that the result can vary.但是,由于渠道对此的处理方式不同,因此您应该知道结果可能会有所不同。 For direct line, it is a better option to utilize sending events.对于直线,使用发送事件是一个更好的选择。

An example, in case of need:一个例子,以备不时之需:

bot.on('conversationUpdate', function(message) {
  if (message.membersAdded) {
    message.membersAdded.forEach(function(identity) {
      if (identity.id === message.address.bot.id) {
        var reply = new builder.Message()
          .address(message.address)
          .text("Welcome");
        bot.send(reply);
      }
    });
  }
});

For immediately calling a specific dialog, do this:要立即调用特定对话框,请执行以下操作:

bot.on('conversationUpdate', function (message) {
  if (message.membersAdded) {
    message.membersAdded.forEach(function (identity) {
      if (identity.id === message.address.bot.id) {
        bot.beginDialog(message.address, '/main');
      }
    });
  }
});

bot.dialog('/main', [
  function (session, args, next) {
    session.send("Glad you could join.");
    session.beginDialog('/next');
  }
]);

Simply combine the two for sending the welcome message and starting up a dialog.只需将两者结合起来发送欢迎消息并启动对话。

Hope of help!希望有帮助!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Microsoft Azure Bot Framework SDK 4:使用Node js从机器人向特定用户发送主动消息 - Microsoft Azure Bot Framework SDK 4: Send proactive message to specific users from bot using Node js 在Microsoft Bot Framework(Node.js)中的对话框之间切换 - Switches between Dialog in Microsoft Bot Framework (Node.js) MS Bot Framework V4-Node.js 中的对话中断 - Dialog interruptions in MS Bot Framework V4- Node.js 什么决定了“bot.dialog”何时传递到 Microsoft Bot Framework 中瀑布的下一个 function? (Node.js) - What determines when 'bot.dialog' passes to the next function of the waterfall in Microsoft Bot Framework? (Node.js) 如何在Microsoft Bot Framework的node.js版本中“退出”? - How to 'exit' in the node.js version of Microsoft Bot Framework? Node.js:如何使用 MS Bot Framework 在 Slack 中发送直接消息? - Node.js: How to send a direct message in Slack with MS Bot Framework? 欢迎消息 Bot Framework v4 nodejs - Welcome message Bot Framework v4 nodejs BotBuilder for Node.js v3和Microsoft Bot Framework:如何远程触发与用户的新对话的开始? - BotBuilder for Node.js v3 & Microsoft Bot Framework: How do I remotely trigger the start of a new conversation with a user? 在基于 botframework v4 的 node.js bot 中将对话框中的消息数据记录到 Application Insights - Logging message data from a dialog to Application Insights in node.js bot based on botframework v4 Microsoft Bot Framework-无法发送消息并结束对话框 - Microsoft Bot Framework - Can't send a message and end dialog
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM