Class: ActionAlexa::Skill
- Inherits:
-
Object
- Object
- ActionAlexa::Skill
- Defined in:
- lib/action_alexa/skill.rb
Overview
Top level class that will:
- Take in the Alexa request payload
- Fetch the intent Alexa is attempting to run
- Run the intent
- Return the response to Alexa for the end user This class should be run within a Rails Controller to interface between Alexa calls to the web service and intent executions
Constant Summary collapse
- MISSING_DEFAULT_INTENT_MESSAGE =
'There was an error talking to the service'.freeze
Instance Attribute Summary collapse
-
#alexa_payload ⇒ Object
readonly
Returns the value of attribute alexa_payload.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Class Method Summary collapse
Instance Method Summary collapse
- #execute_skill ⇒ Object
-
#initialize(alexa_payload) ⇒ Skill
constructor
A new instance of Skill.
Constructor Details
#initialize(alexa_payload) ⇒ Skill
Returns a new instance of Skill.
18 19 20 21 |
# File 'lib/action_alexa/skill.rb', line 18 def initialize(alexa_payload) @alexa_payload = ActionAlexa::AlexaRequest.new(alexa_payload) @logger = ActionAlexa.config.logger end |
Instance Attribute Details
#alexa_payload ⇒ Object (readonly)
Returns the value of attribute alexa_payload.
13 14 15 |
# File 'lib/action_alexa/skill.rb', line 13 def alexa_payload @alexa_payload end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
13 14 15 |
# File 'lib/action_alexa/skill.rb', line 13 def logger @logger end |
Class Method Details
.execute(alexa_payload) ⇒ Object
23 24 25 |
# File 'lib/action_alexa/skill.rb', line 23 def self.execute(alexa_payload) new(alexa_payload).execute_skill end |
Instance Method Details
#execute_skill ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/action_alexa/skill.rb', line 27 def execute_skill # Find the intent based on the registery intents intent_class = ActionAlexa::Intent::Registry.find_intent( alexa_payload.intent_name ) return fallback_intent_response if intent_class.nil? intent = intent_class.new(alexa_payload) # Execute the intent and return the result back to Alexa intent.execute end |