alexa-samples / skill-sample-python-fact-in-skill-purchases

Demonstrates how to use the new in-skill purchasing (ISP) features of Alexa skills by offering different packs of facts behind a purchase, and a subscription to unlock all of the packs at once.
Other
16 stars 13 forks source link

No elif output? & speech format? #9

Closed Daniyaldehleh closed 4 years ago

Daniyaldehleh commented 4 years ago

Hi All! In line 699 it doesn't mention what to be returned if elif ...?

and also its written

speech=("Thanks for your interest in {}.  "
                              "Would you like another random fact?".format(
                                  product[0].name))

isn't that not a right way to output a text an instead you should say something like: return handler_input.response_builder.speak() Also I am not sure why line 162 & 163 has parentheses? also is line 918 comma on purpose or mistake?

Daniyaldehleh commented 4 years ago

lastly, this project uses ask-cli v1. However, everything is v2 now. Is there a way to upgrade the skill to v2?

nikhilym commented 4 years ago

In line 699 it doesn't mention what to be returned if elif ...?

Hey @danieldhz , you are in-fact right that one need to use handler_input.response_builder.speak() to set the speech responses on the alexa response. However, Line 699's condition is part of a longer if-else loop , and is mainly for setting up the speech and reprompt variables. Once the processing is done, the response is sent here. Hope that clarifies your first question.

Also I am not sure why line 162 & 163 has parentheses?

The parentheses on these lines are purely for splitting the condition, so that the written python code follows the suggested line length in PEP 008 style guide. Without the parentheses, one would need to add a backslash in the code and it might look ugly.

also is line 918 comma on purpose or mistake?

I don't think it makes a difference. Do you find the code to fail with that comma present?

lastly, this project uses ask-cli v1. However, everything is v2 now. Is there a way to upgrade the skill to v2?

At the time this skill sample was written, there was no ASK CLI v2. You should be able to follow the migration guide to convert this to a v2 project. If you are interested, please send out a PR for this sample with the structure migrated to v2 CLI and we will be happy to review. Thanks.

Closing this issue. Please let us know if you still have problems.