aws-toolkit-jetbrains icon indicating copy to clipboard operation
aws-toolkit-jetbrains copied to clipboard

Cannot create lambda function that is an Alexa Skill backend

Open gamename opened this issue 1 year ago • 0 comments

Here is an example Alexa Skill lambda definition (below). I put it into a file called lambda.py and tried to create a new function on AWS:

from ask_sdk_core.skill_builder import SkillBuilder
from ask_sdk_core.dispatch_components import AbstractRequestHandler
from ask_sdk_core.utils import is_request_type, is_intent_name

class LaunchRequestHandler(AbstractRequestHandler):
    """Handles LaunchRequest requests sent by Alexa"""
    def can_handle(self, handler_input):
        return is_request_type("LaunchRequest")(handler_input)

    def handle(self, handler_input):
        speech_text = "Welcome to the Alexa skill!"
        return handler_input.response_builder.speak(speech_text).ask(speech_text).response

class CustomIntentHandler(AbstractRequestHandler):
    """Handles CustomIntent intents"""
    def can_handle(self, handler_input):
        return is_intent_name("CustomIntent")(handler_input)

    def handle(self, handler_input):
        speech_text = "Handling your custom intent."
        return handler_input.response_builder.speak(speech_text).response

# Instantiate the SkillBuilder
sb = SkillBuilder()

# Add request handlers
sb.add_request_handler(LaunchRequestHandler())
sb.add_request_handler(CustomIntentHandler())

# Define the lambda handler
lambda_handler = sb.lambda_handler()

The creation fails (see below). There is a handler defined on the last line:

lambda_handler = sb.lambda_handler()

... but the tool doesn't recognize it: image

Please update the tool to handle this case.

Thank you.


Toolkit: AWS Toolkit For JetBrains 2.5-233 OS: Mac OS X 14.2.1 IDE: PyCharm Professional Edition 233

gamename avatar Feb 11 '24 22:02 gamename