видеть, что

даю пример приложения, используя Watson разговор API в nodejs. Я пытаюсь получить имя пользователя и отправить его Уотсону, а затем хочу сказать привет «$ username», также я хочу сохранить это на протяжении всего разговора, чтобы я мог, если пользователь спросит, помню ли я имя, Уотсон может сказать "да," $ username "".

Может кто-нибудь помочь мне с примером кода, как использовать намерение в этом случае использования.

    // Start conversation with Hello message.
conversation.message({
  input: { text: "Hello" },
    }, processResponse);

// Process the conversation response.
function processResponse(err, response) {
  if (err) {
    console.error(err); // something went wrong
    return;
  }

  // If an intent was detected, log it out to the console.
  if (response.intents.length > 0) {
    //console.log('Detected intent: #' + response.intents[0].intent);
    console.log(response.context)
  }

  // Display the output from dialog, if any.
  if (response.output.text.length != 0) {
      console.log("Watson : "+response.output.text[0]);
  }

  // Prompt for the next round of input.
    var newMessageFromUser = prompt('Me : ');
    // Send back the context to maintain state.
    conversation.message({
      input: { text: newMessageFromUser },
      context : response.context,
    }, processResponse)
}

Ответы на вопрос(1)

Ваш ответ на вопрос