在初始调用后,我无法让 getRawInput() 方法捕获用户输入。我希望用户选择并采取行动,然后助手回答一个问题,用户必须回答这个问题才能继续前进。例如,用户想要从支票账户向储蓄账户转账时会说“我想要转账”。助手会问“你想从哪个账户转账”。用户将使用他们想要从中转移的帐户进行响应。问题似乎是助手没有接受第二个输入,并且我收到错误“操作:{我的操作名称}现在没有响应。请稍后再试。” 请让我知道是否有更好的方法或更合适的方法来调用在线对话。
这是我要执行的代码:
else if (assistant.getRawInput() === 'I want to make a transfer') {
let inputPrompt = assistant.buildInputPrompt(true, 'Sure, which account would you like to transfer from? You can say checking or savings.');
assistant.ask(inputPrompt);
if(assistant.getRawInput() === 'checking') {
let transFrom = 'checking';
let transTo = 'savings';
let inputPrompt = assistant.buildInputPrompt(true, 'You are going to make a transfer from your ' + transFrom + ' account to your ' + transTo + ' account. What is the amount you would like to transfer?');
assistant.ask(inputPrompt);
let amtInput = assistant.getRawInput();
let amt = parseInt(amtInput);
transferMoney(transFrom, transTo, amt);
inputPrompt = assistant.buildInputPrompt(true, 'Cool, you have transfered ' + amt + ' dollars from your ' + transFrom + ' account to your ' + transTo + ' account. Your new balance is ' + customer1.chkBal + ' dollars in your ' + transFrom + ' account and ' + customer1.savBal + ' in your ' + transTo + ' account.');
assistant.ask(inputPrompt);
} else if (assistant.getRawInput() === 'savings') {
let transFrom = 'savings';
let transTo = 'checking';
let inputPrompt = assistant.buildInputPrompt(true, 'You are going to make a transfer from your ' + transFrom + ' account to your ' + transTo + ' account. What is the amount you would like to transfer?');
assistant.ask(inputPrompt);
let amtInput = assistant.getRawInput();
let amt = parseInt(amtInput);
transferMoney(transFrom, transTo, amt);
inputPrompt = assistant.buildInputPrompt(true, 'Cool, you have transfered ' + amt + ' dollars from your ' + transFrom + ' account to your ' + transTo + ' account. Your new balance is ' + customer1.chkBal + ' dollars in your ' + transFrom +' account and ' + customer1.savBal + ' in your ' + transTo + ' account.');
assistant.ask(inputPrompt);
}