Skip to content

Commit 665e344

Browse files
Fully supporting Dialogflow CX Page and Flow objects (#8757) (#15668)
* Fully supporting Dialogflow CX Page and Flow objects This fills out a bunch of stuff that was missing including: - repromptEventHandlers (#14573) - setParameterActions (#14572) - payload, and other fulfillment messages (#12946) * Allowing JSON values to actually be values (instead of just objects) * Adding "basic" Flow creation, filling out "full" Flow creation with (I hope) all params * Oops, missed Flow messages.response_type example * Adding "basic" Page creation, filling out "full" Page creation with (I hope) all params * Oops, missed response_type and had an extra level of nested messages{} somehow * Adding return_partial_response + webhook (?!) * Fixing conditionalCases: it's now a JSON encoded list, instead of a list of JSON encoded objects * Normalizing whitespace in examples + tests; it's now all spaces (I hope) * Fixing examples / tests * Normalizing whitespace in basic examples * Fixing examples: empty conditions are supposed to be null / missing * Fixing examples: tag should only be set when webhook is set (we'll see if I need to set webhook everywhere) * Fixing code: responseType is ignored when creating/updating resources Signed-off-by: Modular Magician <[email protected]>
1 parent 2ba9f70 commit 665e344

9 files changed

+9018
-856
lines changed

.changelog/8757.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
```release-note:enhancement
2+
dialogflowcx: added `response_type`, `channel`, `payload`, `conversation_success`, `output_audio_text`, `live_agent_handoff`, `play_audo`, `telephony_transfer_call`, `set_parameter_actions`, and `conditional_cases` fields to `google_dialogflow_cx_flow` resource
3+
```
4+
```release-note:enhancement
5+
dialogflowcx: added `response_type`, `channel`, `payload`, `conversation_success`, `output_audio_text`, `live_agent_handoff`, `play_audo`, `telephony_transfer_call`, `reprompt_event_handlers`, `set_parameter_actions`, and `conditional_cases` fields to `google_dialogflow_cx_page` resource
6+
```

google/services/dialogflowcx/resource_dialogflow_cx_flow.go

+1,483-111
Large diffs are not rendered by default.

google/services/dialogflowcx/resource_dialogflow_cx_flow_generated_test.go

+249-46
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,18 @@ func TestAccDialogflowCXFlow_dialogflowcxFlowFullExample(t *testing.T) {
5858
func testAccDialogflowCXFlow_dialogflowcxFlowFullExample(context map[string]interface{}) string {
5959
return acctest.Nprintf(`
6060
resource "google_dialogflow_cx_agent" "agent" {
61-
display_name = "tf-test-dialogflowcx-agent%{random_suffix}"
62-
location = "global"
63-
default_language_code = "en"
64-
supported_language_codes = ["fr","de","es"]
65-
time_zone = "America/New_York"
66-
description = "Example description."
67-
avatar_uri = "https://cloud.google.com/_static/images/cloud/icons/favicons/onecloud/super_cloud.png"
61+
display_name = "tf-test-dialogflowcx-agent%{random_suffix}"
62+
location = "global"
63+
default_language_code = "en"
64+
supported_language_codes = ["fr", "de", "es"]
65+
time_zone = "America/New_York"
66+
description = "Example description."
67+
avatar_uri = "https://cloud.google.com/_static/images/cloud/icons/favicons/onecloud/super_cloud.png"
6868
enable_stackdriver_logging = true
6969
enable_spell_correction = true
70-
speech_to_text_settings {
71-
enable_speech_adaptation = true
72-
}
70+
speech_to_text_settings {
71+
enable_speech_adaptation = true
72+
}
7373
}
7474
7575
@@ -79,45 +79,248 @@ resource "google_dialogflow_cx_flow" "basic_flow" {
7979
description = "Test Flow"
8080
8181
nlu_settings {
82-
classification_threshold = 0.3
83-
model_type = "MODEL_TYPE_STANDARD"
84-
}
82+
classification_threshold = 0.3
83+
model_type = "MODEL_TYPE_STANDARD"
84+
}
8585
8686
event_handlers {
87-
event = "custom-event"
88-
trigger_fulfillment {
89-
return_partial_responses = false
90-
messages {
91-
text {
92-
text = ["I didn't get that. Can you say it again?"]
93-
}
94-
}
95-
}
96-
}
87+
event = "custom-event"
88+
trigger_fulfillment {
89+
return_partial_responses = false
90+
messages {
91+
text {
92+
text = ["I didn't get that. Can you say it again?"]
93+
}
94+
}
95+
}
96+
}
97+
98+
event_handlers {
99+
event = "sys.no-match-default"
100+
trigger_fulfillment {
101+
return_partial_responses = false
102+
messages {
103+
text {
104+
text = ["Sorry, could you say that again?"]
105+
}
106+
}
107+
}
108+
}
109+
110+
event_handlers {
111+
event = "sys.no-input-default"
112+
trigger_fulfillment {
113+
return_partial_responses = false
114+
messages {
115+
text {
116+
text = ["One more time?"]
117+
}
118+
}
119+
}
120+
}
121+
122+
event_handlers {
123+
event = "another-event"
124+
trigger_fulfillment {
125+
return_partial_responses = true
126+
messages {
127+
channel = "some-channel"
128+
text {
129+
text = ["Some text"]
130+
}
131+
}
132+
messages {
133+
payload = <<EOF
134+
{"some-key": "some-value", "other-key": ["other-value"]}
135+
EOF
136+
}
137+
messages {
138+
conversation_success {
139+
metadata = <<EOF
140+
{"some-metadata-key": "some-value", "other-metadata-key": 1234}
141+
EOF
142+
}
143+
}
144+
messages {
145+
output_audio_text {
146+
text = "some output text"
147+
}
148+
}
149+
messages {
150+
output_audio_text {
151+
ssml = <<EOF
152+
<speak>Some example <say-as interpret-as="characters">SSML XML</say-as></speak>
153+
EOF
154+
}
155+
}
156+
messages {
157+
live_agent_handoff {
158+
metadata = <<EOF
159+
{"some-metadata-key": "some-value", "other-metadata-key": 1234}
160+
EOF
161+
}
162+
}
163+
messages {
164+
play_audio {
165+
audio_uri = "http://example.com/some-audio-file.mp3"
166+
}
167+
}
168+
messages {
169+
telephony_transfer_call {
170+
phone_number = "1-234-567-8901"
171+
}
172+
}
173+
174+
set_parameter_actions {
175+
parameter = "some-param"
176+
value = "123.45"
177+
}
178+
set_parameter_actions {
179+
parameter = "another-param"
180+
value = jsonencode("abc")
181+
}
182+
set_parameter_actions {
183+
parameter = "other-param"
184+
value = jsonencode(["foo"])
185+
}
186+
187+
conditional_cases {
188+
cases = jsonencode([
189+
{
190+
condition = "$sys.func.RAND() < 0.5",
191+
caseContent = [
192+
{
193+
message = { text = { text = ["First case"] } }
194+
},
195+
{
196+
additionalCases = {
197+
cases = [
198+
{
199+
condition = "$sys.func.RAND() < 0.2"
200+
caseContent = [
201+
{
202+
message = { text = { text = ["Nested case"] } }
203+
}
204+
]
205+
}
206+
]
207+
}
208+
}
209+
]
210+
},
211+
{
212+
caseContent = [
213+
{
214+
message = { text = { text = ["Final case"] } }
215+
}
216+
]
217+
},
218+
])
219+
}
220+
}
221+
}
222+
223+
transition_routes {
224+
condition = "true"
225+
trigger_fulfillment {
226+
return_partial_responses = true
227+
messages {
228+
channel = "some-channel"
229+
text {
230+
text = ["Some text"]
231+
}
232+
}
233+
messages {
234+
payload = <<EOF
235+
{"some-key": "some-value", "other-key": ["other-value"]}
236+
EOF
237+
}
238+
messages {
239+
conversation_success {
240+
metadata = <<EOF
241+
{"some-metadata-key": "some-value", "other-metadata-key": 1234}
242+
EOF
243+
}
244+
}
245+
messages {
246+
output_audio_text {
247+
text = "some output text"
248+
}
249+
}
250+
messages {
251+
output_audio_text {
252+
ssml = <<EOF
253+
<speak>Some example <say-as interpret-as="characters">SSML XML</say-as></speak>
254+
EOF
255+
}
256+
}
257+
messages {
258+
live_agent_handoff {
259+
metadata = <<EOF
260+
{"some-metadata-key": "some-value", "other-metadata-key": 1234}
261+
EOF
262+
}
263+
}
264+
messages {
265+
play_audio {
266+
audio_uri = "http://example.com/some-audio-file.mp3"
267+
}
268+
}
269+
messages {
270+
telephony_transfer_call {
271+
phone_number = "1-234-567-8901"
272+
}
273+
}
274+
275+
set_parameter_actions {
276+
parameter = "some-param"
277+
value = "123.45"
278+
}
279+
set_parameter_actions {
280+
parameter = "another-param"
281+
value = jsonencode("abc")
282+
}
283+
set_parameter_actions {
284+
parameter = "other-param"
285+
value = jsonencode(["foo"])
286+
}
97287
98-
event_handlers {
99-
event = "sys.no-match-default"
100-
trigger_fulfillment {
101-
return_partial_responses = false
102-
messages {
103-
text {
104-
text = ["Sorry, could you say that again?"]
105-
}
106-
}
107-
}
108-
}
109-
110-
event_handlers {
111-
event = "sys.no-input-default"
112-
trigger_fulfillment {
113-
return_partial_responses = false
114-
messages {
115-
text {
116-
text = ["One more time?"]
117-
}
118-
}
119-
}
120-
}
288+
conditional_cases {
289+
cases = jsonencode([
290+
{
291+
condition = "$sys.func.RAND() < 0.5",
292+
caseContent = [
293+
{
294+
message = { text = { text = ["First case"] } }
295+
},
296+
{
297+
additionalCases = {
298+
cases = [
299+
{
300+
condition = "$sys.func.RAND() < 0.2"
301+
caseContent = [
302+
{
303+
message = { text = { text = ["Nested case"] } }
304+
}
305+
]
306+
}
307+
]
308+
}
309+
}
310+
]
311+
},
312+
{
313+
caseContent = [
314+
{
315+
message = { text = { text = ["Final case"] } }
316+
}
317+
]
318+
},
319+
])
320+
}
321+
}
322+
target_flow = google_dialogflow_cx_agent.agent.start_flow
323+
}
121324
}
122325
`, context)
123326
}

0 commit comments

Comments
 (0)