Class: Hg::Request
- Inherits:
-
Object
- Object
- Hg::Request
- Defined in:
- lib/hg/request.rb
Overview
Represents an inbound request to a bot. Contains all relevant request information:
user
- The user making the request.message
- The original message object from the bot's platform.action
- The name of the action requested.intent
- The name of the intent requested.parameters
- Any parsed parameters (entities) for this request.
Instance Attribute Summary collapse
-
#action ⇒ Object
The action name.
-
#intent ⇒ Object
The intent name.
-
#message ⇒ Object
The original user message.
-
#parameters ⇒ Object
(also: #params)
The request parameters.
-
#response ⇒ Object
The response suggested by the NLU.
-
#route ⇒ Object
An (optional) specified route for the request.
-
#user ⇒ Object
The user that made the request.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Request
constructor
TODO: Use dry-initializer.
Constructor Details
#initialize(options = {}) ⇒ Request
TODO: Use dry-initializer
26 27 28 29 30 31 32 33 34 |
# File 'lib/hg/request.rb', line 26 def initialize( = {}) @action = .fetch(:action) @user = .fetch(:user) @intent = .fetch(:intent) { nil } @message = .fetch(:message) { nil } @parameters = .fetch(:parameters) { {} } @response = .fetch(:response) { nil } @route = .fetch(:route) { nil } end |
Instance Attribute Details
#action ⇒ Object
The action name
10 11 12 |
# File 'lib/hg/request.rb', line 10 def action @action end |
#intent ⇒ Object
The intent name
12 13 14 |
# File 'lib/hg/request.rb', line 12 def intent @intent end |
#message ⇒ Object
The original user message
14 15 16 |
# File 'lib/hg/request.rb', line 14 def @message end |
#parameters ⇒ Object Also known as: params
The request parameters
18 19 20 |
# File 'lib/hg/request.rb', line 18 def parameters @parameters end |
#response ⇒ Object
The response suggested by the NLU
21 22 23 |
# File 'lib/hg/request.rb', line 21 def response @response end |
#route ⇒ Object
An (optional) specified route for the request. Used for prompts.
23 24 25 |
# File 'lib/hg/request.rb', line 23 def route @route end |
#user ⇒ Object
The user that made the request
16 17 18 |
# File 'lib/hg/request.rb', line 16 def user @user end |