Module: ActionAlexa::RequestPayload::Request

Included in:
AlexaRequest
Defined in:
lib/action_alexa/request_payload/request.rb

Overview

Request component of the JSON blob from the Alexa request TO the application. This module contains utility methods to access the attributes

Instance Method Summary collapse

Instance Method Details

#intent_nameObject



12
13
14
15
16
17
# File 'lib/action_alexa/request_payload/request.rb', line 12

def intent_name
  return type unless type == 'IntentRequest'

  full_intent_name = request_payload['intent']['name']
  full_intent_name.split(/\./).last.gsub(/Intent$/, '')
end

Returns:

  • (Boolean)


32
33
34
35
36
# File 'lib/action_alexa/request_payload/request.rb', line 32

def link_result_should_be_returned?
  key = 'shouldLinkResultBeReturned'

  request_payload.key?(key) && request_payload[key]
end

#localeObject



28
29
30
# File 'lib/action_alexa/request_payload/request.rb', line 28

def locale
  request_payload['locale']
end

#request_idObject

For logging purposes when reaching out to Amazon



20
21
22
# File 'lib/action_alexa/request_payload/request.rb', line 20

def request_id
  request_payload['requestId']
end

#slot(slot_type) ⇒ Object



46
47
48
49
50
# File 'lib/action_alexa/request_payload/request.rb', line 46

def slot(slot_type)
  return nil unless slots?

  slots[slot_type]
end

#slot?(slot_type) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/action_alexa/request_payload/request.rb', line 42

def slot?(slot_type)
  slots? && !slot(slot_type).nil?
end

#slotsObject



52
53
54
# File 'lib/action_alexa/request_payload/request.rb', line 52

def slots
  request_payload['intent']['slots']
end

#slots?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/action_alexa/request_payload/request.rb', line 38

def slots?
  !slots.nil?
end

#timestampObject



24
25
26
# File 'lib/action_alexa/request_payload/request.rb', line 24

def timestamp
  request_payload['timestamp']
end

#typeObject



8
9
10
# File 'lib/action_alexa/request_payload/request.rb', line 8

def type
  request_payload['type']
end