echo_stock_price
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
echo_stock_price [2017/05/30 16:43] – tbrodeur | echo_stock_price [2017/05/30 16:48] – tbrodeur | ||
---|---|---|---|
Line 32: | Line 32: | ||
2. <fs large> | 2. <fs large> | ||
+ | <fc #4682b4> | ||
+ | ******The code below is commented out in order to provide you with a better understanding. If you have any further questions, please feel free to contact me at the email listed above.******</ | ||
<code python index.py> | <code python index.py> | ||
Line 291: | Line 293: | ||
<fc #4682b4> | <fc #4682b4> | ||
******Make sure to change the application id listed in lambda_handler() to your own id once you create the Alexa Skill with Alexa Skills Kit******</ | ******Make sure to change the application id listed in lambda_handler() to your own id once you create the Alexa Skill with Alexa Skills Kit******</ | ||
- | |||
- | <color # | ||
- | </ | ||
- | |||
- | |||
- | |||
- | <color # | ||
- | </ | ||
- | |||
- | |||
- | You’ll soon see how to specify the intents for your skill, but first, let’s | ||
- | take a look at the onIntent function to see how Alexa handles | ||
- | the intents. | ||
- | |||
- | <code python> | ||
- | def on_intent(intent_request, | ||
- | intent = intent_request[" | ||
- | intent_name = intent_request[" | ||
- | |||
- | if intent_name == " | ||
- | return say_hello() | ||
- | elif intent_name == " | ||
- | return get_welcome_response() | ||
- | elif intent_name == " | ||
- | return handle_session_end_request() | ||
- | else: | ||
- | raise ValueError(" | ||
- | </ | ||
- | |||
- | As you can see, most of the function is an if..else structure that | ||
- | compares the intent name from the request to a set of intents the | ||
- | skill accepts. Depending on the intent name, it then calls a matching function. | ||
- | |||
- | For example, when Alexa receives a request with the intent name | ||
- | Hello, it calls the corresponding say_hello() function. | ||
- | |||
- | <color # | ||
- | </ | ||
- | |||
- | Looking at the say_hello function, | ||
- | |||
- | <code python> | ||
- | def say_hello(): | ||
- | session_attributes = {} | ||
- | card_title = "Hello World" | ||
- | speech_output = "Hello World" | ||
- | reprompt_text = "" | ||
- | should_end_session = True | ||
- | |||
- | return build_response(session_attributes, | ||
- | card_title, speech_output, | ||
- | </ | ||
- | |||
- | we can see that the function returns a build_response function that will pass arguments defined in the say_hello function. | ||
- | |||
- | -card_title: | ||
- | |||
- | -speech_output: | ||
- | |||
- | -should_end_session: | ||
<color # | <color # |
echo_stock_price.txt · Last modified: 2017/05/30 17:13 by tbrodeur