wordhop 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +96 -31
- data/lib/wordhop.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fd062193fa74d0eac121d686cbc89172c85aada
|
4
|
+
data.tar.gz: c25c3973a3fc9a36a518025c0aacd1cd3334cbe1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 052054010ab217213318d9508c40e5a0a07da4750a0d349e66e409df34c3088474d3689cfc5d0379e8238741cecac5610e24e1ab4923cee93f2d194865ff166e
|
7
|
+
data.tar.gz: 22bc9c48b7931d7ae0628764865c167089af541fe7fa2b24bc7dc5ae13a0d3d2635611b408f257eaf0e89a537c020ae0da5d842656fbd3551b08a071d48bbd28
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# [Wordhop](https://www.wordhop.io) - Monitor and Optimize Your Conversational Experience
|
2
2
|
## For Chatbots Built in Ruby
|
3
3
|
|
4
|
-
|
4
|
+
Wordhop monitors your Chatbot for friction in your conversational experience and alerts you on Slack in real-time. Simply add Wordhop to Slack and then drop in a couple of lines of code into your Chatbot. Wordhop integrates in minutes, and begins working immediately. From Slack, you can see full transcripts of all your bot's conversations, pause and take over your bot, then hand the conversation back to your bot. Actionable analytics also show you and your Slack team where you can optimize your conversational experience and measure results.
|
5
5
|
|
6
6
|
### What you can do with Wordhop:
|
7
7
|
* [See Key Features](https://developer.wordhop.io)
|
@@ -10,7 +10,12 @@ With Wordhop you can sync up your Ruby-based Chatbot to Slack, so you can retain
|
|
10
10
|
### What you need to get started:
|
11
11
|
* [A Slack Account](http://www.slack.com)
|
12
12
|
* [Wordhop for Slack](https://slack.com/oauth/authorize?scope=users:read,users:read.email,commands,chat:write:bot,channels:read,channels:write,bot&client_id=23850726983.39760486257)
|
13
|
-
* [A Chatbot built in Ruby](
|
13
|
+
* [A Chatbot built in Ruby](./examples/)
|
14
|
+
|
15
|
+
##### Operational Dependencies:
|
16
|
+
1. You'll need an API key from Wordhop and for each Chatbot a Bot Token. You can get both of those (free) when you add Wordhop to Slack and through a conversation with Wordhop.
|
17
|
+
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 Wordhop to work.
|
18
|
+
|
14
19
|
|
15
20
|
### Installation
|
16
21
|
|
@@ -21,6 +26,15 @@ $ gem install wordhop
|
|
21
26
|
|
22
27
|
### Usage
|
23
28
|
|
29
|
+
Set your environmental variables for `WORDHOP_API_KEY`, `WORDHOP_CLIENT_KEY`, `ACCESS_TOKEN`.
|
30
|
+
|
31
|
+
```bash
|
32
|
+
$ export WORDHOP_API_KEY=xxxxxxxxxxxxxxxxxxxx
|
33
|
+
$ export WORDHOP_CLIENT_KEY=xxxxxxxxxxxxxxxxxxxx
|
34
|
+
$ export ACCESS_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
35
|
+
```
|
36
|
+
|
37
|
+
Add the Wordhop class to your code and set the required parameter values.
|
24
38
|
```ruby
|
25
39
|
require 'wordhop'
|
26
40
|
|
@@ -33,14 +47,67 @@ Wordhop.platform = "messenger"
|
|
33
47
|
# Page Access Token (only required for Messenger bots)
|
34
48
|
Wordhop.token = ENV['ACCESS_TOKEN']
|
35
49
|
```
|
50
|
+
##### Incoming Message Schema:
|
51
|
+
Throughout this documentation, you will see references to `incomingMessage`. Depending on whether you have a Messenger or Slack bot, the schema will be different. The value of `incomingMessage` should be equal to the message you receive directly from either the Messenger webhook response, or from the Slack RTM event response.
|
52
|
+
|
53
|
+
```python
|
54
|
+
# Example of a Slack Incoming Message
|
55
|
+
{
|
56
|
+
"type": "message",
|
57
|
+
"channel": "D024BE91L",
|
58
|
+
"user": "U2147483697",
|
59
|
+
"text": "Hello world",
|
60
|
+
"ts": "1355517523.000005"
|
61
|
+
}
|
62
|
+
|
63
|
+
# Example of a Messenger Incoming Message
|
64
|
+
{
|
65
|
+
"sender":{
|
66
|
+
"id":"USER_ID"
|
67
|
+
},
|
68
|
+
"recipient":{
|
69
|
+
"id":"PAGE_ID"
|
70
|
+
},
|
71
|
+
"timestamp":1458692752478,
|
72
|
+
"message":{
|
73
|
+
"mid":"mid.1457764197618:41d102a3e1ae206a38",
|
74
|
+
"seq":73,
|
75
|
+
"text":"hello, world!",
|
76
|
+
"quick_reply": {
|
77
|
+
"payload": "DEVELOPER_DEFINED_PAYLOAD"
|
78
|
+
}
|
79
|
+
}
|
80
|
+
}
|
81
|
+
```
|
82
|
+
|
83
|
+
##### Outgoing Message Schema:
|
84
|
+
Throughout this documentation, you will see references to `outgoingMessage`. Depending on whether you have a Messenger or Slack bot, the schema, as defined by each platform, will be different. Every time you track an outgoing message, the schema requirements match the respective platform.
|
85
|
+
|
86
|
+
```python
|
87
|
+
# Example of Slack Outgoing Message
|
88
|
+
{
|
89
|
+
"channel": "C024BE91L",
|
90
|
+
"text": "Hello world"
|
91
|
+
}
|
92
|
+
|
93
|
+
# Exmaple of Messenger Outgoing Message
|
94
|
+
{
|
95
|
+
"recipient":{
|
96
|
+
"id":"USER_ID"
|
97
|
+
},
|
98
|
+
"message":{
|
99
|
+
"text":"hello, world!"
|
100
|
+
}
|
101
|
+
}
|
102
|
+
```
|
36
103
|
|
37
104
|
##### Tracking received messages:
|
38
105
|
|
39
|
-
When
|
106
|
+
When your bot receives an incoming message, you'll need to log the data with Wordhop by calling to `wordhop.hopIn`.
|
40
107
|
__Note__: Wordhop can pause your bot so that it doesn't auto response while a human has taken over. The server response from your `hopIn` request will pass the `paused` state. Use that to stop your bot from responding to an incoming message. Here is an example:
|
41
108
|
|
42
109
|
```ruby
|
43
|
-
hopInResponse = Wordhop.hopIn(
|
110
|
+
hopInResponse = Wordhop.hopIn(incomingMessage)
|
44
111
|
if hopInResponse['paused'] != true
|
45
112
|
# proceed to process incoming message
|
46
113
|
...
|
@@ -48,55 +115,53 @@ if hopInResponse['paused'] != true
|
|
48
115
|
|
49
116
|
##### Tracking sent messages:
|
50
117
|
|
51
|
-
Each time your bot sends a message, make sure to log that with Wordhop
|
118
|
+
Each time your bot sends a message, make sure to log that with Wordhop by calling to `wordhop.hopOut`. Here is an example of a function that we're calling `sendIt` that tracks an outgoing message and at the same time, has the bot say the message:
|
52
119
|
```ruby
|
53
|
-
def sendIt(
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
Wordhop.hopOut(payload)
|
60
|
-
end
|
120
|
+
def sendIt(channel, text)
|
121
|
+
# schema matches Messenger
|
122
|
+
outgoingMessage = {recipient: {id: channel},message: {text: text}}
|
123
|
+
Wordhop.hopOut(outgoingMessage)
|
124
|
+
bot.send_text_message(channel, text) # <= example of bot sending reply
|
125
|
+
...
|
61
126
|
```
|
62
127
|
|
63
|
-
##### Human Take Over:
|
64
|
-
|
65
|
-
To enable the ability to have a human take over your bot, add the following code:
|
66
|
-
|
67
|
-
```ruby
|
68
|
-
# Handle forwarding the messages sent by a human through your bot
|
69
|
-
Wordhop.on :'chat response' do |data|
|
70
|
-
Bot.deliver(data, access_token: ENV['ACCESS_TOKEN']) # <= example of bot sending message
|
71
|
-
end
|
72
|
-
```
|
73
128
|
##### Log Unknown Intents:
|
74
129
|
|
75
|
-
Find the spot in your code your bot processes incoming messages it does not understand.
|
130
|
+
Find the spot in your code your bot processes incoming messages it does not understand. Within that block of code, call to `wordhop.logUnkownIntent` to capture these conversational ‘dead-ends’. Here's an example:
|
76
131
|
|
77
132
|
```ruby
|
78
133
|
# let the user know that the bot does not understand
|
79
|
-
sendIt(
|
134
|
+
sendIt(recipient_id, 'Huh?')
|
80
135
|
# capture conversational dead-ends.
|
81
|
-
Wordhop.logUnknownIntent(
|
136
|
+
Wordhop.logUnknownIntent(incomingMessage)
|
82
137
|
```
|
83
138
|
##### Dial 0 to Speak With a Live Human Being:
|
84
139
|
|
85
|
-
Wordhop can trigger alerts to suggest when a human should take over for your Chatbot. To enable this, create an intent such as when a customer explicitly requests live assistance, and then include the following
|
140
|
+
Wordhop can trigger alerts to suggest when a human should take over for your Chatbot. To enable this, create an intent such as when a customer explicitly requests live assistance, and then include the following lines of code where your bot listens for this intent:
|
86
141
|
|
87
142
|
```ruby
|
88
143
|
# match an intent to talk to a real human
|
89
144
|
if text == 'help'
|
90
145
|
# let the user know that they are being routed to a human
|
91
|
-
sendIt(
|
146
|
+
sendIt(recipient_id, 'Hang tight. Let me see what I can do.')
|
92
147
|
# send a Wordhop alert to your slack channel
|
93
148
|
# that the user could use assistance
|
94
|
-
Wordhop.assistanceRequested(
|
95
|
-
|
149
|
+
Wordhop.assistanceRequested(incomingMessage);
|
150
|
+
```
|
151
|
+
|
152
|
+
##### Human Take Over:
|
153
|
+
|
154
|
+
To enable the ability to have a human take over your bot, add the following code:
|
155
|
+
|
156
|
+
```ruby
|
157
|
+
# Handle forwarding the messages sent by a human through your bot
|
158
|
+
Wordhop.on :'chat response' do |data|
|
159
|
+
Bot.deliver(data, access_token: ENV['ACCESS_TOKEN']) # <= example of bot sending message
|
160
|
+
end
|
96
161
|
```
|
97
162
|
|
98
163
|
Go back to Slack and wait for alerts. That's it!
|
99
|
-
[Be sure to check out our
|
164
|
+
[Be sure to check out our examples.](./examples/)
|
100
165
|
|
101
166
|
|
102
167
|
### Looking for something we don't yet support?
|
data/lib/wordhop.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wordhop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
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: 2016-12-
|
11
|
+
date: 2016-12-12 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
|