Alexa에서 다음을 수행하는 기술을 개발 중입니다.Alexa conversational skill 오류
- 사용자 : 존
- 알렉사 : 안녕 존, 당신을 만나서 좋은 안녕
- 알렉사, 당신의 이름을 나에게
- 사용자를 제공 안녕하세요하시기 바랍니다. 당신에게 몇 살이
- 사용자 : 내 발언은 아래
내 onIntent()StartTheFlow Hi StartTheFlow {custName} StartTheFlow {age}
아래는@Override public SpeechletResponse onIntent(final IntentRequest request, final Session session) throws SpeechletException { log.info("onIntent requestId={}, sessionId={}", request.getRequestId(), session.getSessionId()); Intent intent = request.getIntent(); String intentName = (intent != null) ? intent.getName() : null; if ("StartTheFlow".equals(intentName)) { return getTheFlow(intent, session); } else if ("AMAZON.HelpIntent".equals(intentName)) { return getHelpResponse(); } else if ("WelcomeChubb".equals(intentName)) { return getWelcomeResponse(); } else { throw new SpeechletException("Invalid Intent"); } }
(25)는 내 의도 아래
{
"intents": [
{
"intent": "StartTheFlow",
"slots": [
{
"name": "custName",
"type": "list_of_userNames"
},
{
"name": "age",
"type": "AMAZON.NUMBER"
}
]
},
{
"intent": "AMAZON.HelpIntent"
},{
"intent": "Welcome"
},
{
"intent": "AMAZON.StopIntent"
},
{
"intent": "AMAZON.CancelIntent"
}
]
}
되고있다
그리고 이것을 아래와 같이 처리하려고합니다.
private SpeechletResponse getTheFlow(Intent intent, Session session) {
boolean isAskResponse = true;
String responseText = "";
String nameFromSession = (String) session.getAttribute("name");
if (StringUtils.isNullOrEmpty(nameFromSession)) {
responseText = "please give me your name";
getTheNameText(intent, session);
} else {
System.out.println(session.getAttribute("nameFromSession"));
responseText = "please give me your date of birth";
}
return getSpeechletResponse(responseText, "", isAskResponse);
}
private String getTheNameText(Intent intent, Session session) {
String userNameFrmIntent = getNameFromSlot(intent).toString();
session.setAttribute("nameFromSession", userNameFrmIntent);
return getNameFromSlot(intent).toString();
}
private String getNameFromSlot(Intent intent) {
Slot userName = intent.getSlot(Slot_Name);
return userName.getValue();
}
또한 상단에 다음과 같이 슬롯을 정의했습니다.
private static final String Slot_Name = "custName";
그러나 여기에 내가 대신 나에게 로그에 오류를주고 나에게 내 이름을 묻는, Hi
를 입력 할 때 그것은 자바 NullPointer 예외를 보여줍니다. 내가 Hi
을 입력했을 때받는 응답은 다음과 같습니다. 누군가가이 있으면 알려 주시기 바랍니다 수 있습니다, 누군가가 알려 주시기 바랍니다 수
{
"session": {
"sessionId": "SessionId.a2740ca4-73ff-4a15-856d-6461b3c7b2e1",
"application": {
"applicationId": "amzn1.ask.skill.e3dfb30e-0089-423c-a325-30ad28dd2e2b"
},
"attributes": {},
"user": {
"userId": "amzn1.ask.account.AEQYTT5HFHEGGDSUCT3NW45HKR7O3FBL5YCBSZIS7P5LNP5BXFEMUR7AUYOZVKC2FT5V6RKJC7RNA5VMZVREBAXAQP3NFNTQSFSSKSEXIYT4FQYMS5JCI2CCAOPUF4FN4C6DHEU6ONNY3D6GN5AWK75KOQNJH2IWROIIXTPNXSNI6FLQYRBBMP7TRSOWVNCY73WJUT2VLHDACWA"
},
"new": true
},
"request": {
"type": "IntentRequest",
"requestId": "EdwRequestId.cf686fc0-cbfd-4496-bb09-c41714563507",
"locale": "en-US",
"timestamp": "2017-02-15T20:12:44Z",
"intent": {
"name": "StartTheFlow",
"slots": {
"custName": {
"name": "custName",
"value": "hi"
}
}
}
},
"version": "1.0"
}
어디 내가 잘못 가고 나는이 문제를 해결할 수있는 방법, 나는 25처럼, 아주 질문의 숫자가 링크 될했습니다 자바에서 이것을하는 더 좋은 방법.
감사