ここに解決策があります。
おそらく、インテント・スキーマでこれを完了したくないかもしれません。代わりに、文字、数字、記号を1つのレスポンスにコンパイルするNode.jsを使用してカスタムモードを作成してみてください。これは、アルファベットの入力モードの私の演出です。注:私はあなたの質問に答えてこれを書いただけで、より大きなスキルでそれをテストしていません。それで私はMODES
で大成功を収めましたが、チャンスがあるときは確かに自分のスキルでこれを実装します。
このコードの背後にあるアイデアは、ユーザをNumberIntent
、LetterIntent
、SymbolIntent
以外のすべてのインテントと、いくつかのヘルプ機能を無視する別のモードにプッシュすることです。ユーザーはすぐにアルファ数値を入力し、完了するとCompletedIntentをアクティブにします。その英数字の値は、スキルの他の場所でも使用できます。 Modes
を使用していない場合は、終了時または終了時にLOBBYMODE
にリダイレクトされ、スキルの他のインテントに引き続きアクセスできます。
var lobbyHandlers = Alexa.CreateStateHandler(states.LOBBYMODE, {
'enterPasswordIntent': function() {
this.attributes['BUILDPASSWORD'] = '';
this.handler.state = states.PASSWORDMODE;
message = ` You will now create a password one letter, number or symbol at a time. there will be no message after each entry. simply wait for alexa's ring to become solid blue then stay your next value. When you are satisfied say complete. Begin now by saying a number, letter, or keyboard symbol. `;
reprompt = `Please say a number letter or symbol`;
this.emit(':ask', message, reprompt);
},
//Place other useful intents for your Skill here
'Unhandled': function() {
console.log("UNHANDLED");
var reprompt = ` You're kind of in the middle of something. Say exit to end createing this password. otherwise say complete if you've stated the whole password. or repeat to hear the current password you've entered. `;
this.emit(':ask', reprompt, reprompt);
}
});
var buildAlphaNumericPasswordHandlers = Alexa.CreateStateHandler(states.PASSWORDMODE, {
'numberIntent': function() {// Sample Utterance: ninty nine AMAZON.NUMBER
var number = this.event.request.intent.slots.number.value; //I believe this returns a string of digits ex: '999'
this.attributes['BUILDPASSWORD'] = this.attributes['BUILDPASSWORD'].concat(number);
message = ``; //No message to make saying the next letter, number or symbol as fluid as possible.
reprompt = `Please say the next number letter or symbol`;
this.emit(':ask', message, reprompt);
},
'letterIntent': function() {// Sample Utterance: A -- Custom Slot LETTERS [A, b, c, d, e, ... ]
var letter = this.event.request.intent.slots.letter.value;
this.attributes['BUILDPASSWORD'] = this.attributes['BUILDPASSWORD'].concat(letter);
message = ``; //No message to make saying the next letter, number or symbol as fluid as possible.
reprompt = `Please say the next number letter or symbol`;
this.emit(':ask', message, reprompt);
},
'symbolIntent': function() {// Sample Utterance: Dash -- Custom Slot SYMBOLS [Pound, Dash, Dollar Sign, At, Exclamation point... ]
var symbol = this.event.request.intent.slots.symbol.value;
// Create a dictionary object to map words to symbols ex Dollar Sign => $. Will need this because you likely cant put $ as a custom slot value. Can also map multiple names to the same value ex. Dash => Tack = \> "-"
var singleCharacterSymbol = symbolDict[symbol]; //^^^ Need to create dictionary
this.attributes['BUILDPASSWORD'] = this.attributes['BUILDPASSWORD'].concat(singleCharacterSymbol);
message = ``; //No message to make saying the next letter, number or symbol as fluid as possible.
reprompt = `Please say the next number letter or symbol`;
this.emit(':ask', message, reprompt);
},
'CompleteIntent': function() { //Sample Utterance: Complete
console.log("COMPLETE");
this.handler.state = states.LOBBYMODE;
var reprompt = ` Your entry has been saved, used to execute another function or checked against our database. `;
this.emit(':ask', reprompt, reprompt);
},
'ExitIntent': function() { //Sample Utterance: Exit
console.log("EXIT");
this.handler.state = states.LOBBYMODE;
message = `You have returned to the lobby, continue with the app or say quit to exit.`;
this.emit(':ask', message, message);
},
'RepeatIntent': function() {
var currentPassword = this.attributes['BUILDPASSWORD'];
var currentPasswordExploded = currentPassword.replace(/(.)(?=.)/g, "$1 "); //insert a space between each character so alexa reads correctly.
var message = ` Your current entry is as follows. `+currentPasswordExploded;
var reprompt = ` say complete if you've stated the whole password. Otherwise continue to say numbers letters and symbols. `;
this.emit(':ask', reprompt, reprompt);
},
'Unhandled': function() {
console.log("UNHANDLED");
var reprompt = ` You're kind of in the middle of something. Say exit to end creating this password, say complete if you've stated the whole password, say repeat to hear the current password you've entered, or continue to state letters, numbers and symbols `;
this.emit(':ask', reprompt, reprompt);
}
});
こんにちはサティシュ、あなたはまだこの1つを把握しましたか? – Kal