Skip to content

Commit 9980e82

Browse files
Add `Flow > eventHandlers > triggerFulfillment > enableGenerativeFall… (#13897) (#22671)
[upstream:44d76e995ff42eef2679a4324a06febf6cae215a] Signed-off-by: Modular Magician <[email protected]>
1 parent a834a54 commit 9980e82

File tree

6 files changed

+40
-0
lines changed

6 files changed

+40
-0
lines changed

.changelog/13897.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
dialogflowcx: added `eventHandlers > triggerFulfillment > enableGenerativeFallback` field to `google_dialogflow_cx_flow` resource
3+
```

google/services/dialogflowcx/resource_dialogflow_cx_flow.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,13 @@ See [Case](https://cloud.google.com/dialogflow/cx/docs/reference/rest/v3/Fulfill
239239
},
240240
},
241241
},
242+
"enable_generative_fallback": {
243+
Type: schema.TypeBool,
244+
Optional: true,
245+
Description: `If the flag is true, the agent will utilize LLM to generate a text response.
246+
If LLM generation fails, the defined responses in the fulfillment will be respected.
247+
This flag is only useful for fulfillments associated with no-match event handlers.`,
248+
},
242249
"messages": {
243250
Type: schema.TypeList,
244251
Optional: true,
@@ -2093,6 +2100,8 @@ func flattenDialogflowCXFlowEventHandlersTriggerFulfillment(v interface{}, d *sc
20932100
flattenDialogflowCXFlowEventHandlersTriggerFulfillmentSetParameterActions(original["setParameterActions"], d, config)
20942101
transformed["conditional_cases"] =
20952102
flattenDialogflowCXFlowEventHandlersTriggerFulfillmentConditionalCases(original["conditionalCases"], d, config)
2103+
transformed["enable_generative_fallback"] =
2104+
flattenDialogflowCXFlowEventHandlersTriggerFulfillmentEnableGenerativeFallback(original["enableGenerativeFallback"], d, config)
20962105
return []interface{}{transformed}
20972106
}
20982107
func flattenDialogflowCXFlowEventHandlersTriggerFulfillmentMessages(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
@@ -2355,6 +2364,10 @@ func flattenDialogflowCXFlowEventHandlersTriggerFulfillmentConditionalCasesCases
23552364
return string(b)
23562365
}
23572366

2367+
func flattenDialogflowCXFlowEventHandlersTriggerFulfillmentEnableGenerativeFallback(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
2368+
return v
2369+
}
2370+
23582371
func flattenDialogflowCXFlowEventHandlersTargetPage(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
23592372
return v
23602373
}
@@ -3719,6 +3732,13 @@ func expandDialogflowCXFlowEventHandlersTriggerFulfillment(v interface{}, d tpgr
37193732
transformed["conditionalCases"] = transformedConditionalCases
37203733
}
37213734

3735+
transformedEnableGenerativeFallback, err := expandDialogflowCXFlowEventHandlersTriggerFulfillmentEnableGenerativeFallback(original["enable_generative_fallback"], d, config)
3736+
if err != nil {
3737+
return nil, err
3738+
} else if val := reflect.ValueOf(transformedEnableGenerativeFallback); val.IsValid() && !tpgresource.IsEmptyValue(val) {
3739+
transformed["enableGenerativeFallback"] = transformedEnableGenerativeFallback
3740+
}
3741+
37223742
return transformed, nil
37233743
}
37243744

@@ -4098,6 +4118,10 @@ func expandDialogflowCXFlowEventHandlersTriggerFulfillmentConditionalCasesCases(
40984118
return j, nil
40994119
}
41004120

4121+
func expandDialogflowCXFlowEventHandlersTriggerFulfillmentEnableGenerativeFallback(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
4122+
return v, nil
4123+
}
4124+
41014125
func expandDialogflowCXFlowEventHandlersTargetPage(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
41024126
return v, nil
41034127
}

google/services/dialogflowcx/resource_dialogflow_cx_flow_generated_meta.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ fields:
2323
- field: 'event_handlers.target_flow'
2424
- field: 'event_handlers.target_page'
2525
- field: 'event_handlers.trigger_fulfillment.conditional_cases.cases'
26+
- field: 'event_handlers.trigger_fulfillment.enable_generative_fallback'
2627
- field: 'event_handlers.trigger_fulfillment.messages.channel'
2728
- field: 'event_handlers.trigger_fulfillment.messages.conversation_success.metadata'
2829
- field: 'event_handlers.trigger_fulfillment.messages.live_agent_handoff.metadata'

google/services/dialogflowcx/resource_dialogflow_cx_flow_generated_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ resource "google_dialogflow_cx_flow" "basic_flow" {
315315
},
316316
])
317317
}
318+
319+
enable_generative_fallback = true
318320
}
319321
}
320322

google/services/dialogflowcx/resource_dialogflowcx_flow_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ func testAccDialogflowCXFlow_full(context map[string]interface{}) string {
236236
},
237237
])
238238
}
239+
240+
enable_generative_fallback = true
239241
}
240242
}
241243

website/docs/r/dialogflow_cx_flow.html.markdown

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ resource "google_dialogflow_cx_flow" "basic_flow" {
277277
},
278278
])
279279
}
280+
281+
enable_generative_fallback = true
280282
}
281283
}
282284
@@ -854,6 +856,12 @@ The Default Start Flow cannot be deleted; deleting the `google_dialogflow_cx_flo
854856
Conditional cases for this fulfillment.
855857
Structure is [documented below](#nested_event_handlers_event_handlers_trigger_fulfillment_conditional_cases).
856858

859+
* `enable_generative_fallback` -
860+
(Optional)
861+
If the flag is true, the agent will utilize LLM to generate a text response.
862+
If LLM generation fails, the defined responses in the fulfillment will be respected.
863+
This flag is only useful for fulfillments associated with no-match event handlers.
864+
857865

858866
<a name="nested_event_handlers_event_handlers_trigger_fulfillment_messages"></a>The `messages` block supports:
859867

0 commit comments

Comments
 (0)