facebook-messenger 0.7.0 → 0.8.0
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74caac0b724839aa50f8bed0364c1af2d648644f
|
4
|
+
data.tar.gz: 72d8baa4473043a681a43f888aab08632dc325a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7714a102ac46e9da46277b21b585c5a7e537d926a31471a4ba6cb4966168751cb52a8471136f3c809dc23a9ed75aa0d013a8b37e201b0f26c7b5058e5f0b4c9c
|
7
|
+
data.tar.gz: a88801bcff664d54f7bddb67cfddcb6a50b900fcbe61184dca1a8299b9f87694a1883a96e504d13ce8bd47646010efb235b568637ebb91dce16756c867730d28
|
data/README.md
CHANGED
@@ -155,12 +155,58 @@ Bot.on :delivery do |delivery|
|
|
155
155
|
end
|
156
156
|
```
|
157
157
|
|
158
|
-
####
|
158
|
+
#### Change thread settings
|
159
159
|
|
160
160
|
You can greet new humans to entice them into talking to you:
|
161
161
|
|
162
162
|
```ruby
|
163
|
-
Facebook::Messenger::
|
163
|
+
Facebook::Messenger::Thread.set(
|
164
|
+
setting_type: 'greeting',
|
165
|
+
greeting: {
|
166
|
+
text: 'Welcome to your new bot overlord!'
|
167
|
+
}
|
168
|
+
)
|
169
|
+
```
|
170
|
+
|
171
|
+
You can define the action to trigger when new humans click on the Get
|
172
|
+
Started button.
|
173
|
+
|
174
|
+
```ruby
|
175
|
+
Facebook::Messenger::Thread.set(
|
176
|
+
setting_type: 'call_to_actions',
|
177
|
+
thread_state: 'new_thread',
|
178
|
+
call_to_actions: [
|
179
|
+
{
|
180
|
+
payload: 'DEVELOPER_DEFINED_PAYLOAD_FOR_WELCOME'
|
181
|
+
}
|
182
|
+
]
|
183
|
+
)
|
184
|
+
```
|
185
|
+
|
186
|
+
You can show a persistent menu to humans.
|
187
|
+
|
188
|
+
```ruby
|
189
|
+
Facebook::Messenger::Thread.set(
|
190
|
+
setting_type: 'call_to_actions',
|
191
|
+
thread_state: 'existing_thread',
|
192
|
+
call_to_actions: [
|
193
|
+
{
|
194
|
+
type: 'postback',
|
195
|
+
title: 'Help',
|
196
|
+
payload: 'DEVELOPER_DEFINED_PAYLOAD_FOR_HELP'
|
197
|
+
},
|
198
|
+
{
|
199
|
+
type: 'postback',
|
200
|
+
title: 'Start a New Order',
|
201
|
+
payload: 'DEVELOPER_DEFINED_PAYLOAD_FOR_START_ORDER'
|
202
|
+
},
|
203
|
+
{
|
204
|
+
type: 'web_url',
|
205
|
+
title: 'View Website',
|
206
|
+
url: 'http://example.com/'
|
207
|
+
}
|
208
|
+
]
|
209
|
+
)
|
164
210
|
```
|
165
211
|
|
166
212
|
## Configuration
|
@@ -175,6 +221,9 @@ token of your choosing.
|
|
175
221
|
|
176
222
|
![Application settings](https://scontent-amt2-1.xx.fbcdn.net/hphotos-xfp1/t39.2178-6/12057143_211110782612505_894181129_n.png)
|
177
223
|
|
224
|
+
*Note*: Don't subscribe to `message_echoes`; it'll echo your bot's own messages
|
225
|
+
back to you, effectively DDOSing yourself.
|
226
|
+
|
178
227
|
Use the generated access token and your verify token to configure your bot:
|
179
228
|
|
180
229
|
##### ... pass a block, or
|
data/lib/facebook/messenger.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'facebook/messenger/version'
|
2
2
|
require 'facebook/messenger/error'
|
3
3
|
require 'facebook/messenger/subscriptions'
|
4
|
-
require 'facebook/messenger/
|
4
|
+
require 'facebook/messenger/thread'
|
5
5
|
require 'facebook/messenger/bot'
|
6
6
|
require 'facebook/messenger/server'
|
7
7
|
require 'facebook/messenger/configuration'
|
@@ -2,10 +2,10 @@ require 'httparty'
|
|
2
2
|
|
3
3
|
module Facebook
|
4
4
|
module Messenger
|
5
|
-
# This module handles
|
5
|
+
# This module handles changing thread settings.
|
6
6
|
#
|
7
|
-
# https://developers.facebook.com/docs/messenger-platform/
|
8
|
-
module
|
7
|
+
# https://developers.facebook.com/docs/messenger-platform/thread-settings
|
8
|
+
module Thread
|
9
9
|
include HTTParty
|
10
10
|
|
11
11
|
base_uri 'https://graph.facebook.com/v2.6/me'
|
@@ -14,18 +14,18 @@ module Facebook
|
|
14
14
|
|
15
15
|
module_function
|
16
16
|
|
17
|
-
def set(
|
17
|
+
def set(settings)
|
18
18
|
response = post '/thread_settings',
|
19
|
-
body:
|
19
|
+
body: settings.to_json
|
20
20
|
|
21
21
|
raise_errors(response)
|
22
22
|
|
23
23
|
true
|
24
24
|
end
|
25
25
|
|
26
|
-
def unset
|
27
|
-
response =
|
28
|
-
|
26
|
+
def unset(settings)
|
27
|
+
response = delete '/thread_settings',
|
28
|
+
body: settings.to_json
|
29
29
|
|
30
30
|
raise_errors(response)
|
31
31
|
|
@@ -47,14 +47,6 @@ module Facebook
|
|
47
47
|
)
|
48
48
|
end
|
49
49
|
|
50
|
-
def welcome_setting_for(payload)
|
51
|
-
{
|
52
|
-
setting_type: 'call_to_actions',
|
53
|
-
thread_state: 'new_thread',
|
54
|
-
call_to_actions: payload ? [{ message: payload }] : []
|
55
|
-
}
|
56
|
-
end
|
57
|
-
|
58
50
|
class Error < Facebook::Messenger::Error; end
|
59
51
|
end
|
60
52
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: facebook-messenger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johannes Gorset
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -172,8 +172,8 @@ files:
|
|
172
172
|
- lib/facebook/messenger/incoming/read.rb
|
173
173
|
- lib/facebook/messenger/server.rb
|
174
174
|
- lib/facebook/messenger/subscriptions.rb
|
175
|
+
- lib/facebook/messenger/thread.rb
|
175
176
|
- lib/facebook/messenger/version.rb
|
176
|
-
- lib/facebook/messenger/welcome.rb
|
177
177
|
homepage: https://github.com/hyperoslo/facebook-messenger
|
178
178
|
licenses:
|
179
179
|
- MIT
|