aws-lex-conversation 4.1.0 → 5.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 128c0cd7f79f2ba2f9fa8c8a148a06100cd9b4d26f9569cd97f53fee5d33b16e
|
4
|
+
data.tar.gz: 3e715ccfbec559fabc2503c49d00fac234df8668edeab39f2c561ad379909da5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 176b75d71df52db5799a95380d6820665511e2e3459e5cdf0d8e30ae4ca0f090086c0bb6609c6124b629fc1ab04d0e3ee1e63fd35da0463186cb7479f165c4e2
|
7
|
+
data.tar.gz: 315f366c43a00923b50828360ff00d32fa8f566d2cc2c990670557de2b87d4259f0960d8abddf0baed3a039a7667ec3aa7982e82edf97db5c20443beb9611a2c
|
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,38 +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: content_type,
|
33
|
-
content: elicitation_content
|
34
|
-
}
|
35
|
-
]
|
27
|
+
messages: elicitation_messages
|
36
28
|
)
|
37
29
|
end
|
38
30
|
|
39
31
|
def elicit?
|
32
|
+
return false if maximum_elicitations? && fallback.nil?
|
33
|
+
|
40
34
|
elicit.call(conversation) && !slot.filled?
|
41
35
|
end
|
42
36
|
|
@@ -46,11 +40,11 @@ module Aws
|
|
46
40
|
conversation.slots[name.to_sym]
|
47
41
|
end
|
48
42
|
|
49
|
-
def
|
50
|
-
first_elicitation? ?
|
43
|
+
def elicitation_messages
|
44
|
+
first_elicitation? ? compose_messages(messages) : compose_messages(follow_up_messages)
|
51
45
|
end
|
52
46
|
|
53
|
-
def
|
47
|
+
def compose_messages(msg)
|
54
48
|
msg.is_a?(Proc) ? msg.call(conversation) : msg
|
55
49
|
end
|
56
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.0
|
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-02 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: shrink_wrap
|