uopspop

Untitled

Dec 19th, 2019
121
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from ask_sdk_core.skill_builder import SkillBuilder
  2.  
  3. sb = SkillBuilder()
  4.  
  5. from ask_sdk_core.dispatch_components import AbstractRequestHandler
  6. from ask_sdk_core.utils import is_request_type, is_intent_name
  7. from ask_sdk_core.handler_input import HandlerInput
  8. from ask_sdk_model import Response
  9. from ask_sdk_model.ui import SimpleCard
  10.  
  11. class LaunchRequestHandler(AbstractRequestHandler):
  12. print('hey004')
  13.  
  14. def can_handle(self, handler_input):
  15. # type: (HandlerInput) -> bool
  16. print('hey005')
  17. print(handler_input)
  18. return is_request_type("LaunchRequest")(handler_input)
  19.  
  20. def handle(self, handler_input):
  21. # type: (HandlerInput) -> Response
  22. speech_text = "Welcome to the Alexa Skills Kit, you can say hello!"
  23.  
  24. handler_input.response_builder.speak(speech_text).set_card(
  25. SimpleCard("Hello World", speech_text)).set_should_end_session(
  26. False)
  27. return handler_input.response_builder.response
  28.  
  29.  
  30. class HelloWorldIntentHandler(AbstractRequestHandler):
  31. def can_handle(self, handler_input):
  32. # type: (HandlerInput) -> bool
  33. print('hey005')
  34. return is_intent_name("HelloWorldIntent")(handler_input)
  35.  
  36. def handle(self, handler_input):
  37. # type: (HandlerInput) -> Response
  38. speech_text = "Hello World"
  39.  
  40. handler_input.response_builder.speak(speech_text).set_card(
  41. SimpleCard("Hello World", speech_text)).set_should_end_session(
  42. True)
  43. return handler_input.response_builder.response
  44.  
  45.  
  46.  
  47. class HelpIntentHandler(AbstractRequestHandler):
  48. def can_handle(self, handler_input):
  49. # type: (HandlerInput) -> bool
  50. print('hey005')
  51. return is_intent_name("AMAZON.HelpIntent")(handler_input)
  52.  
  53. def handle(self, handler_input):
  54. # type: (HandlerInput) -> Response
  55. speech_text = "You can say hello to me!"
  56.  
  57. handler_input.response_builder.speak(speech_text).ask(speech_text).set_card(
  58. SimpleCard("Hello World", speech_text))
  59. return handler_input.response_builder.response
  60.  
  61.  
  62. class CancelAndStopIntentHandler(AbstractRequestHandler):
  63. def can_handle(self, handler_input):
  64. # type: (HandlerInput) -> bool
  65. print('hey005')
  66. return is_intent_name("AMAZON.CancelIntent")(handler_input) or is_intent_name("AMAZON.StopIntent")(handler_input)
  67.  
  68. def handle(self, handler_input):
  69. # type: (HandlerInput) -> Response
  70. speech_text = "Goodbye!"
  71.  
  72. handler_input.response_builder.speak(speech_text).set_card(
  73. SimpleCard("Hello World", speech_text)).set_should_end_session(True)
  74. return handler_input.response_builder.response
  75.  
  76. class SessionEndedRequestHandler(AbstractRequestHandler):
  77. def can_handle(self, handler_input):
  78. # type: (HandlerInput) -> bool
  79. print('hey005')
  80. return is_request_type("SessionEndedRequest")(handler_input)
  81.  
  82. def handle(self, handler_input):
  83. # type: (HandlerInput) -> Response
  84. # any cleanup logic goes here
  85.  
  86. return handler_input.response_builder.response
  87.  
  88.  
  89. from ask_sdk_core.dispatch_components import AbstractExceptionHandler
  90.  
  91. class AllExceptionHandler(AbstractExceptionHandler):
  92.  
  93. def can_handle(self, handler_input, exception):
  94. # type: (HandlerInput, Exception) -> bool
  95. print('hey005')
  96. return True
  97.  
  98. def handle(self, handler_input, exception):
  99. # type: (HandlerInput, Exception) -> Response
  100. # Log the exception in CloudWatch Logs
  101. print(exception)
  102.  
  103. speech = "Sorry, I didn't get it. Can you please say it again!!"
  104. handler_input.response_builder.speak(speech).ask(speech)
  105. return handler_input.response_builder.response
  106.  
  107.  
  108. skill = sb.create()
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×