class Alexa::Session
Public Class Methods
new(session={})
click to toggle source
Calls superclass method
# File lib/alexa/session.rb, line 17 def initialize(session={}) @variables = session super(session["attributes"]) end
Public Instance Methods
application_id()
click to toggle source
Get application's ID from session
# File lib/alexa/session.rb, line 56 def application_id @variables["application"]["applicationId"] end
elicitation_count_for(slot_name)
click to toggle source
Get the elicitation count of a slot.
Elicitation counts are maintained in the session so that they can be referred to within the intenthandlers or the views
Options:
- slot_name: Slot name to return the elicitation count for
# File lib/alexa/session.rb, line 29 def elicitation_count_for(slot_name) self["elicitations"] ||= {} if self["elicitations"][slot_name].present? return self["elicitations"][slot_name]["count"] end return 0 end
increment_elicitation_count!(slot_name)
click to toggle source
Increase the elicitation count of a slot.
Elicitation counts are maintained in the session so that they can be referred to within the intenthandlers or the views
Options:
- slot_name: Slot name to increment the elicitation count for
# File lib/alexa/session.rb, line 43 def increment_elicitation_count!(slot_name) count = elicitation_count_for(slot_name) self["elicitations"].merge!( "#{slot_name}": { count: count + 1 } ) end
new?()
click to toggle source
Whether its a new session.
# File lib/alexa/session.rb, line 51 def new? @variables["new"] == true end
user_id()
click to toggle source
Get Amazon user's ID from session
# File lib/alexa/session.rb, line 61 def user_id @variables["user"]["userId"] end