User Tools

Site Tools


creating_your_own_custom_skill_for_alexa

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Last revisionBoth sides next revision
creating_your_own_custom_skill_for_alexa [2016/12/30 11:27] blakehamentcreating_your_own_custom_skill_for_alexa [2017/01/21 20:26] blakehament
Line 63: Line 63:
    if (event['session']['application']['applicationId'] !=    if (event['session']['application']['applicationId'] !=
    #Change to application id listed under your alexa skill in the developer portal    #Change to application id listed under your alexa skill in the developer portal
-   "amzn1.ask.skill.f976aad9-6567-4a27-8bce-7a0cfe9861e7"):+   "amzn1.ask.skill.<fc #ff0000>f976aad9-6567-4a27-8bce-7a0cfe9861e7</fc>"):
    raise ValueError("Invalid Application ID")    raise ValueError("Invalid Application ID")
  
Line 71: Line 71:
    intent = intent_request["intent"]    intent = intent_request["intent"]
    intent_name = intent_request["intent"]["name"]    intent_name = intent_request["intent"]["name"]
-   if intent_name == "GetCurrentPrice": +   if intent_name == "__<fc #ff0000>GetCurrentPrice</fc>__": 
- return get_current_price(intent) + return <fc #ff0000>get_current_price</fc>(intent) 
-   elif intent_name == "GetHigh": +   elif intent_name == "__<fc #ffa500>GetHigh</fc>__": 
- return get_high(intent) + return <fc #ffa500>get_high</fc>(intent) 
-   elif intent_name == "GetLow": +   elif intent_name == "__<fc #fa8072>GetLow</fc>__": 
- return get_low(intent)+ return <fc #fa8072>get_low</fc>(intent)
    elif intent_name == "AMAZON.HelpIntent":    elif intent_name == "AMAZON.HelpIntent":
  return get_welcome_response()  return get_welcome_response()
Line 84: Line 84:
  raise ValueError("Invalid intent")  raise ValueError("Invalid intent")
  
-Replace or delete the functions relevant to stock tracking with the functions for your custom skill, and rename the intent_name's appropriately.+Replace or delete the <fc #ff0000>fun</fc><fc #ffa500>cti</fc><fc #fa8072>ons</fc> relevant to stock tracking with the functions for your custom skill, and rename the __<fc #ff0000>inte</fc><fc #ffa500>nt_n</fc><fc #fa8072>ame's</fc>__ appropriately.
  
-Look for references to "Stocker" and change to the name of your custom skill+Look for references to "<fc #ff0000>Stocker</fc>" and change to the name of your custom skill
  
   def handle_session_end_request():   def handle_session_end_request():
-   card_title = "Stocker" +   card_title = "<fc #ff0000>Stocker</fc>
-   speech_output = "Im sorry dave. Im afraid I cant do that."+   speech_output = "I'sorry, I'afraid I can'do that."
    should_end_session = True    should_end_session = True
    return build_response({}, build_speechlet_response(card_title, speech_output, None, should_end_session))    return build_response({}, build_speechlet_response(card_title, speech_output, None, should_end_session))
  
-Edit the dialogue so that it suits your user interface needs+Edit the <fc #4682b4>dialogue</fc> so that it suits your user interface needs
  
   def get_welcome_response():   def get_welcome_response():
    #Response to user invoking stock app without parameters/intents    #Response to user invoking stock app without parameters/intents
    session_attributes = {}    session_attributes = {}
-   card_title = "Stocker" +   card_title = "<fc #ff0000>Stocker</fc>
-   speech_output = "Welcome to the Stocker skill. " \ +   speech_output = "Welcome to the <fc #ff0000>Stocker</fc> skill. " \ 
- "You can ask me for current stock prices, or " \ + "<fc #4682b4>You can ask me for current stock prices, or</fc> " \ 
- "ask me about stock highs and lows." + "<fc #4682b4>ask me about stock highs and lows.</fc>
-   reprompt_text = "Please ask me for stock prices, " \ +   reprompt_text = "Please ask me for <fc #4682b4>stock prices,</fc> " \ 
- "for example Apple stock price."+ "for example <fc #4682b4>Apple stock price</fc>."
    should_end_session = False    should_end_session = False
    return build_response(session_attributes, build_speechlet_response(    return build_response(session_attributes, build_speechlet_response(
Line 113: Line 113:
 ===== Final Words ===== ===== Final Words =====
  
-Often it is easier to adapt working code to a new purpose than to write a script from scratch. This method may leave the user lacking important functionality if the code is repurposed for a drastically different skill, so check the resources on the Amazon web developers portal before taking starting an ambitious project.+Often it is easier to adapt working code to a new purpose than to write a script from scratch. This method may leave the user lacking important functionality if the code is repurposed for a drastically different skill, so check the resources on the Amazon web developers [[https://developer.amazon.com/|portal]] before taking starting an ambitious project.
  
  
  
creating_your_own_custom_skill_for_alexa.txt · Last modified: 2017/04/04 09:00 by blakehament