Amazon Echo のプログラミングは初めてです。私は Node.js を使用しており、名前の発話に基づいて別の応答を返そうとしています。
たとえば、「David」、「James」、または「Benjy」という名前を言うと、Alexa は「Welcome [and the name I said]」とだけ言う必要がありますが、「Jonathan」と言うと、「Yay! Welcome home Jonathan」と言う必要があります。
しかし、「ジョナサン」と言うと、「ようこそジョナサン」とだけ言われます。
基本的な alexa-skills-kit-color-expert Lambda を変更し、そのコードの setColorInSession() 関数を変更しました。その関数の名前を setAndWelcomePerson() に変更しました。
私が試してみました:
- if ステートメントを使用して発話をテストし、発話に基づいて Alexa に応答させる
- 発話のさまざまな例を示して、Alexa にある名前と次の名前を区別するように教えようとします。
これはどれもうまくいかないようです。私が間違っていることと修正するための提案を教えてください。以下のコード:
私の Lambda コードからの setAndWelcomePerson() 関数:
/**
* Sets the name of the person(s) and welcomes them.
*/
function setAndWelcomePerson(intent, session, callback) {
var cardTitle = intent.name;
var whoToGreetSlot = intent.slots.Person;
var repromptText = null;
var sessionAttributes = {};
var shouldEndSession = false;
var speechOutput = "";
if (whoToGreetSlot) {
var whoToGreet = whoToGreetSlot.value;
sessionAttributes = createWhoToGreetAttributes(whoToGreet);
if (whoToGreet === "Jonathan") {
speechOutput = "Yay! Welcome home " + whoToGreet + "!";
} else {
speechOutput = "Welcome " + whoToGreet + ".";
}
} else {
speechOutput = "I'm not sure who you want me to welcome. Please try again.";
}
callback(sessionAttributes,
buildSpeechletResponse(cardTitle, speechOutput, repromptText, shouldEndSession));
}
私の意図スキーマ:
{
"intents": [
{
"intent": "WhoShouldBeGreeted",
"slots": [
{
"name": "Person",
"type": "LITERAL"
}
]
},
{
"intent": "AdditionalGreetingRequest",
"slots": []
}
]
}
私のサンプル発話:
WhoShouldBeGreeted {Sam and Cat|Person}
WhoShouldBeGreeted {Jonathan|Person}
WhoShouldBeGreeted {James|Person}
WhoShouldBeGreeted {Benji|Person}
WhoShouldBeGreeted welcome {Sam and Cat|Person}
WhoShouldBeGreeted welcome {Jonathan|Person}
WhoShouldBeGreeted welcome {James|Person}
WhoShouldBeGreeted welcome {Benji|Person}
ご協力ありがとうございました。