Skip to content

Instantly share code, notes, and snippets.

@mvc1009
Created December 29, 2023 02:19
Show Gist options
  • Save mvc1009/68285bfc3a9649be46a07f86a37d7518 to your computer and use it in GitHub Desktop.
Save mvc1009/68285bfc3a9649be46a07f86a37d7518 to your computer and use it in GitHub Desktop.
Alexa skill HTTP GET
import logging
import ask_sdk_core.utils as ask_utils
import requests
from ask_sdk_core.skill_builder import SkillBuilder
from ask_sdk_core.dispatch_components import AbstractRequestHandler
from ask_sdk_core.dispatch_components import AbstractExceptionHandler
from ask_sdk_core.handler_input import HandlerInput
from ask_sdk_model import Response
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
class LaunchRequestHandler(AbstractRequestHandler):
"""Handler for Skill Launch."""
def can_handle(self, handler_input):
# type: (HandlerInput) -> bool
#test
return ask_utils.is_request_type("LaunchRequest")(handler_input)
def handle(self, handler_input):
# type: (HandlerInput) -> Response
speak_output = "Vale"
requests.get('https://api.myserver.com/test?v1=1')
return (
handler_input.response_builder
.speak(speak_output)
#.ask(speak_output)
.response
)
# The SkillBuilder object acts as the entry point for your skill, routing all request and response
# payloads to the handlers above. Make sure any new handlers or interceptors you've
# defined are included below. The order matters - they're processed top to bottom.
sb = SkillBuilder()
sb.add_request_handler(LaunchRequestHandler())
lambda_handler = sb.lambda_handler()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment