watson-assistant-chatbot 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9451071884314b47bed0e5640eedc9fd0226bbcb1ad2c77353aed7959e468ad5
4
- data.tar.gz: 640d8a657eb989de38ae80cb85d9d18e2d17afda46c80d33eb76780afcc3213d
3
+ metadata.gz: 73c249936eb92afbf17633947de7d22e8443e6b9c16983eb8c2deee084946f67
4
+ data.tar.gz: e9c1f0cba7ede2a81b052cb9aa102aae9f901f5b5a153bb81fbe8332881fbed9
5
5
  SHA512:
6
- metadata.gz: 71f4cf785c0ce21ca53001f1b1a2b73583e003d1cd874f898d8b9a92f712e4179a43f09856b307a35174824c926090fb890f5148fbb439eb64f1e04a8c1cd102
7
- data.tar.gz: 0eeade929fac64e55b784c14c18f4239d4ce08e2a85056a74bb61791c498f95da720cd23ee690bc153df702292e0fb96876ea2e5a6dd351a128406cd6da0e49c
6
+ metadata.gz: be358115b1d597d7a7e182a27748257e913a2d0825b7bddd6eb06267bb4fecf33bafa8b0791044bc4ebb7bd5e0f7b609b4efec043d1a1e7c8c175fa7dfe2d148
7
+ data.tar.gz: 5dc2fab5cd8a9e2051fa370f17b0d7b5d39add98406024f59ff0faed0ac164262d1119adbb208581921558e3f4d316ffb3037ae1d125f4b87a7672df2cc2cc43
@@ -1,4 +1,4 @@
1
- # chatbot.rb
1
+ # watson-assistant-chatbot.rb
2
2
  # Julian I. Kamil / @juliankamil
3
3
  # 2018/04/04
4
4
 
@@ -8,6 +8,7 @@ require 'json'
8
8
  module WatsonAssistant
9
9
  API_PROTOCOL = 'https'
10
10
  API_SERVICE = 'assistant'
11
+ INTENT_UNDETECTED = '-- undetected --'
11
12
 
12
13
  class Chatbot
13
14
  attr_accessor :user_id, :password, :workspace_id
@@ -38,6 +39,26 @@ module WatsonAssistant
38
39
  results = JSON.parse(response.to_str)
39
40
  end
40
41
 
42
+ def conversation_id(results)
43
+ results["context"]["conversation_id"]
44
+ end
45
+
46
+ def response_text(results)
47
+ results["output"]["text"][0] if (results["output"]["text"].length > 0)
48
+ end
49
+
50
+ def intent_and_confidence(results)
51
+ if (results["intents"].length > 0)
52
+ intent = results["intents"][0]["intent"]
53
+ confidence = results["intents"][0]["confidence"]
54
+ else
55
+ intent = INTENT_UNDETECTED
56
+ confidence = '1'
57
+ end
58
+
59
+ return intent, confidence
60
+ end
61
+
41
62
  private def message_url
42
63
  "#{API_PROTOCOL}://#{self.class.api_domain}" \
43
64
  "/#{API_SERVICE}/api/v1" \
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watson-assistant-chatbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian I. Kamil