Thursday, June 22, 2017

Make a first SKILL for Amazon Alexa (day 1)

Python + A.Alexa simple tut



YAML is a data serialisation language designed to be directly writable and readable by humans.
No module named 'flask'
-> check lib to see if flask and flask-ask are installed: python -m pip list
-> For Windows:
python -m pip install flask
python -m pip install flask-ask

Then, install ngrok

=== Documentation for me === 
speech_text = 'Welcome to the Alexa Skills Kit, you can say hello'
--> speech_text: just a variable
return question(speech_text).reprompt(speech_text).simple_card('HelloWorld', speech_text)

question(): keep the current session open and asking the <user>
reprompt(): ask again if <user> did not reply
simple_card(): show text for alexa on android and tablet
statements(): Statements terminate Echo sessions.

Amazon has Standard Built-in Intent 

we can map them:
AMAZON.HelpIntent help me the color of register
AMAZON.HelpIntent how do I pick a register based on color

The skill will be invoked (executed) whenever user ask those two questions or a phrase that contains "help"

=== WHAT IS INTENTS AND SLOTS === (explain for five)

intents > slots > types

sample utterance: predict what user is going to say in order to execute the intent or skill.
Ex: i want to order {food}
We can either use skill buider or mapping method


I'll follow the instruction from the amazon website
Identify the user stories:
- what can a user do?
-- a user can say: stop - stop the game, open 50 states game
- what information is the person expected to have available?
-- names of states in the US
- what are the ways a user can invoke the skill?
-- "let play 50 states", "naming 50 states in the US", "50 states game"
- what features directly support the purpose?
-- Not understand the question
- Is there information that you need from other experiences, for example from website or from a mobile app?
-- yes, just the list of 50 states (saved in listof50states.txt)



Create script:
U(user), A(alexa)
U: alexa, let open 50 states game
A: welcome to naming 50 states game, you can choose single mode or two-players mode.

Single
U: single
A: You're in single mode, say show my score, i'll
tell you the scores you've got. Say stop to end the game.
Now, tell me a valid state in the United States.
U: California
A: That's correct (* optional for further development: tell population and best places to go in <state>), let continue
U: Parris
A: Aww, please try again, that is not a state in US. Correct {counter}, wrong {counter1}(correct:1 wrong:1)
U: stop
A: I hope you've leant something new from this game. Bye.

Two Players Will be developed after Single mode is finished

Develop the flow
Those are not necessary

Get ready to build
- identify intents: intents are the unique things that our skill can do. 
In this case our skill can do: naming 50 states game, stop, and hint.

Sample Utterance field:
AnswerIntent {state}


problem is: I have an array of 50 states 
I want to find if the answer match with one of them.
https://developer.amazon.com/blogs/post/8e8ad73a-99e9-4c0f-a7b3-60f92287b0bf/new-alexa-tutorial-deploy-flask-ask-skills-to-aws-lambda-with-zappa