aws-lex-conversation 4.2.0 → 5.1.1

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
  SHA256:
3
- metadata.gz: 10b9a6aa5e59e3f2c016255c6fbd46f30631ece6c981fa81d45c2b300f676041
4
- data.tar.gz: a49c289a1c5cf5189f3f87e971a32947dc5ab2a6380189b39c8544c1d5792c20
3
+ metadata.gz: 46556f575fd08ac0ded8d8fc50692be70388fbf1e3d96ff8d236c82a5e8eb860
4
+ data.tar.gz: c5456ec5961936b210d80491bb9edaebf503c71daba5acf755257b36ae211875
5
5
  SHA512:
6
- metadata.gz: c94e997fba06c3658c53d0a51dd4b67a0c3f75118fddd7ba0430ecba2e8433d4e601ba9da5e14d7307d200c97bdda47f74e35809b0e4ae95883c6572365e311e
7
- data.tar.gz: 8734811c21883cc5ba09a234bbd04a1cd6fcf5b98f189406da843c30ea631c19fc0e32ae2a95a7bfdda6985f849ba4e2804f3e3897a3a46eebc9b2de6eb2396d
6
+ metadata.gz: dfcf7591d2c9667d17f3863dde180724c4dc5ec5b2f623173be6c11b6cbf9548d99b39ae1ad809e25adb6069fea9239dc58c3a8776bc85340ec07c9752a3c976
7
+ data.tar.gz: 6cd97d779b1e482c19300db5cb63e9d36f01278be04c896dc603138b0a293d0baf8fa8cfadfd95d27896b4a467d81211607bb0cb551e960f72d3efd740a5a9cf
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 4.3.0 - August 25, 2021
2
+
3
+ * Slot elicitor can now be passed an Aws::Lex::Conversation::Type::Message as part of the DSL/callback and properly formats the response as such
4
+
1
5
  # 4.1.0 - July 21, 2021
2
6
 
3
7
  * Don't set the `intent` property in the response for `ElicitIntent`
@@ -5,42 +5,32 @@ module Aws
5
5
  class Conversation
6
6
  module Slot
7
7
  class Elicitation
8
- attr_accessor :name, :elicit, :message, :follow_up_message,
9
- :content_type, :fallback, :maximum_elicitations,
10
- :conversation
8
+ attr_accessor :name, :elicit, :messages, :follow_up_messages,
9
+ :fallback, :maximum_elicitations, :conversation
11
10
 
12
11
  def initialize(opts = {})
13
12
  self.name = opts.fetch(:name)
14
13
  self.elicit = opts.fetch(:elicit) { ->(_c) { true } }
15
- self.message = opts.fetch(:message)
16
- self.follow_up_message = opts.fetch(:follow_up_message) { opts.fetch(:message) }
17
- self.content_type = opts.fetch(:content_type) do
18
- Aws::Lex::Conversation::Type::Message::ContentType.new('PlainText')
19
- end
20
- self.fallback = opts.fetch(:fallback) { ->(_c) {} }
14
+ self.messages = opts.fetch(:messages)
15
+ self.follow_up_messages = opts.fetch(:follow_up_messages) { opts.fetch(:messages) }
16
+ self.fallback = opts[:fallback]
21
17
  self.maximum_elicitations = opts.fetch(:maximum_elicitations) { 0 }
22
18
  end
23
19
 
24
20
  def elicit!
21
+ return false unless elicit?
25
22
  return fallback.call(conversation) if maximum_elicitations?
26
23
 
27
24
  increment_slot_elicitations!
28
25
  conversation.elicit_slot(
29
26
  slot_to_elicit: name,
30
- messages: [
31
- {
32
- contentType: message_content_type,
33
- content: elicitation_content
34
- }
35
- ]
27
+ messages: elicitation_messages
36
28
  )
37
29
  end
38
30
 
39
- def message_content_type
40
- content_type.is_a?(Proc) ? content_type.call(conversation) : content_type
41
- end
42
-
43
31
  def elicit?
32
+ return false if maximum_elicitations? && fallback.nil?
33
+
44
34
  elicit.call(conversation) && !slot.filled?
45
35
  end
46
36
 
@@ -50,11 +40,11 @@ module Aws
50
40
  conversation.slots[name.to_sym]
51
41
  end
52
42
 
53
- def elicitation_content
54
- first_elicitation? ? compose_message(message) : compose_message(follow_up_message)
43
+ def elicitation_messages
44
+ first_elicitation? ? compose_messages(messages) : compose_messages(follow_up_messages)
55
45
  end
56
46
 
57
- def compose_message(msg)
47
+ def compose_messages(msg)
58
48
  msg.is_a?(Proc) ? msg.call(conversation) : msg
59
49
  end
60
50
 
@@ -9,8 +9,10 @@ module Aws
9
9
  def close(opts = {})
10
10
  params = {
11
11
  session_state: lex.session_state,
12
- request_attributes: lex.request_attributes
12
+ request_attributes: lex.request_attributes,
13
+ intent: lex.current_intent
13
14
  }.merge(opts)
15
+ lex.session_state.intent = params.fetch(:intent)
14
16
  Response::Close.new(params).to_lex
15
17
  end
16
18
 
@@ -27,16 +29,20 @@ module Aws
27
29
  def delegate(opts = {})
28
30
  params = {
29
31
  session_state: lex.session_state,
30
- request_attributes: lex.request_attributes
32
+ request_attributes: lex.request_attributes,
33
+ intent: lex.current_intent
31
34
  }.merge(opts)
35
+ lex.session_state.intent = params.fetch(:intent)
32
36
  Response::Delegate.new(params).to_lex
33
37
  end
34
38
 
35
39
  def elicit_intent(opts = {})
36
40
  params = {
37
41
  session_state: lex.session_state,
38
- request_attributes: lex.request_attributes
42
+ request_attributes: lex.request_attributes,
43
+ intent: lex.current_intent
39
44
  }.merge(opts)
45
+ lex.session_state.intent = params.fetch(:intent)
40
46
  Response::ElicitIntent.new(params).to_lex
41
47
  end
42
48
 
@@ -20,11 +20,12 @@ module Aws
20
20
  fulfillment_state: FulfillmentState
21
21
  )
22
22
 
23
- # rubocop:disable Metrics/MethodLength
23
+ # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
24
24
  def restore(conversation, opts = {})
25
25
  case dialog_action_type.raw
26
26
  when 'Close'
27
27
  conversation.close(
28
+ intent: intent,
28
29
  fulfillment_state: opts.fetch(:fulfillment_state) { fulfillment_state },
29
30
  messages: opts.fetch(:messages)
30
31
  )
@@ -34,9 +35,12 @@ module Aws
34
35
  messages: opts.fetch(:messages)
35
36
  )
36
37
  when 'Delegate'
37
- conversation.delegate
38
+ conversation.delegate(
39
+ intent: intent
40
+ )
38
41
  when 'ElicitIntent'
39
42
  conversation.elicit_intent(
43
+ intent: intent,
40
44
  messages: opts.fetch(:messages)
41
45
  )
42
46
  when 'ElicitSlot'
@@ -49,7 +53,7 @@ module Aws
49
53
  raise ArgumentError, "invalid DialogActionType: `#{dialog_action_type.raw}`"
50
54
  end
51
55
  end
52
- # rubocop:enable Metrics/MethodLength
56
+ # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
53
57
  end
54
58
  end
55
59
  end
@@ -20,7 +20,7 @@ module Aws
20
20
  def to_lex
21
21
  merge(
22
22
  checkpoints: Base64.urlsafe_encode64(checkpoints.map(&:to_lex).to_json, padding: false)
23
- )
23
+ ).to_h
24
24
  end
25
25
  end
26
26
  end
@@ -3,7 +3,7 @@
3
3
  module Aws
4
4
  module Lex
5
5
  class Conversation
6
- VERSION = '4.2.0'
6
+ VERSION = '5.1.1'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-lex-conversation
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 5.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Doyle
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: exe
14
14
  cert_chain: []
15
- date: 2021-08-23 00:00:00.000000000 Z
15
+ date: 2021-09-03 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: shrink_wrap