This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env/python | |
# | |
# More of a reference of using jinaj2 without actual template files. | |
# This is great for a simple output transformation to standard out. | |
# | |
# Of course you will need to "sudo pip install jinja2" first! | |
# | |
# I like to refer to the following to remember how to use jinja2 :) | |
# http://jinja.pocoo.org/docs/templates/ | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Example directive, from https://developer.amazon.com/docs/custom-skills/dialog-interface-reference.html#elicitslot | |
from ask_sdk_model.dialog import ElicitSlotDirective | |
from ask_sdk_model import ( | |
Intent, IntentConfirmationStatus, Slot, SlotConfirmationStatus) | |
directive = ElicitSlotDirective( | |
slot_to_elicit="fromCity", | |
updated_intent=Intent( | |
name="planMyTrip", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ask_sdk_core.skill_builder import CustomSkillBuilder | |
from ask_sdk_core.api_client import DefaultApiClient | |
from ask_sdk_core.dispatch_components import AbstractRequestHandler | |
from ask_sdk_core.dispatch_components import AbstractExceptionHandler | |
from ask_sdk_core.utils import is_request_type, is_intent_name | |
from ask_sdk_model.ui import SimpleCard | |
from ask_sdk_model.services.directive import ( | |
SendDirectiveRequest, Header, SpeakDirective) | |
from ask_sdk_core.handler_input import HandlerInput | |
from ask_sdk_model.response import Response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_display_supported(handler_input): | |
# type: (HandlerInput) -> bool | |
"""Check if display is supported by the skill.""" | |
try: | |
if hasattr(handler_input.request_envelope.context.system.device.supported_interfaces, 'display'): | |
return handler_input.request_envelope.context.system.device.supported_interfaces.display is not None | |
except: | |
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ask_sdk_core.dispatch_components import AbstractRequestHandler | |
from ask_sdk_core.handler_input import HandlerInput | |
from ask_sdk_core.utils import is_intent_name | |
from ask_sdk_core.response_helper import get_plain_text_content | |
from ask_sdk_model.response import Response | |
from ask_sdk_model.interfaces.display import ( | |
ImageInstance, Image, RenderTemplateDirective, | |
BackButtonBehavior, BodyTemplate2) | |
from ask_sdk_model import ui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ask_sdk_core.dispatch_components import AbstractRequestHandler | |
from ask_sdk_core.utils import is_intent_name | |
from ask_sdk_core.handler_input import HandlerInput | |
from ask_sdk_model.response import Response | |
from ask_sdk_model.ui import StandardCard, Image, SimpleCard | |
from ask_sdk_model.interfaces.audioplayer import ( | |
PlayDirective, PlayBehavior, AudioItem, Stream, AudioItemMetadata, | |
StopDirective) | |
from ask_sdk_model.interfaces import display |
NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.
If you are not into long explanations, see [Paolo Bergantino’s answer][2].
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# This is a skill for getting device location. | |
import logging | |
from ask_sdk_core.skill_builder import CustomSkillBuilder | |
from ask_sdk_core.api_client import DefaultApiClient | |
from ask_sdk_core.dispatch_components import AbstractRequestHandler | |
from ask_sdk_core.dispatch_components import AbstractExceptionHandler |
OlderNewer