stealth-smooch 1.0.0 → 1.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfd16ef8aa0444746d2b4e52e2211e839f76bf15e1a963b3c0099226eb4c9622
4
- data.tar.gz: 773e786a3c0dcfddf7b450f20202c9d7dafae8947896ac0b6bb4c8a63fc9b91a
3
+ metadata.gz: 4ec637b1d5664a634fff6b742b4cbcf8c115835f74848d8c0de6de7963943276
4
+ data.tar.gz: 7142f76a257fba8763b25093a72bf129fec2c787cd4a4cb4ebd33a5a645f573d
5
5
  SHA512:
6
- metadata.gz: f863b5964a68861faca37abb857b0fd35f062017eee812b72813de66c09c35db1e6d5bad43f4e3c7702a4b49af23e2a4d4cdfb36403da03e4ca9740e87bb80a8
7
- data.tar.gz: c53ea4f8ea0926d41c89c3d32ed0ece592526bd6ed71bf097fba488451ba06c82b12aea2455ed851a7b31c6240f3f9a51aadeb3d0f4902b228a91863af538871
6
+ metadata.gz: ce1d907d02b7f48cfb7947181cd3e7e9cc8b74235b9a039e4c8f758eb73f61ee82cf0ca5bd730ca10239853c1eb2f7b4f9b771f2c87e18bb612f1a29aeb1df50
7
+ data.tar.gz: 67b0a4f0f04b74f5a1c72aea65d8ca0a7bf7f0330a29efa045f02ac7bf6900dd25423199ec4fb46c28cc298f909e290c87ac340f117de3c564e660ff2c48bbb8
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stealth-smooch (0.9.1)
4
+ stealth-smooch (1.1.0)
5
5
  jwt (~> 2.1)
6
6
  smooch-api (~> 5.3)
7
7
  stealth (< 2.0)
@@ -40,7 +40,7 @@ GEM
40
40
  rspec-mocks (~> 3.8.0)
41
41
  rspec-core (3.8.0)
42
42
  rspec-support (~> 3.8.0)
43
- rspec-expectations (3.8.1)
43
+ rspec-expectations (3.8.2)
44
44
  diff-lcs (>= 1.2.0, < 2.0)
45
45
  rspec-support (~> 3.8.0)
46
46
  rspec-mocks (3.8.0)
@@ -59,10 +59,10 @@ GEM
59
59
  rack (~> 2.0)
60
60
  rack-protection (= 2.0.5)
61
61
  tilt (~> 2.0)
62
- smooch-api (5.3.0)
62
+ smooch-api (5.5.0)
63
63
  json (~> 1.8, >= 1.8.3)
64
64
  typhoeus (~> 1.0, >= 1.0.1)
65
- stealth (1.1.3)
65
+ stealth (1.1.4)
66
66
  activesupport (~> 5.2)
67
67
  multi_json (~> 1.12)
68
68
  puma (~> 3.10)
@@ -87,4 +87,4 @@ DEPENDENCIES
87
87
  stealth-smooch!
88
88
 
89
89
  BUNDLED WITH
90
- 1.17.2
90
+ 1.17.3
data/README.md CHANGED
@@ -19,6 +19,14 @@ Stealth::Services::Smooch::Client.generate_jwt_token
19
19
 
20
20
  It will output the JWT token based on the `app_id`, `key_id`, and `secret` from your `services.yml` file.
21
21
 
22
+ ### Webhooks
23
+
24
+ <img src='smooch-webhooks.png' height='450' alt='Smooch Webhook Config' aria-label='Smooch Webhook Config' />
25
+
26
+ You will want to add the `Webhooks` integration to the Smooch app you created above. Currently, this driver supports `AppUser messages`, `Postbacks`, and the `Conversation Start` webhooks.
27
+
28
+ **Please note:** the `Conversation Start` webhook is configured to send a payload with the value of `conversation_start`. Please handle that accordingly in your `BotController`.
29
+
22
30
  ## Configure the Integration
23
31
 
24
32
  ```yaml
@@ -50,7 +58,7 @@ test:
50
58
  Additionally, you will need to create an initializer called `smooch.rb` in `config/initializers`:
51
59
 
52
60
  ```ruby
53
- SmoochApi.configure do |config|
61
+ SmoochApi.configure do |config|
54
62
  config.api_key['Authorization'] = Stealth.config.smooch.jwt_token
55
63
  config.api_key_prefix['Authorization'] = 'Bearer'
56
64
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.1.0
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ module Stealth
5
+ module Services
6
+ module Smooch
7
+
8
+ class ConversationStartEvent
9
+
10
+ attr_reader :service_message, :params
11
+
12
+ def initialize(service_message:, params:)
13
+ @service_message = service_message
14
+ @params = params
15
+ end
16
+
17
+ def process
18
+ service_message.payload = 'conversation_start'
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -3,6 +3,7 @@
3
3
 
4
4
  require 'stealth/services/smooch/events/message_event'
5
5
  require 'stealth/services/smooch/events/postback_event'
6
+ require 'stealth/services/smooch/events/conversation_start_event'
6
7
 
7
8
  module Stealth
8
9
  module Services
@@ -64,6 +65,13 @@ module Stealth
64
65
  service_message: service_message,
65
66
  params: smooch_postback
66
67
  )
68
+ elsif smooch_response['trigger'] == 'conversation:start'
69
+ service_message.timestamp = Time.at(smooch_response['timestamp']).to_datetime
70
+
71
+ message_event = Stealth::Services::Smooch::ConversationStartEvent.new(
72
+ service_message: service_message,
73
+ params: smooch_response
74
+ )
67
75
  end
68
76
 
69
77
  message_event.process
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stealth-smooch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mauricio Gomes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-22 00:00:00.000000000 Z
11
+ date: 2019-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: stealth
@@ -108,6 +108,7 @@ files:
108
108
  - VERSION
109
109
  - lib/stealth-smooch.rb
110
110
  - lib/stealth/services/smooch/client.rb
111
+ - lib/stealth/services/smooch/events/conversation_start_event.rb
111
112
  - lib/stealth/services/smooch/events/message_event.rb
112
113
  - lib/stealth/services/smooch/events/postback_event.rb
113
114
  - lib/stealth/services/smooch/message_handler.rb
@@ -115,6 +116,7 @@ files:
115
116
  - lib/stealth/services/smooch/setup.rb
116
117
  - lib/stealth/services/smooch/version.rb
117
118
  - lib/stealth/smooch.rb
119
+ - smooch-webhooks.png
118
120
  - spec/spec_helper.rb
119
121
  - spec/version_spec.rb
120
122
  - stealth-smooch.gemspec
@@ -137,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
139
  - !ruby/object:Gem::Version
138
140
  version: '0'
139
141
  requirements: []
140
- rubygems_version: 3.0.1
142
+ rubygems_version: 3.0.2
141
143
  signing_key:
142
144
  specification_version: 4
143
145
  summary: Stealth Smooch driver