Alexa Skills Dialog Management : 발화를 다시 지정하지 않고 마지막 의도를 반복하는 방법
저는 첫 번째 Alexa 기술을 개발 중이며 대화 관리를 개선하려고합니다.
내 기술에는 몇 가지 의도가 있습니다. 하나는 실내 온도를 얻고 하나는 습도를 얻는 것입니다.
모든 인 텐트에는 내 집의 바닥 / 방을 나타내는 하나의 슬롯이 있으므로 Alexa에 대한 일반적인 질문은 "1 층의 온도는?"입니다.
인 텐트가 실행될 때마다 세션 속성에 슬롯이 저장되므로 다음과 같은 대화를 처리 할 수 있습니다.
나 : "Alexa 1 층 온도는 어때?"
Alexa : "1 층 온도는 24도"
나 : "습도?"
Alexa : "1 층의 습도는 50 %입니다."
구현하려는 다음 단계는 다음과 같은 유형의 대화입니다.
나 : "Alexa 1 층의 온도는?"
Alexa : "1 층 온도는 24도"
나 : "2 층은?"
Alexa : "2 층 온도는 26 도입니다."
실제로는 발화를 말하지 않고 마지막으로 실행 된 인 텐트를 시작해야합니다.
슬롯 만 수신 한 다음 마지막으로 실행 된 인 텐트로 요청을 전달하는 새로운 일반 인 텐트를 만들 생각 중이었습니다.
세션 속성에 ID를 저장하여 실행 된 마지막 인 텐트를 추적 할 수 있습니다.
이 작업을 수행하는 더 좋은 방법이 있습니까?
지난 월요일부터 Alexa 기술을 개발하고 있기 때문에 모든 제안을 환영합니다! :-)
감사합니다.
답변
당신은 올바른 길을 가고 있습니다. 기억해야 할 것은 여러 슬롯에 대해 하나의 인 텐트를 가질 수 있으며 모두를 요구하지 않는다는 것입니다.
모든 것에 대한 단일 인 텐트를 만드는 방법은 다음과 같습니다.

How are things on the {floor}
And on the {floor}
What is the {condition}
What is the {condition} on the {floor}
그런 다음 "조건"및 "바닥"슬롯 유형을 작성하여 조건에 대한 "온도"및 바닥에 대한 "1 층"과 같은 적절한 샘플 값으로 채 웁니다. 그런 다음 해당 슬롯 유형을 인 텐트의 슬롯에 할당해야합니다.
그러면 핸들러 코드는 다음과 같습니다.
const conditionIntentHandler = {
canHandle(handlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'conditionIntent';
},
handle(handlerInput) {
var speakOutput = "";
var condition = "";
var floor = "";
const attributesManager = handlerInput.attributesManager;
const attributes = attributesManager.getSessionAttributes();
if (handlerInput.requestEnvelope.request.intent.slots.condition.hasOwnProperty('value')) {
condition = handlerInput.requestEnvelope.request.intent.slots.condition.value;
} else if (attributes.hasOwnProperty('condition')) {
if(attributes.condition !== "") condition = attributes.condition;
}
if (handlerInput.requestEnvelope.request.intent.slots.floor.hasOwnProperty('value')) {
floor = handlerInput.requestEnvelope.request.intent.slots.floor.value;
} else if (attributes.hasOwnProperty('floor')) {
if(attributes.floor !== "") floor = attributes.floor;
}
if (floor !== "" && condition === ""){
speakOutput = "Here's the conditions for the " + floor;
} else if (floor === "" && condition !== ""){
speakOutput = "Here's the " + condition + " throughout the house";
} else if (floor !== "" && condition !== ""){
speakOutput = "Here's the " + condition + " on the " + floor;
} else {
speakOutput = "I have no idea what you're saying. Are you okay?"
}
attributes.floor = floor;
attributes.condition = condition;
attributesManager.setSessionAttributes(attributes);
return handlerInput.responseBuilder
.speak(speakOutput)
.reprompt('What else can I tell you?')
.getResponse();
}
};
값을 표시하는 실제 코드를 작성하지 않았고 자리 표시 자 응답 만 있지만 아이디어를 얻어야합니다. 사람들이이 정보를 요청할 수있는 더 많은 방법으로이 핸들을 만들려면 하나 또는 두 슬롯 유형을 모두 포함하는 더 많은 캐리어 문구를 추가하세요.
