Class: BotController

Inherits:
Stealth::Controller show all
Defined in:
lib/stealth/generators/builder/bot/controllers/bot_controller.rb

Constant Summary

Constants included from Stealth::Controller::DevJumps

Stealth::Controller::DevJumps::DEV_JUMP_REGEX

Constants included from Stealth::Controller::DynamicDelay

Stealth::Controller::DynamicDelay::LONG_DELAY, Stealth::Controller::DynamicDelay::SHORT_DELAY, Stealth::Controller::DynamicDelay::STANDARD_DELAY

Instance Attribute Summary

Attributes inherited from Stealth::Controller

#action_name, #current_message, #current_service, #current_session_id, #flow_controller, #nlp_result, #pos

Instance Method Summary collapse

Methods inherited from Stealth::Controller

#action, #current_session, #do_nothing, #halt!, #has_attachments?, #has_location?, #initialize, #previous_session, #progressed?, #set_back_to, #step_back, #step_to, #step_to_at, #step_to_in, #update_session_to

Methods included from Stealth::Controller::DynamicDelay

#calculate_delay_from_text

Constructor Details

This class inherits a constructor from Stealth::Controller

Instance Method Details

#routeObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/stealth/generators/builder/bot/controllers/bot_controller.rb', line 7

def route
  if current_message.payload.present?
    handle_payloads
    # Clear out the payload to prevent duplicate handling
    current_message.payload = nil
    return
  end

  # Allow devs to jump around flows and states by typing:
  #   /flow_name/state_name or
  #   /flow_name (jumps to first state) or
  #   //state_name (jumps to state in current flow)
  # (only works for bots in development)
  return if dev_jump_detected?

  if current_session.present?
    step_to session: current_session
  else
    step_to flow: 'hello', state: 'say_hello'
  end
end