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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/aws/lex/conversation/slot/elicitation.rb +12 -22
- data/lib/aws/lex/conversation/support/mixins/responses.rb +9 -3
- data/lib/aws/lex/conversation/type/checkpoint.rb +7 -3
- data/lib/aws/lex/conversation/type/session_attributes.rb +1 -1
- data/lib/aws/lex/conversation/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46556f575fd08ac0ded8d8fc50692be70388fbf1e3d96ff8d236c82a5e8eb860
|
4
|
+
data.tar.gz: c5456ec5961936b210d80491bb9edaebf503c71daba5acf755257b36ae211875
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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, :
|
9
|
-
:
|
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.
|
16
|
-
self.
|
17
|
-
self.
|
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
|
54
|
-
first_elicitation? ?
|
43
|
+
def elicitation_messages
|
44
|
+
first_elicitation? ? compose_messages(messages) : compose_messages(follow_up_messages)
|
55
45
|
end
|
56
46
|
|
57
|
-
def
|
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
|
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
|
+
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-
|
15
|
+
date: 2021-09-03 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: shrink_wrap
|