janis-ai 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +16 -17
  3. data/lib/janis.rb +48 -18
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 95489d4cd6e6526cf764f8403d96f078a68b0d8b
4
- data.tar.gz: 9a85fc4a4e916081807163c3764398ba9afd3fb4
3
+ metadata.gz: 4609b248d7ae8150b0f88c7affa945b4e9e9ea0a
4
+ data.tar.gz: 7ab1556e2aaffda24704971e14c9efeabbb4f922
5
5
  SHA512:
6
- metadata.gz: 4e07d6a975c63435d58de5376c3709dad6168a857a4f6f87fdb8cb60ccb8bc3d8d210dd3e0a4ab18f2bb7901763593607ea2ffc60b77c84fe99e25d4bd6be8db
7
- data.tar.gz: 9fab1d850db851cdfb64f1cc919086336804efd33bd4f639ace2dea2bb23382c47c3254100f4e22da4ac85a5366d7a00f6e8e5eda893588b0add63383ee483f8
6
+ metadata.gz: 7b787ead334e1fc07547fae719c3eed3b5e796f0ba6cbd2500afe17bb3a2e5c6bd9d321ecbfa3ac25319512a32b705904b6da49b5ca27be77085ff37401219ff
7
+ data.tar.gz: da63e866c10e921dd09c392cb11b75d0a125456713ac2cdb1e91c6ecba4c9bea2f673d1df780e1b1a637284507f6ea09a1c9f6dcf7f31036e7f421d958bb8872
data/README.md CHANGED
@@ -1,30 +1,29 @@
1
- # [janis](https://www.janis.ai) - SDK For Human + AI Conversational Experiences
2
- ## For Bots Built in Ruby
1
+ # [Janis](https://www.Janis.ai) - Message Management
2
+ ## For Chatbots built with Ruby
3
3
 
4
- Bots enable businesses to respond to customers immediately but they often fail to understand user intent. According to Facebook, bots fail 70% of the time. janis helps solve this problem with a toolkit to easily keep humans in the loop when AI fails your customers. The solution includes an SDK for bot developers to connect their bots to Slack, and a Slack app to get alerts, then pause and take over a bot.
4
+ Janis helps teams train and monitor bots and fix problems fast. [Build a bot in Ruby](./examples/) and integrate Janis with just a few lines of code to ensure delightful conversational experiences in every messaging channel.
5
5
 
6
- ![Solution](https://cloud.githubusercontent.com/assets/7429980/22609969/491afe58-ea31-11e6-8928-27e1a1f1d6bd.png)
6
+ ##### Train
7
+ Collaborate on what users say and your responses in a dedicated training channel. Experience exactly what your users will experience when they message you.
7
8
 
9
+ ##### Monitor
10
+ Janis alerts you in Slack when your bot needs your help. Use our smart alerts, or create your own alerts to bring humans in the loop.
8
11
 
12
+ ##### Fix Problems Fast
13
+ Take over for your bot and chat live to retain your users, while training your AI to learn from the conversation. Hand control back to your bot when you're done.
9
14
 
10
- You can integrate janis in minutes and it begins working immediately, enabling you to deliver exceptional human + AI conversational experiences.
11
- This module has been tested with Messenger, Slack, Skype, and Microsoft Webchat. Please see our [examples](./examples/).
12
- It supports bot developers working in Node, Python and Ruby.
13
-
14
- ### What you can do with janis:
15
- You can view a full list of features at (https://www.janis.ai). It's core purpose can be explained with this single GIF
16
-
17
- ![Takeover](https://cloud.githubusercontent.com/assets/7429980/22609935/22e39740-ea31-11e6-8286-e5a3ae545565.gif)
15
+ To learn more about Janis' capabilities, visit [Janis.ai](https://www.janis.ai)
18
16
 
19
17
  ### What you need to get started:
20
- * [A Slack Account](http://www.slack.com)
21
- * [janis for Slack](https://slack.com/oauth/authorize?scope=users:read,users:read.email,commands,chat:write:bot,chat:write:user,channels:read,channels:history,files:write:user,channels:write,bot&client_id=23850726983.39760486257)
18
+ * [Add Janis to your Slack team](https://www.janis.ai)
22
19
  * [A Chatbot built in Ruby](./examples/)
23
20
 
24
21
  ##### Operational Dependencies:
25
- 1. You'll need an API key from janis and for each Chatbot a Bot Token. You can get both of those (free) when you add janis to Slack and through a conversation with janis.
26
- 2. If you're building a Messenger Chatbot, you'll need to setup a Facebook App, Facebook Page, get the Page Access Token from Facebook and link the Facebook App to the Facebook Page for janis to work.
22
+ 1. You'll need an API key and a Client Key for your Chatbot. You can get both of those (free) when you add Janis to Slack.
23
+ 2. If you're building a Messenger Chatbot, you'll need to setup a Facebook App, Facebook Page, get the Page Access Token from Facebook and link the Facebook App to the Facebook Page for Janis to work. This is standard for any Chatbot you build for Messenger.
24
+ 3. Janis can help you train your AI from Slack. Currently Dialogflow, formerly known as API.AI (http://www.api.ai) is supported.
27
25
 
26
+ Note: This module has been tested with Messenger, Slack, Skype, and Microsoft Webchat. Please see our [examples](./examples/).
28
27
 
29
28
  ### Installation
30
29
 
@@ -176,5 +175,5 @@ Go back to Slack and wait for alerts. That's it!
176
175
 
177
176
 
178
177
  ### Looking for something we don't yet support?
179
- * [Join our mailing list and we'll notifiy you](https://www.janis.ai/contact.html)
178
+ * [Join our mailing list and we'll notifiy you](https://www.janis.ai)
180
179
  * [Contact Support](mailto:support@janis.ai)
@@ -5,22 +5,28 @@ require 'httparty'
5
5
  module Janis
6
6
 
7
7
 
8
- class Partay
8
+ class Janiapi
9
9
  include HTTParty
10
- base_uri 'https://wordhopapi.herokuapp.com/api/v1'
10
+ base_uri 'https://janis.ai/api/v1'
11
+ end
12
+
13
+ class FBApi
14
+ include HTTParty
15
+ base_uri 'https://graph.facebook.com/v2.6/me'
11
16
  end
12
17
 
13
18
  EVENTS = [:'chat response', :'socket_id_set', :'channel update'].freeze
14
19
 
15
20
  class << self
16
21
 
17
- attr_accessor :apikey, :clientkey, :token, :platform
22
+ attr_accessor :apikey, :clientkey, :token, :platform, :options
18
23
 
19
24
  def initialize
20
25
  @apikey
21
26
  @clientkey
22
27
  @token
23
28
  @platform
29
+ @options
24
30
  end
25
31
 
26
32
  def new(*args, &block)
@@ -45,6 +51,10 @@ module Janis
45
51
  def platform
46
52
  @platform ||= "messenger"
47
53
  end
54
+
55
+ def janisappid
56
+ @janisappid = 1242623579085955
57
+ end
48
58
 
49
59
  def headers
50
60
  @headers = {'apikey':apikey,'clientkey':clientkey,'platform':platform, 'token': token}
@@ -59,11 +69,11 @@ module Janis
59
69
  socket.on :socket_id_set do |data|
60
70
  socket_id = data
61
71
  x = {'socket_id': socket_id, 'clientkey': JANIS_CLIENT_KEY}
62
- options = {
72
+ data = {
63
73
  body: x,
64
74
  headers: headers
65
75
  }
66
- Partay.post('/update_bot_socket_id', options)
76
+ Janiapi.post('/update_bot_socket_id', data)
67
77
  end
68
78
 
69
79
  socket.on :'chat response' do |data|
@@ -94,28 +104,48 @@ module Janis
94
104
  end
95
105
 
96
106
  def hopIn(x)
97
- puts 'hopIn'
98
- options = {'body':x, 'headers':headers}
99
- return Partay.post('/in', options)
107
+ data = {'body':x, 'headers':headers}
108
+ return Janiapi.post('/in', data)
100
109
  end
101
110
 
102
111
  def hopOut(x)
103
- puts 'hopOut'
104
- options = {'body':x, 'headers':headers}
105
- return Partay.post('/out', options)
112
+ data = {'body':x, 'headers':headers}
113
+ return Janiapi.post('/out', data)
106
114
  end
107
115
 
108
116
  def logUnknownIntent(x)
109
- puts 'logUnknownIntent'
110
- options = {'body':x, 'headers':headers}
111
- return Partay.post('/unknown', options)
117
+ data = {'body':x, 'headers':headers}
118
+ return Janiapi.post('/unknown', data)
112
119
  end
113
120
 
114
121
  def assistanceRequested(x)
115
- puts 'assistanceRequested'
116
- options = {'body':x, 'headers':headers}
117
- return Partay.post('/human', options)
122
+ data = {'body':x, 'headers':headers}
123
+ return Janiapi.post('/human', data)
124
+ end
125
+
126
+ def passThreadControl(x)
127
+ message = x['message']
128
+ recipientid = x['recipient']['id']
129
+ appid = message['app_id']
130
+ is_echo = message['is_echo']
131
+ if message['is_echo'] && (appid == janisappid || appid.nil?)
132
+
133
+ # If an agent responds via the Messenger Inbox, then `appId` will be null.
134
+ # If an agent responds from Janis on Slack, the `appId` will be 1242623579085955.
135
+ # In both cases, we should pause your bot by giving the thread control to Janis.
136
+ # Janis will pass control back to your app again after 10 minutes of inactivity.
137
+ # If you want to manually pass back control, use the slash command `/resume`
138
+ # in the Janis transcript channel, or press "Done" in the Page Inbox on the thread.
139
+
140
+ # See: https://developers.facebook.com/docs/messenger-platform/handover-protocol#app_roles
141
+ # This app should be the Primary Receiver. Janis should be a Secondary Receiver.
142
+ # Every time an echo from either Janis or the Page Inbox is received,
143
+ # this app passes control over to Janis so the humans are the only ones who can respond.
144
+ j = {"recipient": {"id": recipientid}, "target_app_id": janisappid, "metadata": "passing thread"}
145
+ uri = "/pass_thread_control?access_token=" + token
146
+ return FBApi.post(uri, {'body':j})
147
+ end
148
+ return false
118
149
  end
119
150
  end
120
151
  end
121
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: janis-ai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Nathanson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-09 00:00:00.000000000 Z
11
+ date: 2017-11-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: "Chatbots allow you scale your customer communications through messaging,
14
14
  \n \tautomating tasks and enabling transactions, but they can't empathize like