Skip to content

googleDialogflowCxFlow

Flows represents the conversation flows when you build your chatbot agent.

To get more information about Flow, see:

Example Usage - Dialogflowcx Flow Full

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleDialogflowCxAgentAgent =
  new google.dialogflowCxAgent.DialogflowCxAgent(this, "agent", {
    avatar_uri:
      "https://cloud.google.com/_static/images/cloud/icons/favicons/onecloud/super_cloud.png",
    default_language_code: "en",
    description: "Example description.",
    display_name: "dialogflowcx-agent",
    enable_spell_correction: true,
    enable_stackdriver_logging: true,
    location: "global",
    speech_to_text_settings: [
      {
        enable_speech_adaptation: true,
      },
    ],
    supported_language_codes: ["fr", "de", "es"],
    time_zone: "America/New_York",
  });
new google.dialogflowCxFlow.DialogflowCxFlow(this, "basic_flow", {
  description: "Test Flow",
  display_name: "MyFlow",
  event_handlers: [
    {
      event: "custom-event",
      trigger_fulfillment: [
        {
          messages: [
            {
              text: [
                {
                  text: ["I didn't get that. Can you say it again?"],
                },
              ],
            },
          ],
          return_partial_responses: false,
        },
      ],
    },
    {
      event: "sys.no-match-default",
      trigger_fulfillment: [
        {
          messages: [
            {
              text: [
                {
                  text: ["Sorry, could you say that again?"],
                },
              ],
            },
          ],
          return_partial_responses: false,
        },
      ],
    },
    {
      event: "sys.no-input-default",
      trigger_fulfillment: [
        {
          messages: [
            {
              text: [
                {
                  text: ["One more time?"],
                },
              ],
            },
          ],
          return_partial_responses: false,
        },
      ],
    },
  ],
  nlu_settings: [
    {
      classification_threshold: 0.3,
      model_type: "MODEL_TYPE_STANDARD",
    },
  ],
  parent: googleDialogflowCxAgentAgent.id,
});

Argument Reference

The following arguments are supported:

  • displayName - (Required) The human-readable name of the flow.

  • description - (Optional) The description of the flow. The maximum length is 500 characters. If exceeded, the request is rejected.

  • transitionRoutes - (Optional) A flow's transition routes serve two purposes: They are responsible for matching the user's first utterances in the flow. They are inherited by every page's [transition routes][Page.transition_routes] and can support use cases such as the user saying "help" or "can I talk to a human?", which can be handled in a common way regardless of the current page. Transition routes defined in the page have higher priority than those defined in the flow. TransitionRoutes are evalauted in the following order: TransitionRoutes with intent specified. TransitionRoutes with only condition specified. TransitionRoutes with intent specified are inherited by pages in the flow. Structure is documented below.

  • eventHandlers - (Optional) A flow's event handlers serve two purposes: They are responsible for handling events (e.g. no match, webhook errors) in the flow. They are inherited by every page's [event handlers][Page.event_handlers], which can be used to handle common events regardless of the current page. Event handlers defined in the page have higher priority than those defined in the flow. Unlike transitionRoutes, these handlers are evaluated on a first-match basis. The first one that matches the event get executed, with the rest being ignored. Structure is documented below.

  • transitionRouteGroups - (Optional) A flow's transition route group serve two purposes: They are responsible for matching the user's first utterances in the flow. They are inherited by every page's [transition route groups][Page.transition_route_groups]. Transition route groups defined in the page have higher priority than those defined in the flow. Format:projects//locations//agents//flows//transitionRouteGroups/.

  • nluSettings - (Optional) NLU related settings of the flow. Structure is documented below.

  • parent - (Optional) The agent to create a flow for. Format: projects//locations//agents/.

  • languageCode - (Optional) The language of the following fields in flow: Flow.event_handlers.trigger_fulfillment.messages Flow.event_handlers.trigger_fulfillment.conditional_cases Flow.transition_routes.trigger_fulfillment.messages Flow.transition_routes.trigger_fulfillment.conditional_cases If not specified, the agent's default language is used. Many languages are supported. Note: languages must be enabled in the agent before they can be used.

The transitionRoutes block supports:

  • name - (Output) The unique identifier of this transition route.

  • intent - (Optional) The unique identifier of an Intent. Format: projects//locations//agents//intents/. Indicates that the transition can only happen when the given intent is matched. At least one of intent or condition must be specified. When both intent and condition are specified, the transition can only happen when both are fulfilled.

  • condition - (Optional) The condition to evaluate against form parameters or session parameters. At least one of intent or condition must be specified. When both intent and condition are specified, the transition can only happen when both are fulfilled.

  • triggerFulfillment - (Optional) The fulfillment to call when the condition is satisfied. At least one of triggerFulfillment and target must be specified. When both are defined, triggerFulfillment is executed first. Structure is documented below.

  • targetPage - (Optional) The target page to transition to. Format: projects//locations//agents//flows//pages/.

  • targetFlow - (Optional) The target flow to transition to. Format: projects//locations//agents//flows/.

The triggerFulfillment block supports:

  • messages - (Optional) The list of rich message responses to present to the user. Structure is documented below.

  • webhook - (Optional) The webhook to call. Format: projects//locations//agents//webhooks/.

  • returnPartialResponses - (Optional) Whether Dialogflow should return currently queued fulfillment response messages in streaming APIs. If a webhook is specified, it happens before Dialogflow invokes webhook. Warning: 1) This flag only affects streaming API. Responses are still queued and returned once in non-streaming API. 2) The flag can be enabled in any fulfillment but only the first 3 partial responses will be returned. You may only want to apply it to fulfillments that have slow webhooks.

  • tag - (Optional) The tag used by the webhook to identify which fulfillment is being called. This field is required if webhook is specified.

The messages block supports:

The text block supports:

  • text - (Optional) A collection of text responses.

  • allowPlaybackInterruption - (Output) Whether the playback of this message can be interrupted by the end user's speech and the client can then starts the next Dialogflow request.

The eventHandlers block supports:

  • name - (Output) The unique identifier of this event handler.

  • event - (Optional) The name of the event to handle.

  • triggerFulfillment - (Optional) The fulfillment to call when the event occurs. Handling webhook errors with a fulfillment enabled with webhook could cause infinite loop. It is invalid to specify such fulfillment for a handler handling webhooks. Structure is documented below.

  • targetPage - (Optional) The target page to transition to. Format: projects//locations//agents//flows//pages/.

  • targetFlow - (Optional) The target flow to transition to. Format: projects//locations//agents//flows/.

The triggerFulfillment block supports:

  • messages - (Optional) The list of rich message responses to present to the user. Structure is documented below.

  • webhook - (Optional) The webhook to call. Format: projects//locations//agents//webhooks/.

  • returnPartialResponses - (Optional) Whether Dialogflow should return currently queued fulfillment response messages in streaming APIs. If a webhook is specified, it happens before Dialogflow invokes webhook. Warning: 1) This flag only affects streaming API. Responses are still queued and returned once in non-streaming API. 2) The flag can be enabled in any fulfillment but only the first 3 partial responses will be returned. You may only want to apply it to fulfillments that have slow webhooks.

  • tag - (Optional) The tag used by the webhook to identify which fulfillment is being called. This field is required if webhook is specified.

The messages block supports:

The text block supports:

  • text - (Optional) A collection of text responses.

  • allowPlaybackInterruption - (Output) Whether the playback of this message can be interrupted by the end user's speech and the client can then starts the next Dialogflow request.

The nluSettings block supports:

  • modelType - (Optional) Indicates the type of NLU model.

    • MODEL_TYPE_STANDARD: Use standard NLU model.
    • MODEL_TYPE_ADVANCED: Use advanced NLU model. Possible values are modelTypeStandard and modelTypeAdvanced.
  • classificationThreshold - (Optional) To filter out false positive results and still get variety in matched natural language inputs for your agent, you can tune the machine learning classification threshold. If the returned score value is less than the threshold value, then a no-match event will be triggered. The score values range from 0.0 (completely uncertain) to 1.0 (completely certain). If set to 0.0, the default of 0.3 is used.

  • modelTrainingMode - (Optional) Indicates NLU model training mode.

    • MODEL_TRAINING_MODE_AUTOMATIC: NLU model training is automatically triggered when a flow gets modified. User can also manually trigger model training in this mode.
    • MODEL_TRAINING_MODE_MANUAL: User needs to manually trigger NLU model training. Best for large flows whose models take long time to train. Possible values are modelTrainingModeAutomatic and modelTrainingModeManual.

Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

  • id - an identifier for the resource with format {{parent}}/flows/{{name}}

  • name - The unique identifier of the flow. Format: projects//locations//agents//flows/.

Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 40 minutes.
  • update - Default is 40 minutes.
  • delete - Default is 20 minutes.

Import

Flow can be imported using any of these accepted formats:

$ terraform import google_dialogflow_cx_flow.default {{parent}}/flows/{{name}}
$ terraform import google_dialogflow_cx_flow.default {{parent}}/{{name}}