As a complete newbie, I don't know where to begin with your example. I have an Alexa Developer Console account and created a skill with the Custom Model and Alexa-Hosted Python. The next screen forces me to choose a template from Hello World Skill, Fact Skill, Quiz Game, High-Low Game, or Sauce Boss. None seem appropriate. I tried adding your example to Hello World but it didn't work. It says "Sorry, I had trouble doing what you asked. Please try again." Once it said "Here's something I found on the web. According to wikipedia.org: Chuck says that the fact she doesn't like olives is the only thing he knows about her that is real."
joke = getResponseFromAPI()
return (
handler_input.response_builder
.speak(f"{joke}. Would you like to hear another Chuck Norris joke?")
.ask("Would you like to hear another joke?")
.response
)
class ChuckNorrisIntentHandler(AbstractRequestHandler):
"""Handler for Chuck Norris Intent."""
def can_handle(self, handler_input):
# type: (HandlerInput) -> bool
return ask_utils.is_intent_name("ChuckNorrisIntent")(handler_input)
def handle(self, handler_input):
# type: (HandlerInput) -> Response
speak_output = "Hi from Chuck Norris!"
return (
handler_input.response_builder
.speak(speak_output)
# .ask("add a reprompt if you want to keep the session open for the user to respond")
.response
)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
As a complete newbie, I don't know where to begin with your example. I have an Alexa Developer Console account and created a skill with the Custom Model and Alexa-Hosted Python. The next screen forces me to choose a template from Hello World Skill, Fact Skill, Quiz Game, High-Low Game, or Sauce Boss. None seem appropriate. I tried adding your example to Hello World but it didn't work. It says "Sorry, I had trouble doing what you asked. Please try again." Once it said "Here's something I found on the web. According to wikipedia.org: Chuck says that the fact she doesn't like olives is the only thing he knows about her that is real."
Here is my modification to the Hello World code:
import requests
def getResponseFromAPI():
url = 'api.chucknorris.io/jokes/random'
response = requests.get(url)
print(response.status_code)
class LaunchRequestHandler(AbstractRequestHandler):
"""Handler for Skill Launch."""
def can_handle(self, handler_input):
# type: (HandlerInput) -> bool
def handle(self, handler_input):
# type: (HandlerInput) -> Response
logging.info("LaunchRequest was trigerred")
class ChuckNorrisIntentHandler(AbstractRequestHandler):
"""Handler for Chuck Norris Intent."""
def can_handle(self, handler_input):
# type: (HandlerInput) -> bool
return ask_utils.is_intent_name("ChuckNorrisIntent")(handler_input)