stealth 1.1.5 → 2.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +27 -11
  3. data/CHANGELOG.md +77 -0
  4. data/Gemfile +1 -1
  5. data/Gemfile.lock +53 -49
  6. data/LICENSE +4 -17
  7. data/README.md +9 -17
  8. data/VERSION +1 -1
  9. data/lib/stealth/base.rb +72 -21
  10. data/lib/stealth/cli.rb +1 -2
  11. data/lib/stealth/commands/console.rb +1 -1
  12. data/lib/stealth/configuration.rb +6 -3
  13. data/lib/stealth/controller/callbacks.rb +1 -1
  14. data/lib/stealth/controller/catch_all.rb +27 -4
  15. data/lib/stealth/controller/controller.rb +168 -49
  16. data/lib/stealth/controller/dev_jumps.rb +41 -0
  17. data/lib/stealth/controller/dynamic_delay.rb +4 -6
  18. data/lib/stealth/controller/interrupt_detect.rb +100 -0
  19. data/lib/stealth/controller/messages.rb +283 -0
  20. data/lib/stealth/controller/nlp.rb +50 -0
  21. data/lib/stealth/controller/replies.rb +183 -40
  22. data/lib/stealth/controller/unrecognized_message.rb +62 -0
  23. data/lib/stealth/{flow/core_ext.rb → core_ext/numeric.rb} +0 -1
  24. data/lib/stealth/core_ext/string.rb +18 -0
  25. data/lib/stealth/core_ext.rb +5 -0
  26. data/lib/stealth/dispatcher.rb +21 -0
  27. data/lib/stealth/errors.rb +12 -0
  28. data/lib/stealth/flow/base.rb +1 -2
  29. data/lib/stealth/flow/specification.rb +3 -2
  30. data/lib/stealth/flow/state.rb +3 -3
  31. data/lib/stealth/generators/builder/Gemfile +4 -3
  32. data/lib/stealth/generators/builder/bot/controllers/bot_controller.rb +42 -0
  33. data/lib/stealth/generators/builder/bot/controllers/catch_alls_controller.rb +2 -0
  34. data/lib/stealth/generators/builder/bot/controllers/goodbyes_controller.rb +2 -0
  35. data/lib/stealth/generators/builder/bot/controllers/hellos_controller.rb +2 -0
  36. data/lib/stealth/generators/builder/bot/controllers/interrupts_controller.rb +9 -0
  37. data/lib/stealth/generators/builder/bot/controllers/unrecognized_messages_controller.rb +9 -0
  38. data/lib/stealth/generators/builder/config/flow_map.rb +8 -0
  39. data/lib/stealth/generators/builder/config/initializers/autoload.rb +8 -0
  40. data/lib/stealth/generators/builder/config/initializers/inflections.rb +16 -0
  41. data/lib/stealth/generators/builder/config/puma.rb +15 -0
  42. data/lib/stealth/helpers/redis.rb +40 -0
  43. data/lib/stealth/lock.rb +83 -0
  44. data/lib/stealth/logger.rb +27 -18
  45. data/lib/stealth/nlp/client.rb +22 -0
  46. data/lib/stealth/nlp/result.rb +57 -0
  47. data/lib/stealth/reloader.rb +90 -0
  48. data/lib/stealth/reply.rb +17 -0
  49. data/lib/stealth/scheduled_reply.rb +3 -3
  50. data/lib/stealth/server.rb +8 -3
  51. data/lib/stealth/service_message.rb +3 -2
  52. data/lib/stealth/service_reply.rb +5 -1
  53. data/lib/stealth/services/base_reply_handler.rb +10 -2
  54. data/lib/stealth/session.rb +106 -53
  55. data/spec/configuration_spec.rb +42 -2
  56. data/spec/controller/callbacks_spec.rb +23 -28
  57. data/spec/controller/catch_all_spec.rb +87 -29
  58. data/spec/controller/controller_spec.rb +444 -43
  59. data/spec/controller/dynamic_delay_spec.rb +16 -18
  60. data/spec/controller/helpers_spec.rb +1 -2
  61. data/spec/controller/interrupt_detect_spec.rb +171 -0
  62. data/spec/controller/messages_spec.rb +744 -0
  63. data/spec/controller/nlp_spec.rb +93 -0
  64. data/spec/controller/replies_spec.rb +446 -11
  65. data/spec/controller/unrecognized_message_spec.rb +168 -0
  66. data/spec/dispatcher_spec.rb +79 -0
  67. data/spec/flow/flow_spec.rb +1 -2
  68. data/spec/flow/state_spec.rb +14 -3
  69. data/spec/helpers/redis_spec.rb +77 -0
  70. data/spec/lock_spec.rb +100 -0
  71. data/spec/nlp/client_spec.rb +23 -0
  72. data/spec/nlp/result_spec.rb +57 -0
  73. data/spec/replies/messages/say_msgs_without_breaks.yml +4 -0
  74. data/spec/replies/messages/say_randomize_speech.yml +10 -0
  75. data/spec/replies/messages/say_randomize_text.yml +10 -0
  76. data/spec/replies/messages/sub1/sub2/say_nested.yml +10 -0
  77. data/spec/reply_spec.rb +61 -0
  78. data/spec/scheduled_reply_spec.rb +23 -0
  79. data/spec/service_reply_spec.rb +1 -2
  80. data/spec/session_spec.rb +251 -12
  81. data/spec/spec_helper.rb +21 -0
  82. data/spec/support/controllers/vaders_controller.rb +24 -0
  83. data/spec/support/nlp_clients/dialogflow.rb +9 -0
  84. data/spec/support/nlp_clients/luis.rb +9 -0
  85. data/spec/support/nlp_results/luis_result.rb +163 -0
  86. data/spec/version_spec.rb +1 -2
  87. data/stealth.gemspec +6 -6
  88. metadata +83 -38
  89. data/docs/00-introduction.md +0 -37
  90. data/docs/01-getting-started.md +0 -21
  91. data/docs/02-local-development.md +0 -40
  92. data/docs/03-basics.md +0 -171
  93. data/docs/04-sessions.md +0 -29
  94. data/docs/05-controllers.md +0 -179
  95. data/docs/06-models.md +0 -39
  96. data/docs/07-replies.md +0 -114
  97. data/docs/08-catchalls.md +0 -49
  98. data/docs/09-messaging-integrations.md +0 -80
  99. data/docs/10-nlp-integrations.md +0 -13
  100. data/docs/11-analytics.md +0 -13
  101. data/docs/12-commands.md +0 -62
  102. data/docs/13-deployment.md +0 -50
  103. data/lib/stealth/generators/builder/config/initializers/.keep +0 -0
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stealth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 2.0.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mauricio Gomes
8
8
  - Matthew Black
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-02-13 00:00:00.000000000 Z
12
+ date: 2021-12-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
@@ -29,30 +29,36 @@ dependencies:
29
29
  name: puma
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - "~>"
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '4.2'
35
+ - - "<"
33
36
  - !ruby/object:Gem::Version
34
- version: '3.10'
37
+ version: '6.0'
35
38
  type: :runtime
36
39
  prerelease: false
37
40
  version_requirements: !ruby/object:Gem::Requirement
38
41
  requirements:
39
- - - "~>"
42
+ - - ">="
40
43
  - !ruby/object:Gem::Version
41
- version: '3.10'
44
+ version: '4.2'
45
+ - - "<"
46
+ - !ruby/object:Gem::Version
47
+ version: '6.0'
42
48
  - !ruby/object:Gem::Dependency
43
49
  name: thor
44
50
  requirement: !ruby/object:Gem::Requirement
45
51
  requirements:
46
52
  - - "~>"
47
53
  - !ruby/object:Gem::Version
48
- version: '0.20'
54
+ version: '1.0'
49
55
  type: :runtime
50
56
  prerelease: false
51
57
  version_requirements: !ruby/object:Gem::Requirement
52
58
  requirements:
53
59
  - - "~>"
54
60
  - !ruby/object:Gem::Version
55
- version: '0.20'
61
+ version: '1.0'
56
62
  - !ruby/object:Gem::Dependency
57
63
  name: multi_json
58
64
  requirement: !ruby/object:Gem::Requirement
@@ -73,42 +79,42 @@ dependencies:
73
79
  requirements:
74
80
  - - "~>"
75
81
  - !ruby/object:Gem::Version
76
- version: '5.0'
82
+ version: '6.0'
77
83
  type: :runtime
78
84
  prerelease: false
79
85
  version_requirements: !ruby/object:Gem::Requirement
80
86
  requirements:
81
87
  - - "~>"
82
88
  - !ruby/object:Gem::Version
83
- version: '5.0'
89
+ version: '6.0'
84
90
  - !ruby/object:Gem::Dependency
85
91
  name: activesupport
86
92
  requirement: !ruby/object:Gem::Requirement
87
93
  requirements:
88
94
  - - "~>"
89
95
  - !ruby/object:Gem::Version
90
- version: '5.2'
96
+ version: '6.0'
91
97
  type: :runtime
92
98
  prerelease: false
93
99
  version_requirements: !ruby/object:Gem::Requirement
94
100
  requirements:
95
101
  - - "~>"
96
102
  - !ruby/object:Gem::Version
97
- version: '5.2'
103
+ version: '6.0'
98
104
  - !ruby/object:Gem::Dependency
99
105
  name: rspec
100
106
  requirement: !ruby/object:Gem::Requirement
101
107
  requirements:
102
108
  - - "~>"
103
109
  - !ruby/object:Gem::Version
104
- version: '3.6'
110
+ version: '3.9'
105
111
  type: :development
106
112
  prerelease: false
107
113
  version_requirements: !ruby/object:Gem::Requirement
108
114
  requirements:
109
115
  - - "~>"
110
116
  - !ruby/object:Gem::Version
111
- version: '3.6'
117
+ version: '3.9'
112
118
  - !ruby/object:Gem::Dependency
113
119
  name: rspec_junit_formatter
114
120
  requirement: !ruby/object:Gem::Requirement
@@ -143,14 +149,14 @@ dependencies:
143
149
  requirements:
144
150
  - - "~>"
145
151
  - !ruby/object:Gem::Version
146
- version: '0.17'
152
+ version: '0.22'
147
153
  type: :development
148
154
  prerelease: false
149
155
  version_requirements: !ruby/object:Gem::Requirement
150
156
  requirements:
151
157
  - - "~>"
152
158
  - !ruby/object:Gem::Version
153
- version: '0.17'
159
+ version: '0.22'
154
160
  description: Ruby framework for building conversational bots.
155
161
  email: mauricio@edge14.com
156
162
  executables:
@@ -167,20 +173,6 @@ files:
167
173
  - README.md
168
174
  - VERSION
169
175
  - bin/stealth
170
- - docs/00-introduction.md
171
- - docs/01-getting-started.md
172
- - docs/02-local-development.md
173
- - docs/03-basics.md
174
- - docs/04-sessions.md
175
- - docs/05-controllers.md
176
- - docs/06-models.md
177
- - docs/07-replies.md
178
- - docs/08-catchalls.md
179
- - docs/09-messaging-integrations.md
180
- - docs/10-nlp-integrations.md
181
- - docs/11-analytics.md
182
- - docs/12-commands.md
183
- - docs/13-deployment.md
184
176
  - lib/stealth.rb
185
177
  - lib/stealth/base.rb
186
178
  - lib/stealth/cli.rb
@@ -192,13 +184,20 @@ files:
192
184
  - lib/stealth/controller/callbacks.rb
193
185
  - lib/stealth/controller/catch_all.rb
194
186
  - lib/stealth/controller/controller.rb
187
+ - lib/stealth/controller/dev_jumps.rb
195
188
  - lib/stealth/controller/dynamic_delay.rb
196
189
  - lib/stealth/controller/helpers.rb
190
+ - lib/stealth/controller/interrupt_detect.rb
191
+ - lib/stealth/controller/messages.rb
192
+ - lib/stealth/controller/nlp.rb
197
193
  - lib/stealth/controller/replies.rb
194
+ - lib/stealth/controller/unrecognized_message.rb
195
+ - lib/stealth/core_ext.rb
196
+ - lib/stealth/core_ext/numeric.rb
197
+ - lib/stealth/core_ext/string.rb
198
198
  - lib/stealth/dispatcher.rb
199
199
  - lib/stealth/errors.rb
200
200
  - lib/stealth/flow/base.rb
201
- - lib/stealth/flow/core_ext.rb
202
201
  - lib/stealth/flow/specification.rb
203
202
  - lib/stealth/flow/state.rb
204
203
  - lib/stealth/generators/builder.rb
@@ -212,6 +211,8 @@ files:
212
211
  - lib/stealth/generators/builder/bot/controllers/concerns/.keep
213
212
  - lib/stealth/generators/builder/bot/controllers/goodbyes_controller.rb
214
213
  - lib/stealth/generators/builder/bot/controllers/hellos_controller.rb
214
+ - lib/stealth/generators/builder/bot/controllers/interrupts_controller.rb
215
+ - lib/stealth/generators/builder/bot/controllers/unrecognized_messages_controller.rb
215
216
  - lib/stealth/generators/builder/bot/helpers/bot_helper.rb
216
217
  - lib/stealth/generators/builder/bot/models/bot_record.rb
217
218
  - lib/stealth/generators/builder/bot/models/concerns/.keep
@@ -223,7 +224,8 @@ files:
223
224
  - lib/stealth/generators/builder/config/database.yml
224
225
  - lib/stealth/generators/builder/config/environment.rb
225
226
  - lib/stealth/generators/builder/config/flow_map.rb
226
- - lib/stealth/generators/builder/config/initializers/.keep
227
+ - lib/stealth/generators/builder/config/initializers/autoload.rb
228
+ - lib/stealth/generators/builder/config/initializers/inflections.rb
227
229
  - lib/stealth/generators/builder/config/puma.rb
228
230
  - lib/stealth/generators/builder/config/services.yml
229
231
  - lib/stealth/generators/builder/config/sidekiq.yml
@@ -232,12 +234,17 @@ files:
232
234
  - lib/stealth/generators/generate/flow/controllers/controller.tt
233
235
  - lib/stealth/generators/generate/flow/helpers/helper.tt
234
236
  - lib/stealth/generators/generate/flow/replies/ask_example.tt
237
+ - lib/stealth/helpers/redis.rb
235
238
  - lib/stealth/jobs.rb
239
+ - lib/stealth/lock.rb
236
240
  - lib/stealth/logger.rb
237
241
  - lib/stealth/migrations/configurator.rb
238
242
  - lib/stealth/migrations/generators.rb
239
243
  - lib/stealth/migrations/railtie_config.rb
240
244
  - lib/stealth/migrations/tasks.rb
245
+ - lib/stealth/nlp/client.rb
246
+ - lib/stealth/nlp/result.rb
247
+ - lib/stealth/reloader.rb
241
248
  - lib/stealth/reply.rb
242
249
  - lib/stealth/scheduled_reply.rb
243
250
  - lib/stealth/server.rb
@@ -256,27 +263,46 @@ files:
256
263
  - spec/controller/controller_spec.rb
257
264
  - spec/controller/dynamic_delay_spec.rb
258
265
  - spec/controller/helpers_spec.rb
266
+ - spec/controller/interrupt_detect_spec.rb
267
+ - spec/controller/messages_spec.rb
268
+ - spec/controller/nlp_spec.rb
259
269
  - spec/controller/replies_spec.rb
270
+ - spec/controller/unrecognized_message_spec.rb
271
+ - spec/dispatcher_spec.rb
260
272
  - spec/flow/flow_spec.rb
261
273
  - spec/flow/state_spec.rb
274
+ - spec/helpers/redis_spec.rb
275
+ - spec/lock_spec.rb
276
+ - spec/nlp/client_spec.rb
277
+ - spec/nlp/result_spec.rb
262
278
  - spec/replies/hello.yml.erb
263
279
  - spec/replies/messages/say_hola.yml+facebook.erb
264
280
  - spec/replies/messages/say_hola.yml+twilio.erb
265
281
  - spec/replies/messages/say_hola.yml.erb
266
282
  - spec/replies/messages/say_howdy_with_dynamic.yml
283
+ - spec/replies/messages/say_msgs_without_breaks.yml
267
284
  - spec/replies/messages/say_offer.yml
268
285
  - spec/replies/messages/say_offer_with_dynamic.yml
269
286
  - spec/replies/messages/say_oi.yml.erb
287
+ - spec/replies/messages/say_randomize_speech.yml
288
+ - spec/replies/messages/say_randomize_text.yml
270
289
  - spec/replies/messages/say_yo.yml
271
290
  - spec/replies/messages/say_yo.yml+twitter
291
+ - spec/replies/messages/sub1/sub2/say_nested.yml
292
+ - spec/reply_spec.rb
293
+ - spec/scheduled_reply_spec.rb
272
294
  - spec/service_reply_spec.rb
273
295
  - spec/session_spec.rb
274
296
  - spec/spec_helper.rb
275
297
  - spec/support/alternate_helpers/foo_helper.rb
298
+ - spec/support/controllers/vaders_controller.rb
276
299
  - spec/support/helpers/fun/games_helper.rb
277
300
  - spec/support/helpers/fun/pdf_helper.rb
278
301
  - spec/support/helpers/standalone_helper.rb
279
302
  - spec/support/helpers_typo/users_helper.rb
303
+ - spec/support/nlp_clients/dialogflow.rb
304
+ - spec/support/nlp_clients/luis.rb
305
+ - spec/support/nlp_results/luis_result.rb
280
306
  - spec/support/sample_messages.rb
281
307
  - spec/support/services.yml
282
308
  - spec/support/services_with_erb.yml
@@ -286,7 +312,7 @@ homepage: https://github.com/hellostealth/stealth
286
312
  licenses:
287
313
  - MIT
288
314
  metadata: {}
289
- post_install_message:
315
+ post_install_message:
290
316
  rdoc_options: []
291
317
  require_paths:
292
318
  - lib
@@ -297,12 +323,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
297
323
  version: '0'
298
324
  required_rubygems_version: !ruby/object:Gem::Requirement
299
325
  requirements:
300
- - - ">="
326
+ - - ">"
301
327
  - !ruby/object:Gem::Version
302
- version: '0'
328
+ version: 1.3.1
303
329
  requirements: []
304
- rubygems_version: 3.0.2
305
- signing_key:
330
+ rubygems_version: 3.2.32
331
+ signing_key:
306
332
  specification_version: 4
307
333
  summary: Ruby framework for conversational bots
308
334
  test_files:
@@ -312,27 +338,46 @@ test_files:
312
338
  - spec/controller/controller_spec.rb
313
339
  - spec/controller/dynamic_delay_spec.rb
314
340
  - spec/controller/helpers_spec.rb
341
+ - spec/controller/interrupt_detect_spec.rb
342
+ - spec/controller/messages_spec.rb
343
+ - spec/controller/nlp_spec.rb
315
344
  - spec/controller/replies_spec.rb
345
+ - spec/controller/unrecognized_message_spec.rb
346
+ - spec/dispatcher_spec.rb
316
347
  - spec/flow/flow_spec.rb
317
348
  - spec/flow/state_spec.rb
349
+ - spec/helpers/redis_spec.rb
350
+ - spec/lock_spec.rb
351
+ - spec/nlp/client_spec.rb
352
+ - spec/nlp/result_spec.rb
318
353
  - spec/replies/hello.yml.erb
319
354
  - spec/replies/messages/say_hola.yml+facebook.erb
320
355
  - spec/replies/messages/say_hola.yml+twilio.erb
321
356
  - spec/replies/messages/say_hola.yml.erb
322
357
  - spec/replies/messages/say_howdy_with_dynamic.yml
358
+ - spec/replies/messages/say_msgs_without_breaks.yml
323
359
  - spec/replies/messages/say_offer.yml
324
360
  - spec/replies/messages/say_offer_with_dynamic.yml
325
361
  - spec/replies/messages/say_oi.yml.erb
362
+ - spec/replies/messages/say_randomize_speech.yml
363
+ - spec/replies/messages/say_randomize_text.yml
326
364
  - spec/replies/messages/say_yo.yml
327
365
  - spec/replies/messages/say_yo.yml+twitter
366
+ - spec/replies/messages/sub1/sub2/say_nested.yml
367
+ - spec/reply_spec.rb
368
+ - spec/scheduled_reply_spec.rb
328
369
  - spec/service_reply_spec.rb
329
370
  - spec/session_spec.rb
330
371
  - spec/spec_helper.rb
331
372
  - spec/support/alternate_helpers/foo_helper.rb
373
+ - spec/support/controllers/vaders_controller.rb
332
374
  - spec/support/helpers/fun/games_helper.rb
333
375
  - spec/support/helpers/fun/pdf_helper.rb
334
376
  - spec/support/helpers/standalone_helper.rb
335
377
  - spec/support/helpers_typo/users_helper.rb
378
+ - spec/support/nlp_clients/dialogflow.rb
379
+ - spec/support/nlp_clients/luis.rb
380
+ - spec/support/nlp_results/luis_result.rb
336
381
  - spec/support/sample_messages.rb
337
382
  - spec/support/services.yml
338
383
  - spec/support/services_with_erb.yml
@@ -1,37 +0,0 @@
1
- ---
2
- title: Introduction
3
- ---
4
- Stealth includes everything you need to build amazing chatbots with tools you know and love.
5
-
6
- ## Assumptions
7
-
8
- These docs are designed for intermediate Ruby developers who want to get started with the Stealth framework.
9
-
10
- If you do not yet have experience with Ruby, we would recommend checking out these guides first:
11
-
12
- - [Official Ruby website](https://www.ruby-lang.org/en/documentation/)
13
- - [List of Free Programming Books](https://github.com/EbookFoundation/free-programming-books/blob/master/free-programming-books.md#ruby)
14
-
15
- ## What is Stealth?
16
-
17
- Stealth is an open source Ruby framework for conversational voice and text chatbots.
18
-
19
- Stealth is inspired by the Model-View-Controller (MVC) pattern. However, instead of calling them *Views* Stealth refers to them as *Replies* to better match the chatbot domain.
20
-
21
- - The [Model](#models) layer represents your data model (such as Account, User, Quote, etc.) and encapsulates the business logic that is specific to your bot. By default, Stealth uses [ActiveRecord](#models.active_record).
22
-
23
- - The [Controller](#controllers) layer is responsible for handling incoming requests from messaging platforms and providing and transmitting the response (reply).
24
-
25
- - The [Reply](#replies) layer is composed of "templates" that are responsible for constructing the respective response.
26
-
27
- In addition to being inspired by Model-View-Controller (MVC) pattern, Stealth as a few other awesome things built in for you.
28
-
29
- - **Plug and play services.** Every service integration in Stealth is a Ruby gem. One bot can support [multiple chat services](#messaging_integrations) (i.e. Facebook Messenger, SMS, Alexa, and more) and multiple NLP/NLU services.
30
-
31
- - **Advanced tooling.** From web servers to continuous integration testing, Stealth is built to take advantage of all the great work done by the web development community.
32
-
33
- - **Hosting you know.** Stealth is a Rack application. That means your bots can be [deployed](#deployment) using familiar services like Docker and Heroku.
34
-
35
- - **Ready for production.** Stealth already powers bots for large, well-known brands including: Humana, TradeStation, Haven Life, and BarkBox.
36
-
37
- - **Open source.** Stealth is MIT licensed to ensure you own your bot. More importantly, we welcome contributors to help make Stealth even better.
@@ -1,21 +0,0 @@
1
- ---
2
- title: Getting Started
3
- ---
4
-
5
- ## Ruby
6
-
7
- Stealth has been tested on Ruby (MRI) `2.4.x` and `2.5.x`. While we don't require any C-based Ruby gems, we haven't yet certified Stealth on other VMs (such as JRuby).
8
-
9
- ## Installation
10
-
11
- You can install Stealth via RubyGems:
12
-
13
- ```
14
- gem install stealth
15
- ```
16
-
17
- Next, you can create a new Stealth bot:
18
-
19
- ```
20
- stealth new <bot_name>
21
- ```
@@ -1,40 +0,0 @@
1
- ---
2
- title: Local Development
3
- ---
4
-
5
- ## Prerequisites
6
-
7
- Stealth bundles [Sidekiq](https://github.com/mperham/sidekiq) in order to process background jobs. Therefore, it is required to run Redis in order to boot up a Stealth server.
8
-
9
- ## Starting the Server
10
-
11
- Once you have made your current working directory your Stealth bot, you can install gems:
12
-
13
- ```
14
- bundle install
15
- ```
16
-
17
- To boot your bot:
18
-
19
- ```
20
- stealth server
21
- ```
22
-
23
- You can also use `stealth s`. This will use the [foreman](https://github.com/ddollar/foreman) gem to start the web server and Sidekiq processes together. Redis will have to be running for the server to start.
24
-
25
- That's it! You are now running Stealth.
26
-
27
- ## Introspectable Tunnels to localhost
28
-
29
- When developing locally, messaging services require access to your server in order to transmit user messages. We recommend downloading and using [ngrok](https://ngrok.com/download) to create a local tunnel to your development machine.
30
-
31
- 1. Download [ngrok](https://ngrok.com/download)
32
- 2. Start your Stealth server as detailed above.
33
- 3. Open up an ngrok tunnel to your Stealth server and port (default 5000) like this: `ngrok http 5000`. ngrok will output a unique ngrok local tunnel URL to your machine.
34
-
35
- When you provide your local ngrok URL to a messaging service, you will have to add `/incoming/<service>`. For example:
36
-
37
- * `https://abc1234.ngrok.io/incoming/facebook`
38
- * `https://abc1234.ngrok.io/incoming/twilio`
39
-
40
- More details on service specific settings can be found on the GitHub page for each service gem.
data/docs/03-basics.md DELETED
@@ -1,171 +0,0 @@
1
- ---
2
- title: The Basics
3
- ---
4
-
5
- ## Directory Structure
6
-
7
- When you open up your Stealth bot you will see the following file structure:
8
-
9
- ```
10
- ├── Gemfile
11
- ├── Procfile.dev
12
- ├── README.md
13
- ├── Rakefile
14
- ├── bot
15
- │   ├── controllers
16
- │   │   ├── bot_controller.rb
17
- │   │   ├── catch_alls_controller.rb
18
- │   │   ├── concerns
19
- │   │   ├── goodbyes_controller.rb
20
- │   │   └── hellos_controller.rb
21
- │   ├── helpers
22
- │   │   └── bot_helper.rb
23
- │   ├── models
24
- │   │   ├── bot_record.rb
25
- │   │   └── concerns
26
- │   └── replies
27
- │   ├── catch_alls
28
- │   │   └── level1.yml
29
- │   ├── goodbyes
30
- │   │   └── say_goodbye.yml
31
- │   └── hellos
32
- │   └── say_hello.yml
33
- ├── config
34
- │   ├── boot.rb
35
- │   ├── database.yml
36
- │   ├── environment.rb
37
- │   ├── flow_map.rb
38
- │   ├── initializers
39
- │   ├── puma.rb
40
- │   ├── services.yml
41
- │   └── sidekiq.yml
42
- ├── config.ru
43
- └── db
44
- └── seeds.rb
45
- ```
46
-
47
- ## Flows
48
-
49
- A `Flow` is a general term to describe a complete interaction between a user and the bot. Flows are comprised of `states`, like a finite state machine.
50
-
51
- For example, if a user was using your bot to receive an insurance quote, the flow might be named `quote`. Note: Stealth requires that flows be named in the singular form, like Rails.
52
-
53
- A flow consists of the following components:
54
-
55
- 1. A controller file, named in the plural form. For example, a `quote` flow would have a corresponding `QuotesController`.
56
- 2. Replies. Each flow will have a directory in the `replies` directory in plural form. Again using the `quote` flow example, the directory would named `quotes`.
57
- 3. An entry in `config/flow_map.rb`. The `FlowMap` file is where each flow and it's respective states are defined for your bot.
58
-
59
- Flows can be generated using a generator:
60
-
61
- ```
62
- stealth generate flow <NAME>
63
- ```
64
-
65
- ## FlowMap
66
-
67
- The `FlowMap` file is where each flow and it's respective states are defined for your bot. Here is an example `flow_map.rb`:
68
-
69
- ```ruby
70
- class FlowMap
71
-
72
- include Stealth::Flow
73
-
74
- flow :hello do
75
- state :say_hello
76
- state :ask_name
77
- state :get_name, fails_to: :ask_name
78
- state :say_wow, redirects_to: :say_hello
79
- state :say_bye, redirects_to: 'goodbye->say_goodbye'
80
- end
81
-
82
- flow :goodbye do
83
- state :say_goodbye
84
- end
85
-
86
- flow :catch_all do
87
- state :level1
88
- state :level2
89
- end
90
-
91
- end
92
- ```
93
-
94
- Here we have defined three flows: `hello`, `goodbye`, and `catch_all`. These are the default flows that are generated for you when you create a new bot. We have made a few changes above to highlight some functionality.
95
-
96
- Each flow consists of an arbitrary number of states. These states should each have a corresponding controller action by the same name. States also support two additional options: `fails_to` and `redirects_to` which we explain below.
97
-
98
- ## Default Flows
99
-
100
- When you generate a new Stealth bot, it comes packaged with three default flows. While you will likely add many flows of your own, we recommend keeping these three flows as they encourage good bot building practices.
101
-
102
- ## Hello & Goodbye
103
-
104
- These two flows make up the entrance and exit of your bot. We include blank examples on how to greet (say hello) and sendoff (say goodbye) your users. You can customize these flows to work with the design of your bot.
105
-
106
- ## CatchAll
107
-
108
- Stealth also comes packaged with a `catch_all` flow. Stealth CatchAlls are designed to handle scenarios in which the user says something the bot is not expecting or the bot encounters an error.
109
-
110
- Error handling is one of the most important parts of building great bots. We recommend that bot designers and developers spend sufficient time building the CatchAll states.
111
-
112
- See the Catch All (#catchalls) section for more information on how Stealth handles `catch_all` flows.
113
-
114
- ## fails_to
115
-
116
- The `fails_to` option allows you to specify a state that a user should be redirected to in case of an error. The `CatchAllsController` will still be responsible for determining how to handle the error, but by specifying a `fails_to` state here, the `CatchAllsController` is able to redirect accordingly.
117
-
118
- A freshly generated bot will contain sample `CatchAll` code for redirecting a user to a `fails_to` state.
119
-
120
- The `fails_to` option takes a state name (string or symbol) or a session key. See [Redis Backed Sessions](#sessions.redis_backed_sessions) (or in the FlowMap example above) for more info about session keys. By specifying a session key, you can fail to a completely different flow from the one where the error occurred.
121
-
122
- ## redirects_to
123
-
124
- The `redirects_to` option allows you specify a state that a user should be redirected to. This is useful if you have deprecated a state where existing users may still have open sessions pointing to the state. When a user returns to your bot, they will be redirected to the flow and state specified by this option.
125
-
126
- Like `fails_to` above, the `redirects_to` option takes a state name (string or symbol) or a session key. See [Redis Backed Sessions](#sessions.redis_backed_sessions) (or in the FlowMap example above) for more info about session keys. By specifying a session key, you can fail to a completely different flow from the one where the error occurred.
127
-
128
- ## Say, Ask, Get
129
-
130
- Stealth recommends you use the `say`, `ask`, and `get` prefix for your flow state names. It's not required, but it is a convention we have found helpful to keep state names under control. It also helps other developers on your team follow along more easily.
131
-
132
- ### SAY
133
-
134
- *SAY* Stealth actions are for _saying_ something to the user.
135
-
136
- For example:
137
-
138
- ```ruby
139
- def say_hello
140
- send_replies
141
- end
142
- ```
143
-
144
- ### ASK
145
-
146
- *ASK* Stealth actions are for _asking_ something from the user.
147
-
148
- For example:
149
-
150
- ```ruby
151
- def ask_weather
152
- send_replies
153
- update_session_to state: 'get_weather_reponse'
154
- end
155
- ```
156
-
157
- ### GET
158
-
159
- *GET* Stealth actions are for _getting_ and parsing a response from the user.
160
-
161
- For example:
162
-
163
- ```ruby
164
- def get_weather_reponse
165
- if current_message.message == 'Sunny'
166
- step_to state: "say_wear_sunglasses"
167
- elsif current_message.message == 'Raining'
168
- step_to state: "say_dont_forget_umbrella"
169
- end
170
- end
171
- ```
data/docs/04-sessions.md DELETED
@@ -1,29 +0,0 @@
1
- ---
2
- title: Sessions
3
- ---
4
-
5
- A user of your bot can be in any single flow and state at any given moment. They can never be in more than one flow or state. For this reason, Stealth sessions are modeled using [finite state machines](https://en.m.wikipedia.org/wiki/Finite-state_machine).
6
-
7
- ## Finite State Machines
8
-
9
- Technically, each flow is its own state machine with its own states. Stealth, however, does not restrict the movement between states as rigidly. So while we find the state machine model helpful to learn sessions, don't spend too much time on Wikipedia!
10
-
11
- ## Redis Backed Sessions
12
-
13
- User sessions are stored in Redis. Each session is a lightweight key-value pair. The key is the user's ID from the service -- so for Facebook it may be a long integer value: `100023838288224423`. The value is the flow and state for the user separated by a "stabby" operator (`->`).
14
-
15
- So if for example a user with ID `100023838288224423` is currently at the `hello` flow and `ask_name` state, the value for the key would be: `hello->ask_name`.
16
-
17
- You likely won't be interacting with sessions directly since Stealth manages it automatically for you. We just present it here for clarity into how sessions work.
18
-
19
- ## Session Expiration
20
-
21
- By default, Stealth will not expire your user sessions. If you want your sessions to expire, you can set the `session_ttl` option:
22
-
23
- ```ruby
24
- Stealth.config.session_ttl = 2_592_000 # seconds (30 * 24 * 60 * 60)
25
- ```
26
-
27
- The above configuration setting will result in stale keys expiring in 30 days. Sessions that have been accessed reset the TTL (time to live). If you set a value of zero (the default), session expiration will be disabled.
28
-
29
- If a user returns to your bot after their session has expired, they will start again in the `Hello` flow or whatever you have defined to be your first flow.