Module: ChatbotHelpers
- Defined in:
- lib/chatbot_helpers.rb
Instance Method Summary collapse
- #chatbot(expected_response) ⇒ Object
- #chatbot_client ⇒ Object
- #intent_fired(intent_details) ⇒ Object
- #the_logger ⇒ Object
- #user(utterance) ⇒ Object
Instance Method Details
#chatbot(expected_response) ⇒ Object
26 27 28 29 30 |
# File 'lib/chatbot_helpers.rb', line 26 def chatbot(expected_response) the_logger.info "Expected response: " + expected_response.inspect the_logger.info "Actual response: " + @response..inspect expect(@response.).to match(expected_response) end |
#chatbot_client ⇒ Object
11 12 13 |
# File 'lib/chatbot_helpers.rb', line 11 def chatbot_client @client ||= BotSpec::AWS::LexService.new({botname: 'WebUiOrderFlowers'}) end |
#intent_fired(intent_details) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/chatbot_helpers.rb', line 32 def intent_fired(intent_details) expected_intent = intent_details.first the_logger.info "\n\n got this intent.data: " + @response.data.inspect expected_intent.keys.each do |key| expect(@response.data[key]).to eq(expected_intent[key]) end end |
#the_logger ⇒ Object
15 16 17 18 19 |
# File 'lib/chatbot_helpers.rb', line 15 def the_logger @logger = @logger ||= Logger.new(STDOUT) @logger.level = Logger::INFO @logger end |
#user(utterance) ⇒ Object
21 22 23 24 |
# File 'lib/chatbot_helpers.rb', line 21 def user(utterance) the_logger.info "User says: " + utterance.inspect @response = chatbot_client.(utterance, 'user_id') end |