Class: Hg::Request

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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(options = {})
  @action     = options.fetch(:action)
  @user       = options.fetch(:user)
  @intent     = options.fetch(:intent) { nil }
  @message    = options.fetch(:message) { nil }
  @parameters = options.fetch(:parameters) { {} }
  @response   = options.fetch(:response) { nil }
  @route      = options.fetch(:route) { nil }
end

Instance Attribute Details

#actionObject

The action name



10
11
12
# File 'lib/hg/request.rb', line 10

def action
  @action
end

#intentObject

The intent name



12
13
14
# File 'lib/hg/request.rb', line 12

def intent
  @intent
end

#messageObject

The original user message



14
15
16
# File 'lib/hg/request.rb', line 14

def message
  @message
end

#parametersObject Also known as: params

The request parameters



18
19
20
# File 'lib/hg/request.rb', line 18

def parameters
  @parameters
end

#responseObject

The response suggested by the NLU



21
22
23
# File 'lib/hg/request.rb', line 21

def response
  @response
end

#routeObject

An (optional) specified route for the request. Used for prompts.



23
24
25
# File 'lib/hg/request.rb', line 23

def route
  @route
end

#userObject

The user that made the request



16
17
18
# File 'lib/hg/request.rb', line 16

def user
  @user
end