用户给出的价值在哪里?

时间:2017-12-26 15:12:24

标签: javascript node.js

首先,我是node.js的初学者,并试图理解:

bot.dialog('askForLocation', [
  function (session, args) {
    if (args && args.reprompt) {
      builder.Prompts.text(session, "Enter a proper location");
    } else {
      builder.Prompts.text(session, "What's your meeting location?");
    }
  },

如何在此代码之后获取用户输入以供日后使用,让我们说用户说california它存储在哪里以及如何在另一个函数中使用它?< / p>

1 个答案:

答案 0 :(得分:1)

这是将prompts数据作为response

获取的正确方法
bot.dialog('askForLocation', [
    // Step 1
    function (session) {
        if (args && args.reprompt) {
          builder.Prompts.text(session, "Enter a proper location");
        } else {
          builder.Prompts.text(session, "What's your meeting location?");
        }
    },
    // Step 2
    function (session, results) {
        session.endDialog(`Hello from location name = ${results.response}!`);
    }
]);

查看更多信息:https://docs.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-dialog-prompt