class BotSpec::AWS::LexService
Public Class Methods
load(config)
click to toggle source
# File lib/botspec/lex/lex_service.rb, line 6 def self.load(config) return LexService.new(config) end
new(config)
click to toggle source
# File lib/botspec/lex/lex_service.rb, line 10 def initialize(config) if config[:stub_responses] @lex_client = Aws::Lex::Client.new(stub_responses: true) @lex_client.stub_responses(config[:stub_responses][:operation_to_stub], config[:stub_responses][:stub_data]) end @config = config @bot_name = config[:botname] @user_id = "botspec-#{SecureRandom.uuid}" end
Public Instance Methods
interaction_to_lex_message(message)
click to toggle source
# File lib/botspec/lex/lex_service.rb, line 24 def interaction_to_lex_message(message) return { bot_name: @bot_name, bot_alias: "$LATEST", user_id: @user_id, session_attributes: { "String" => "String", }, request_attributes: { "String" => "String", }, input_text: message, } end
lex_client()
click to toggle source
# File lib/botspec/lex/lex_service.rb, line 20 def lex_client @lex_client ||= Aws::Lex::Client.new end
post_message(message, user_id='')
click to toggle source
# File lib/botspec/lex/lex_service.rb, line 39 def post_message message, user_id='' resp = lex_client.post_text(interaction_to_lex_message(message)) sleep(1); resp end