question

newuser-2fe33d2a-0b64-49db-a82c-7083f3e8e82b avatar image

how to handle yes/no intents?

i have a normal question answers skill. This skill lets user ask questions. After every answer, skill asks user if he wants to ask another question. This is done by saying yes/no which takes us to "nextquestionintent" which works fine.But if the user randomly say yes/no in the skill, it still goes to "nextquestionintent".

I know this can be resolved using session attributes, but how do i do that? I have tried looking everywhere for this but no luck. I'm using python. There are many examples with js, but python doesn't have. Please help me. I'm stuck on this from fast 3 days.

alexa skillspythonask sdk
10 |5000

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

1 Answer

KirkC@Amazon avatar image
KirkC@Amazon answered

Hi. If I understand correctly the question at hand is that you know that using session attributes will allow you to address your use case, but need some help adding session attributes using the Python ASK SDK correct? If so, I can certainly help.

The way you would handle is this fairly similar to how you would add a key and value to a dictionary in Python normally. It's just that the dictionary is located at handler_input.attributes_manager.session_attributes. For example, if I wanted to add a key value of "animal" and value of "cat" I would do the following:

handler_input.attributes_manager.session_attributes["animal"] = "cat"

If you want more examples, we have a Python ASK SDK version of our "High Low Game" sample skill which makes use of session attributes as well.

https://github.com/alexa/skill-sample-python-highlowgame

10 |5000

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