class Watson::Conversation::Dialog
Public Class Methods
new(username: "", password: "", workspace_id: "")
click to toggle source
# File lib/watson/conversation.rb, line 13 def initialize(username: "", password: "", workspace_id: "") url = "https://#{username}:#{password}@gateway.watsonplatform.net/conversation/api" version="2017-02-03" @endpoint = "#{url}/v1/workspaces/#{workspace_id}/message?version=#{version}" end
Public Instance Methods
get_data()
click to toggle source
# File lib/watson/conversation.rb, line 51 def get_data() return code, body end
talk(question, context)
click to toggle source
# File lib/watson/conversation.rb, line 20 def talk(question, context) future_data = FutureData.new() if context == "" body = {}.to_json else body = { input: { text: question }, alternate_intents: true, context: context, }.to_json end Thread.start do begin response = RestClient.post @endpoint, body, content_type: :json, accept: :json code = response.code body = JSON.parse(response.body) rescue RestClient::ExceptionWithResponse => e code = e.response.code body = JSON.parse(e.response.body) end future_data.set_real_data(code, body) end return future_data end