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: a97b014f458381225a5cf3b76148fdf1b240348a
4
- data.tar.gz: 6a3d1c139c2aa42f3891864b1080b8af1f782ecc
3
+ metadata.gz: 74caac0b724839aa50f8bed0364c1af2d648644f
4
+ data.tar.gz: 72d8baa4473043a681a43f888aab08632dc325a2
5
5
  SHA512:
6
- metadata.gz: bb9b1c17ab1057e49489153deb9fa94384abcbe550114101f1b2f16cdd5b8b3fba9b8640b241af14ada44f51f1502b345e1168d5b7e089144f4b7afd50be4ecc
7
- data.tar.gz: d4b2d577c290b9caf6cb02861f6a1e592bb2e313918e875d5a4055db3751da9eec7651af67fcfe82b7213b7a561e823a5e8affb9c8c81121db3dd4e25bd97a0c
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
- #### Set a welcome message
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::Welcome.set text: 'Hello, human!'
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
@@ -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/welcome'
4
+ require 'facebook/messenger/thread'
5
5
  require 'facebook/messenger/bot'
6
6
  require 'facebook/messenger/server'
7
7
  require 'facebook/messenger/configuration'
@@ -17,6 +17,10 @@ module Facebook
17
17
  @messaging['sender']
18
18
  end
19
19
 
20
+ def recipient
21
+ @messaging['recipient']
22
+ end
23
+
20
24
  def seq
21
25
  @messaging['message']['seq']
22
26
  end
@@ -2,10 +2,10 @@ require 'httparty'
2
2
 
3
3
  module Facebook
4
4
  module Messenger
5
- # This module handles setting welcome messages.
5
+ # This module handles changing thread settings.
6
6
  #
7
- # https://developers.facebook.com/docs/messenger-platform/send-api-reference#welcome_message_configuration
8
- module Welcome
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(message)
17
+ def set(settings)
18
18
  response = post '/thread_settings',
19
- body: welcome_setting_for(message).to_json
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 = post '/thread_settings',
28
- body: welcome_setting_for(nil).to_json
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
@@ -1,5 +1,5 @@
1
1
  module Facebook
2
2
  module Messenger
3
- VERSION = '0.7.0'.freeze
3
+ VERSION = '0.8.0'.freeze
4
4
  end
5
5
  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.7.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-06-26 00:00:00.000000000 Z
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