question

P avatar image
P asked

Slot answer returning undefined when wrong answer is given

Hey all, in my quiz, I'm capturing the users answer with

handlerInput.requestEnvelope.request.intent.slots.answer.resolutions.resolutionsPerAuthority[0].values[0].value.name

and comparing it to an answer set in the sessionAttributes. The problem is that when the wrong answer is given, the request object looks like this, with no values to then compare with my session answer:


"request": {
                "type": "IntentRequest",
                "requestId": "amzn1.echo-api.request.1e4d598d-2cb8-45fa-80d7-4ea75f544401",
                "timestamp": "2020-05-09T15:12:37Z",
                "locale": "en-US",
                "intent": {
                    "name": "AnswerIntent",
                    "confirmationStatus": "NONE",
                    "slots": {
                        "answer": {
                            "name": "answer",
                            "confirmationStatus": "NONE"
                        }
                    }
                }
            }


When you give the correct answer, the slot answer is captured correctly and is able to then be compared with the sessionAttribute value:


"request": {
                "type": "IntentRequest",
                "requestId": "amzn1.echo-api.request.6da39547-7039-49f4-8138-a9105bb6f010",
                "timestamp": "2020-05-09T15:13:10Z",
                "locale": "en-US",
                "intent": {
                    "name": "AnswerIntent",
                    "confirmationStatus": "NONE",
                    "slots": {
                        "answer": {
                            "name": "answer",
                            "value": "project manager",
                            "resolutions": {
                                "resolutionsPerAuthority": [
                                    {
                                        "authority": "amzn1.er-authority.echo-sdk.amzn1.ask.skill.c933b50a-faf5-4f49-8551-838fc1f47fc4.QuizAnswers",
                                        "status": {
                                            "code": "ER_SUCCESS_MATCH"
                                        },
                                        "values": [
                                            {
                                                "value": {
                                                    "name": "Project manager",
                                                    "id": "00f87ea316ec965ecda65285f4e273b6"
                                                }
                                            }
                                        ]
                                    }
                                ]
                            },
                            "confirmationStatus": "NONE",
                            "source": "USER"
                        }
                    }
                }
            }


How can I make it so that I can access the answer no matter if it is correct or incorrect?


Thank you!

alexarequest
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers