@@ -58,18 +58,18 @@ func TestAccDialogflowCXFlow_dialogflowcxFlowFullExample(t *testing.T) {
58
58
func testAccDialogflowCXFlow_dialogflowcxFlowFullExample (context map [string ]interface {}) string {
59
59
return acctest .Nprintf (`
60
60
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"
68
68
enable_stackdriver_logging = true
69
69
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
+ }
73
73
}
74
74
75
75
@@ -79,45 +79,248 @@ resource "google_dialogflow_cx_flow" "basic_flow" {
79
79
description = "Test Flow"
80
80
81
81
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
+ }
85
85
86
86
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
+ }
97
287
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
+ }
121
324
}
122
325
` , context )
123
326
}
0 commit comments