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].
#requires -version 3 | |
<# | |
.SYNOPSIS | |
PowerShell script for ask-cli's Python-pip code building flow. | |
.DESCRIPTION | |
This is the PowerShell version of the build script, for building the AWS Lambda deployable skill code that is written in Python language. This script is only run by the ask-cli whenever a 'requirements.txt' file is found alongside the skill code. The dependencies are installed using 'pip', and are packaged using 'zip'. | |
.EXAMPLE | |
build.ps1 archive.zip | |
This example showcases how to run the build script, to create an AWS Lambda deployable package called 'archive.zip'. | |
.EXAMPLE |
# -*- 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 |
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].
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 |
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 |
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 |
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 |
## 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", |
#!/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/ | |
# |
git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git
cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream