watson-assistant-chatbot 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/watson-assistant-chatbot.rb +48 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9451071884314b47bed0e5640eedc9fd0226bbcb1ad2c77353aed7959e468ad5
|
4
|
+
data.tar.gz: 640d8a657eb989de38ae80cb85d9d18e2d17afda46c80d33eb76780afcc3213d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 71f4cf785c0ce21ca53001f1b1a2b73583e003d1cd874f898d8b9a92f712e4179a43f09856b307a35174824c926090fb890f5148fbb439eb64f1e04a8c1cd102
|
7
|
+
data.tar.gz: 0eeade929fac64e55b784c14c18f4239d4ce08e2a85056a74bb61791c498f95da720cd23ee690bc153df702292e0fb96876ea2e5a6dd351a128406cd6da0e49c
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# chatbot.rb
|
2
|
+
# Julian I. Kamil / @juliankamil
|
3
|
+
# 2018/04/04
|
4
|
+
|
5
|
+
require 'rest-client'
|
6
|
+
require 'json'
|
7
|
+
|
8
|
+
module WatsonAssistant
|
9
|
+
API_PROTOCOL = 'https'
|
10
|
+
API_SERVICE = 'assistant'
|
11
|
+
|
12
|
+
class Chatbot
|
13
|
+
attr_accessor :user_id, :password, :workspace_id
|
14
|
+
|
15
|
+
@api_domain = 'gateway.watsonplatform.net'
|
16
|
+
@api_version = '2018-02-16'
|
17
|
+
|
18
|
+
class << self
|
19
|
+
attr_accessor :api_domain, :api_version
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize(user_id, password, workspace_id)
|
23
|
+
@user_id = user_id
|
24
|
+
@password = password
|
25
|
+
@workspace_id = workspace_id
|
26
|
+
end
|
27
|
+
|
28
|
+
def message(request)
|
29
|
+
response = RestClient::Request.new(
|
30
|
+
:method => :post,
|
31
|
+
:url => message_url,
|
32
|
+
:user => user_id,
|
33
|
+
:password => password,
|
34
|
+
:payload => request,
|
35
|
+
:headers => { :accept => :json, :content_type => :json }
|
36
|
+
).execute
|
37
|
+
|
38
|
+
results = JSON.parse(response.to_str)
|
39
|
+
end
|
40
|
+
|
41
|
+
private def message_url
|
42
|
+
"#{API_PROTOCOL}://#{self.class.api_domain}" \
|
43
|
+
"/#{API_SERVICE}/api/v1" \
|
44
|
+
"/workspaces/#{workspace_id}" \
|
45
|
+
"/message?version=#{self.class.api_version}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: watson-assistant-chatbot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Julian I. Kamil
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-04-04 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A Ruby chatbot that uses Watson Assistant
|
14
|
+
email: julian.kamil@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/watson-assistant-chatbot.rb
|
20
|
+
homepage: http://rubygems.org/gems/watson-assistant-chatbot
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.7.6
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Watson Assistant Chatbot
|
44
|
+
test_files: []
|