# Copyright 2024 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
name: 'Page'
description: |
  A Dialogflow CX conversation (session) can be described and visualized as a state machine. The states of a CX session are represented by pages.
references:
  guides:
    'Official Documentation': 'https://cloud.google.com/dialogflow/cx/docs'
  api: 'https://cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.flows.pages'
docs:
id_format: '{{parent}}/pages/{{name}}'
base_url: '{{parent}}/pages'
update_verb: 'PATCH'
update_mask: true
import_format:
  - '{{parent}}/pages/{{name}}'
timeouts:
  insert_minutes: 40
  update_minutes: 40
  delete_minutes: 20
custom_code:
  pre_create: 'templates/terraform/pre_create/dialogflow_set_location.go.tmpl'
  pre_read: 'templates/terraform/pre_create/dialogflow_set_location.go.tmpl'
  pre_update: 'templates/terraform/pre_create/dialogflow_set_location.go.tmpl'
  pre_delete: 'templates/terraform/pre_create/dialogflow_set_location.go.tmpl'
  custom_import: 'templates/terraform/custom_import/dialogflowcx_page.go.tmpl'
exclude_sweeper: true
examples:
  - name: 'dialogflowcx_page_full'
    primary_resource_id: 'basic_page'
    vars:
      agent_name: 'dialogflowcx-agent'
parameters:
  - name: 'parent'
    type: String
    description: |
      The flow to create a page for.
      Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/flows/<Flow ID>.
    url_param_only: true
    immutable: true
  - name: 'languageCode'
    type: String
    description: |
      The language of the following fields in page:

      Page.entry_fulfillment.messages
      Page.entry_fulfillment.conditional_cases
      Page.event_handlers.trigger_fulfillment.messages
      Page.event_handlers.trigger_fulfillment.conditional_cases
      Page.form.parameters.fill_behavior.initial_prompt_fulfillment.messages
      Page.form.parameters.fill_behavior.initial_prompt_fulfillment.conditional_cases
      Page.form.parameters.fill_behavior.reprompt_event_handlers.messages
      Page.form.parameters.fill_behavior.reprompt_event_handlers.conditional_cases
      Page.transition_routes.trigger_fulfillment.messages
      Page.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.
    immutable: true
properties:
  - name: 'name'
    type: String
    description: |
      The unique identifier of the page.
      Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/flows/<Flow ID>/pages/<Page ID>.
    output: true
    custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.tmpl'
  - name: 'displayName'
    type: String
    description: |
      The human-readable name of the page, unique within the agent.
    required: true
    validation:
      function: 'validation.StringLenBetween(0, 64)'
  - name: 'entryFulfillment'
    type: NestedObject
    description: |
      The fulfillment to call when the session is entering the page.
    properties:
      - name: 'messages'
        type: Array
        description: |
          The list of rich message responses to present to the user.
        item_type:
          type: NestedObject
          properties:
            - name: 'channel'
              type: String
              description: |
                The channel which the response is associated with. Clients can specify the channel via QueryParameters.channel, and only associated channel response will be returned.
            - name: 'text'
              type: NestedObject
              description: |
                The text response message.
              properties:
                - name: 'text'
                  type: Array
                  description: |
                    A collection of text responses.
                  item_type:
                    type: String
                - name: 'allowPlaybackInterruption'
                  type: Boolean
                  description: |
                    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.
                  output: true
            # This can be an arbitrary json blob, so we use a string instead of a NestedObject.
            - name: 'payload'
              type: String
              description: |
                A custom, platform-specific payload.
              state_func: 'func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }'
              custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
              custom_expand: 'templates/terraform/custom_expand/json_schema.tmpl'
              validation:
                function: 'validation.StringIsJSON'
            - name: 'conversationSuccess'
              type: NestedObject
              description: |
                Indicates that the conversation succeeded, i.e., the bot handled the issue that the customer talked to it about.
                Dialogflow only uses this to determine which conversations should be counted as successful and doesn't process the metadata in this message in any way. Note that Dialogflow also considers conversations that get to the conversation end page as successful even if they don't return ConversationSuccess.
                You may set this, for example:
                * In the entryFulfillment of a Page if entering the page indicates that the conversation succeeded.
                * In a webhook response when you determine that you handled the customer issue.
              properties:
                # This can be an arbitrary json blob, so we use a string instead of a NestedObject.
                - name: 'metadata'
                  type: String
                  description: |
                    Custom metadata. Dialogflow doesn't impose any structure on this.
                  state_func: 'func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }'
                  custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
                  custom_expand: 'templates/terraform/custom_expand/json_schema.tmpl'
                  validation:
                    function: 'validation.StringIsJSON'
            - name: 'outputAudioText'
              type: NestedObject
              description: |
                A text or ssml response that is preferentially used for TTS output audio synthesis, as described in the comment on the ResponseMessage message.
              properties:
                - name: 'allowPlaybackInterruption'
                  type: Boolean
                  description: |
                    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.
                  output: true
                - name: 'text'
                  type: String
                  description: |
                    The raw text to be synthesized.
                - name: 'ssml'
                  type: String
                  description: |
                    The SSML text to be synthesized. For more information, see SSML.
            - name: 'liveAgentHandoff'
              type: NestedObject
              description: |
                Indicates that the conversation should be handed off to a live agent.
                Dialogflow only uses this to determine which conversations were handed off to a human agent for measurement purposes. What else to do with this signal is up to you and your handoff procedures.
                You may set this, for example:
                * In the entryFulfillment of a Page if entering the page indicates something went extremely wrong in the conversation.
                * In a webhook response when you determine that the customer issue can only be handled by a human.
              properties:
                # This can be an arbitrary json blob, so we use a string instead of a NestedObject.
                - name: 'metadata'
                  type: String
                  description: |
                    Custom metadata. Dialogflow doesn't impose any structure on this.
                  state_func: 'func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }'
                  custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
                  custom_expand: 'templates/terraform/custom_expand/json_schema.tmpl'
                  validation:
                    function: 'validation.StringIsJSON'
            - name: 'playAudio'
              type: NestedObject
              description: |
                Specifies an audio clip to be played by the client as part of the response.
              properties:
                - name: 'audioUri'
                  type: String
                  description: |
                    URI of the audio clip. Dialogflow does not impose any validation on this value. It is specific to the client that reads it.
                  required: true
                - name: 'allowPlaybackInterruption'
                  type: Boolean
                  description: |
                    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.
                  output: true
            - name: 'telephonyTransferCall'
              type: NestedObject
              description: |
                Represents the signal that telles the client to transfer the phone call connected to the agent to a third-party endpoint.
              properties:
                - name: 'phoneNumber'
                  type: String
                  description: |
                    Transfer the call to a phone number in E.164 format.
                  required: true
      - name: 'webhook'
        type: String
        description: |
          The webhook to call. Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/webhooks/<Webhook ID>.
      - name: 'returnPartialResponses'
        type: Boolean
        description: |
          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.
      - name: 'tag'
        type: String
        description: |
          The tag used by the webhook to identify which fulfillment is being called. This field is required if webhook is specified.
      - name: 'setParameterActions'
        type: Array
        description: |
          Set parameter values before executing the webhook.
        item_type:
          type: NestedObject
          properties:
            - name: 'parameter'
              type: String
              description: |
                Display name of the parameter.
            - name: 'value'
              type: String
              description: |
                The new JSON-encoded value of the parameter. A null value clears the parameter.
              state_func: 'func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }'
              custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
              custom_expand: 'templates/terraform/custom_expand/json_value.tmpl'
              validation:
                function: 'validation.StringIsJSON'
      - name: 'conditionalCases'
        type: Array
        description: |
          Conditional cases for this fulfillment.
        item_type:
          type: NestedObject
          properties:
            # This object has a recursive schema so we use a string instead of a NestedObject
            - name: 'cases'
              type: String
              description: |
                A JSON encoded list of cascading if-else conditions. Cases are mutually exclusive. The first one with a matching condition is selected, all the rest ignored.
                See [Case](https://cloud.google.com/dialogflow/cx/docs/reference/rest/v3/Fulfillment#case) for the schema.
              state_func: 'func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }'
              custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
              custom_expand: 'templates/terraform/custom_expand/json_value.tmpl'
              validation:
                function: 'validation.StringIsJSON'
  - name: 'form'
    type: NestedObject
    description: |
      The form associated with the page, used for collecting parameters relevant to the page.
    properties:
      - name: 'parameters'
        type: Array
        description: |
          Parameters to collect from the user.
        item_type:
          type: NestedObject
          properties:
            - name: 'displayName'
              type: String
              description: |
                The human-readable name of the parameter, unique within the form.
            - name: 'required'
              type: Boolean
              description: |
                Indicates whether the parameter is required. Optional parameters will not trigger prompts; however, they are filled if the user specifies them.
                Required parameters must be filled before form filling concludes.
            - name: 'entityType'
              type: String
              description: |
                The entity type of the parameter.
                Format: projects/-/locations/-/agents/-/entityTypes/<System Entity Type ID> for system entity types (for example, projects/-/locations/-/agents/-/entityTypes/sys.date), or projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/entityTypes/<Entity Type ID> for developer entity types.
            - name: 'isList'
              type: Boolean
              description: |
                Indicates whether the parameter represents a list of values.
            - name: 'fillBehavior'
              type: NestedObject
              description: |
                Defines fill behavior for the parameter.
              properties:
                - name: 'initialPromptFulfillment'
                  type: NestedObject
                  description: |
                    The fulfillment to provide the initial prompt that the agent can present to the user in order to fill the parameter.
                  properties:
                    - name: 'messages'
                      type: Array
                      description: |
                        The list of rich message responses to present to the user.
                      item_type:
                        type: NestedObject
                        properties:
                          - name: 'channel'
                            type: String
                            description: |
                              The channel which the response is associated with. Clients can specify the channel via QueryParameters.channel, and only associated channel response will be returned.
                          - name: 'text'
                            type: NestedObject
                            description: |
                              The text response message.
                            properties:
                              - name: 'text'
                                type: Array
                                description: |
                                  A collection of text responses.
                                item_type:
                                  type: String
                              - name: 'allowPlaybackInterruption'
                                type: Boolean
                                description: |
                                  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.
                                output: true
                          # This can be an arbitrary json blob, so we use a string instead of a NestedObject.
                          - name: 'payload'
                            type: String
                            description: |
                              A custom, platform-specific payload.
                            state_func: 'func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }'
                            custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
                            custom_expand: 'templates/terraform/custom_expand/json_schema.tmpl'
                            validation:
                              function: 'validation.StringIsJSON'
                          - name: 'conversationSuccess'
                            type: NestedObject
                            description: |
                              Indicates that the conversation succeeded, i.e., the bot handled the issue that the customer talked to it about.
                              Dialogflow only uses this to determine which conversations should be counted as successful and doesn't process the metadata in this message in any way. Note that Dialogflow also considers conversations that get to the conversation end page as successful even if they don't return ConversationSuccess.
                              You may set this, for example:
                              * In the entryFulfillment of a Page if entering the page indicates that the conversation succeeded.
                              * In a webhook response when you determine that you handled the customer issue.
                            properties:
                              # This can be an arbitrary json blob, so we use a string instead of a NestedObject.
                              - name: 'metadata'
                                type: String
                                description: |
                                  Custom metadata. Dialogflow doesn't impose any structure on this.
                                state_func: 'func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }'
                                custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
                                custom_expand: 'templates/terraform/custom_expand/json_schema.tmpl'
                                validation:
                                  function: 'validation.StringIsJSON'
                          - name: 'outputAudioText'
                            type: NestedObject
                            description: |
                              A text or ssml response that is preferentially used for TTS output audio synthesis, as described in the comment on the ResponseMessage message.
                            properties:
                              - name: 'allowPlaybackInterruption'
                                type: Boolean
                                description: |
                                  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.
                                output: true
                              - name: 'text'
                                type: String
                                description: |
                                  The raw text to be synthesized.
                              - name: 'ssml'
                                type: String
                                description: |
                                  The SSML text to be synthesized. For more information, see SSML.
                          - name: 'liveAgentHandoff'
                            type: NestedObject
                            description: |
                              Indicates that the conversation should be handed off to a live agent.
                              Dialogflow only uses this to determine which conversations were handed off to a human agent for measurement purposes. What else to do with this signal is up to you and your handoff procedures.
                              You may set this, for example:
                              * In the entryFulfillment of a Page if entering the page indicates something went extremely wrong in the conversation.
                              * In a webhook response when you determine that the customer issue can only be handled by a human.
                            properties:
                              # This can be an arbitrary json blob, so we use a string instead of a NestedObject.
                              - name: 'metadata'
                                type: String
                                description: |
                                  Custom metadata. Dialogflow doesn't impose any structure on this.
                                state_func: 'func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }'
                                custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
                                custom_expand: 'templates/terraform/custom_expand/json_schema.tmpl'
                                validation:
                                  function: 'validation.StringIsJSON'
                          - name: 'playAudio'
                            type: NestedObject
                            description: |
                              Specifies an audio clip to be played by the client as part of the response.
                            properties:
                              - name: 'audioUri'
                                type: String
                                description: |
                                  URI of the audio clip. Dialogflow does not impose any validation on this value. It is specific to the client that reads it.
                                required: true
                              - name: 'allowPlaybackInterruption'
                                type: Boolean
                                description: |
                                  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.
                                output: true
                          - name: 'telephonyTransferCall'
                            type: NestedObject
                            description: |
                              Represents the signal that telles the client to transfer the phone call connected to the agent to a third-party endpoint.
                            properties:
                              - name: 'phoneNumber'
                                type: String
                                description: |
                                  Transfer the call to a phone number in E.164 format.
                                required: true
                    - name: 'webhook'
                      type: String
                      description: |
                        The webhook to call. Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/webhooks/<Webhook ID>.
                    - name: 'returnPartialResponses'
                      type: Boolean
                      description: |
                        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.
                    - name: 'tag'
                      type: String
                      description: |
                        The tag used by the webhook to identify which fulfillment is being called. This field is required if webhook is specified.
                    - name: 'setParameterActions'
                      type: Array
                      description: |
                        Set parameter values before executing the webhook.
                      item_type:
                        type: NestedObject
                        properties:
                          - name: 'parameter'
                            type: String
                            description: |
                              Display name of the parameter.
                          - name: 'value'
                            type: String
                            description: |
                              The new JSON-encoded value of the parameter. A null value clears the parameter.
                            state_func: 'func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }'
                            custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
                            custom_expand: 'templates/terraform/custom_expand/json_value.tmpl'
                            validation:
                              function: 'validation.StringIsJSON'
                    - name: 'conditionalCases'
                      type: Array
                      description: |
                        Conditional cases for this fulfillment.
                      item_type:
                        type: NestedObject
                        properties:
                          # This object has a recursive schema so we use a string instead of a NestedObject
                          - name: 'cases'
                            type: String
                            description: |
                              A JSON encoded list of cascading if-else conditions. Cases are mutually exclusive. The first one with a matching condition is selected, all the rest ignored.
                              See [Case](https://cloud.google.com/dialogflow/cx/docs/reference/rest/v3/Fulfillment#case) for the schema.
                            state_func: 'func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }'
                            custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
                            custom_expand: 'templates/terraform/custom_expand/json_value.tmpl'
                            validation:
                              function: 'validation.StringIsJSON'
                - name: 'repromptEventHandlers'
                  type: Array
                  description: |
                    The handlers for parameter-level events, used to provide reprompt for the parameter or transition to a different page/flow. The supported events are:
                    * sys.no-match-<N>, where N can be from 1 to 6
                    * sys.no-match-default
                    * sys.no-input-<N>, where N can be from 1 to 6
                    * sys.no-input-default
                    * sys.invalid-parameter
                    [initialPromptFulfillment][initialPromptFulfillment] provides the first prompt for the parameter.
                    If the user's response does not fill the parameter, a no-match/no-input event will be triggered, and the fulfillment associated with the sys.no-match-1/sys.no-input-1 handler (if defined) will be called to provide a prompt. The sys.no-match-2/sys.no-input-2 handler (if defined) will respond to the next no-match/no-input event, and so on.
                    A sys.no-match-default or sys.no-input-default handler will be used to handle all following no-match/no-input events after all numbered no-match/no-input handlers for the parameter are consumed.
                    A sys.invalid-parameter handler can be defined to handle the case where the parameter values have been invalidated by webhook. For example, if the user's response fill the parameter, however the parameter was invalidated by webhook, the fulfillment associated with the sys.invalid-parameter handler (if defined) will be called to provide a prompt.
                    If the event handler for the corresponding event can't be found on the parameter, initialPromptFulfillment will be re-prompted.
                  item_type:
                    type: NestedObject
                    properties:
                      - name: 'name'
                        type: String
                        description: |
                          The unique identifier of this event handler.
                        output: true
                      - name: 'event'
                        type: String
                        description: |
                          The name of the event to handle.
                      - name: 'triggerFulfillment'
                        type: NestedObject
                        description: |
                          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.
                        properties:
                          - name: 'messages'
                            type: Array
                            description: |
                              The list of rich message responses to present to the user.
                            item_type:
                              type: NestedObject
                              properties:
                                - name: 'channel'
                                  type: String
                                  description: |
                                    The channel which the response is associated with. Clients can specify the channel via QueryParameters.channel, and only associated channel response will be returned.
                                - name: 'text'
                                  type: NestedObject
                                  description: |
                                    The text response message.
                                  properties:
                                    - name: 'text'
                                      type: Array
                                      description: |
                                        A collection of text responses.
                                      item_type:
                                        type: String
                                    - name: 'allowPlaybackInterruption'
                                      type: Boolean
                                      description: |
                                        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.
                                      output: true
                                # This can be an arbitrary json blob, so we use a string instead of a NestedObject.
                                - name: 'payload'
                                  type: String
                                  description: |
                                    A custom, platform-specific payload.
                                  state_func: 'func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }'
                                  custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
                                  custom_expand: 'templates/terraform/custom_expand/json_schema.tmpl'
                                  validation:
                                    function: 'validation.StringIsJSON'
                                - name: 'conversationSuccess'
                                  type: NestedObject
                                  description: |
                                    Indicates that the conversation succeeded, i.e., the bot handled the issue that the customer talked to it about.
                                    Dialogflow only uses this to determine which conversations should be counted as successful and doesn't process the metadata in this message in any way. Note that Dialogflow also considers conversations that get to the conversation end page as successful even if they don't return ConversationSuccess.
                                    You may set this, for example:
                                    * In the entryFulfillment of a Page if entering the page indicates that the conversation succeeded.
                                    * In a webhook response when you determine that you handled the customer issue.
                                  properties:
                                    # This can be an arbitrary json blob, so we use a string instead of a NestedObject.
                                    - name: 'metadata'
                                      type: String
                                      description: |
                                        Custom metadata. Dialogflow doesn't impose any structure on this.
                                      state_func: 'func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }'
                                      custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
                                      custom_expand: 'templates/terraform/custom_expand/json_schema.tmpl'
                                      validation:
                                        function: 'validation.StringIsJSON'
                                - name: 'outputAudioText'
                                  type: NestedObject
                                  description: |
                                    A text or ssml response that is preferentially used for TTS output audio synthesis, as described in the comment on the ResponseMessage message.
                                  properties:
                                    - name: 'allowPlaybackInterruption'
                                      type: Boolean
                                      description: |
                                        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.
                                      output: true
                                    - name: 'text'
                                      type: String
                                      description: |
                                        The raw text to be synthesized.
                                    - name: 'ssml'
                                      type: String
                                      description: |
                                        The SSML text to be synthesized. For more information, see SSML.
                                - name: 'liveAgentHandoff'
                                  type: NestedObject
                                  description: |
                                    Indicates that the conversation should be handed off to a live agent.
                                    Dialogflow only uses this to determine which conversations were handed off to a human agent for measurement purposes. What else to do with this signal is up to you and your handoff procedures.
                                    You may set this, for example:
                                    * In the entryFulfillment of a Page if entering the page indicates something went extremely wrong in the conversation.
                                    * In a webhook response when you determine that the customer issue can only be handled by a human.
                                  properties:
                                    # This can be an arbitrary json blob, so we use a string instead of a NestedObject.
                                    - name: 'metadata'
                                      type: String
                                      description: |
                                        Custom metadata. Dialogflow doesn't impose any structure on this.
                                      state_func: 'func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }'
                                      custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
                                      custom_expand: 'templates/terraform/custom_expand/json_schema.tmpl'
                                      validation:
                                        function: 'validation.StringIsJSON'
                                - name: 'playAudio'
                                  type: NestedObject
                                  description: |
                                    Specifies an audio clip to be played by the client as part of the response.
                                  properties:
                                    - name: 'audioUri'
                                      type: String
                                      description: |
                                        URI of the audio clip. Dialogflow does not impose any validation on this value. It is specific to the client that reads it.
                                      required: true
                                    - name: 'allowPlaybackInterruption'
                                      type: Boolean
                                      description: |
                                        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.
                                      output: true
                                - name: 'telephonyTransferCall'
                                  type: NestedObject
                                  description: |
                                    Represents the signal that telles the client to transfer the phone call connected to the agent to a third-party endpoint.
                                  properties:
                                    - name: 'phoneNumber'
                                      type: String
                                      description: |
                                        Transfer the call to a phone number in E.164 format.
                                      required: true
                          - name: 'webhook'
                            type: String
                            description: |
                              The webhook to call. Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/webhooks/<Webhook ID>.
                          - name: 'returnPartialResponses'
                            type: Boolean
                            description: |
                              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.
                          - name: 'tag'
                            type: String
                            description: |
                              The tag used by the webhook to identify which fulfillment is being called. This field is required if webhook is specified.
                          - name: 'setParameterActions'
                            type: Array
                            description: |
                              Set parameter values before executing the webhook.
                            item_type:
                              type: NestedObject
                              properties:
                                - name: 'parameter'
                                  type: String
                                  description: |
                                    Display name of the parameter.
                                - name: 'value'
                                  type: String
                                  description: |
                                    The new JSON-encoded value of the parameter. A null value clears the parameter.
                                  state_func: 'func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }'
                                  custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
                                  custom_expand: 'templates/terraform/custom_expand/json_value.tmpl'
                                  validation:
                                    function: 'validation.StringIsJSON'
                          - name: 'conditionalCases'
                            type: Array
                            description: |
                              Conditional cases for this fulfillment.
                            item_type:
                              type: NestedObject
                              properties:
                                # This object has a recursive schema so we use a string instead of a NestedObject
                                - name: 'cases'
                                  type: String
                                  description: |
                                    A JSON encoded list of cascading if-else conditions. Cases are mutually exclusive. The first one with a matching condition is selected, all the rest ignored.
                                    See [Case](https://cloud.google.com/dialogflow/cx/docs/reference/rest/v3/Fulfillment#case) for the schema.
                                  state_func: 'func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }'
                                  custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
                                  custom_expand: 'templates/terraform/custom_expand/json_value.tmpl'
                                  validation:
                                    function: 'validation.StringIsJSON'
                      - name: 'targetPage'
                        type: String
                        description: |
                          The target page to transition to.
                          Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/flows/<Flow ID>/pages/<Page ID>.
                      - name: 'targetFlow'
                        type: String
                        description: |
                          The target flow to transition to.
                          Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/flows/<Flow ID>.
            # This can be an arbitrary value, so we use a string instead of a NestedObject.
            - name: 'defaultValue'
              type: String
              description: |
                The default value of an optional parameter. If the parameter is required, the default value will be ignored.
              state_func: 'func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }'
              custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
              custom_expand: 'templates/terraform/custom_expand/json_value.tmpl'
              validation:
                function: 'validation.StringIsJSON'
            - name: 'redact'
              type: Boolean
              description: |
                Indicates whether the parameter content should be redacted in log.
                If redaction is enabled, the parameter content will be replaced by parameter name during logging. Note: the parameter content is subject to redaction if either parameter level redaction or entity type level redaction is enabled.
            - name: 'advancedSettings'
              type: NestedObject
              description: |
                Hierarchical advanced settings for this parameter. The settings exposed at the lower level overrides the settings exposed at the higher level.
                Hierarchy: Agent->Flow->Page->Fulfillment/Parameter.
              properties:
                - name: 'dtmfSettings'
                  type: NestedObject
                  description: |
                    Define behaviors for DTMF (dual tone multi frequency). DTMF settings does not override each other. DTMF settings set at different levels define DTMF detections running in parallel. Exposed at the following levels:
                    * Agent level
                    * Flow level
                    * Page level
                    * Parameter level
                  properties:
                    - name: 'enabled'
                      type: Boolean
                      description: |
                        If true, incoming audio is processed for DTMF (dual tone multi frequency) events. For example, if the caller presses a button on their telephone keypad and DTMF processing is enabled, Dialogflow will detect the event (e.g. a "3" was pressed) in the incoming audio and pass the event to the bot to drive business logic (e.g. when 3 is pressed, return the account balance).
                    - name: 'maxDigits'
                      type: Integer
                      description: |
                        Max length of DTMF digits.
                    - name: 'finishDigit'
                      type: String
                      description: |
                        The digit that terminates a DTMF digit sequence.
  - name: 'transitionRouteGroups'
    type: Array
    description: |
      Ordered list of TransitionRouteGroups associated with the page. Transition route groups must be unique within a page.
      If multiple transition routes within a page scope refer to the same intent, then the precedence order is: page's transition route -> page's transition route group -> flow's transition routes.
      If multiple transition route groups within a page contain the same intent, then the first group in the ordered list takes precedence.
      Format:projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/flows/<Flow ID>/transitionRouteGroups/<TransitionRouteGroup ID>.
    item_type:
      type: String
  - name: 'transitionRoutes'
    type: Array
    description: |
      A list of transitions for the transition rules of this page. They route the conversation to another page in the same flow, or another flow.
      When we are in a certain page, the TransitionRoutes are evalauted in the following order:
      TransitionRoutes defined in the page with intent specified.
      TransitionRoutes defined in the transition route groups with intent specified.
      TransitionRoutes defined in flow with intent specified.
      TransitionRoutes defined in the transition route groups with intent specified.
      TransitionRoutes defined in the page with only condition specified.
      TransitionRoutes defined in the transition route groups with only condition specified.
    item_type:
      type: NestedObject
      properties:
        - name: 'name'
          type: String
          description: |
            The unique identifier of this transition route.
          output: true
        - name: 'intent'
          type: String
          description: |
            The unique identifier of an Intent.
            Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/intents/<Intent ID>. 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.
        - name: 'condition'
          type: String
          description: |
            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.
        - name: 'triggerFulfillment'
          type: NestedObject
          description: |
            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.
          properties:
            - name: 'messages'
              type: Array
              description: |
                The list of rich message responses to present to the user.
              item_type:
                type: NestedObject
                properties:
                  - name: 'channel'
                    type: String
                    description: |
                      The channel which the response is associated with. Clients can specify the channel via QueryParameters.channel, and only associated channel response will be returned.
                  - name: 'text'
                    type: NestedObject
                    description: |
                      The text response message.
                    properties:
                      - name: 'text'
                        type: Array
                        description: |
                          A collection of text responses.
                        item_type:
                          type: String
                      - name: 'allowPlaybackInterruption'
                        type: Boolean
                        description: |
                          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.
                        output: true
                  # This can be an arbitrary json blob, so we use a string instead of a NestedObject.
                  - name: 'payload'
                    type: String
                    description: |
                      A custom, platform-specific payload.
                    state_func: 'func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }'
                    custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
                    custom_expand: 'templates/terraform/custom_expand/json_schema.tmpl'
                    validation:
                      function: 'validation.StringIsJSON'
                  - name: 'conversationSuccess'
                    type: NestedObject
                    description: |
                      Indicates that the conversation succeeded, i.e., the bot handled the issue that the customer talked to it about.
                      Dialogflow only uses this to determine which conversations should be counted as successful and doesn't process the metadata in this message in any way. Note that Dialogflow also considers conversations that get to the conversation end page as successful even if they don't return ConversationSuccess.
                      You may set this, for example:
                      * In the entryFulfillment of a Page if entering the page indicates that the conversation succeeded.
                      * In a webhook response when you determine that you handled the customer issue.
                    properties:
                      # This can be an arbitrary json blob, so we use a string instead of a NestedObject.
                      - name: 'metadata'
                        type: String
                        description: |
                          Custom metadata. Dialogflow doesn't impose any structure on this.
                        state_func: 'func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }'
                        custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
                        custom_expand: 'templates/terraform/custom_expand/json_schema.tmpl'
                        validation:
                          function: 'validation.StringIsJSON'
                  - name: 'outputAudioText'
                    type: NestedObject
                    description: |
                      A text or ssml response that is preferentially used for TTS output audio synthesis, as described in the comment on the ResponseMessage message.
                    properties:
                      - name: 'allowPlaybackInterruption'
                        type: Boolean
                        description: |
                          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.
                        output: true
                      - name: 'text'
                        type: String
                        description: |
                          The raw text to be synthesized.
                      - name: 'ssml'
                        type: String
                        description: |
                          The SSML text to be synthesized. For more information, see SSML.
                  - name: 'liveAgentHandoff'
                    type: NestedObject
                    description: |
                      Indicates that the conversation should be handed off to a live agent.
                      Dialogflow only uses this to determine which conversations were handed off to a human agent for measurement purposes. What else to do with this signal is up to you and your handoff procedures.
                      You may set this, for example:
                      * In the entryFulfillment of a Page if entering the page indicates something went extremely wrong in the conversation.
                      * In a webhook response when you determine that the customer issue can only be handled by a human.
                    properties:
                      # This can be an arbitrary json blob, so we use a string instead of a NestedObject.
                      - name: 'metadata'
                        type: String
                        description: |
                          Custom metadata. Dialogflow doesn't impose any structure on this.
                        state_func: 'func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }'
                        custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
                        custom_expand: 'templates/terraform/custom_expand/json_schema.tmpl'
                        validation:
                          function: 'validation.StringIsJSON'
                  - name: 'playAudio'
                    type: NestedObject
                    description: |
                      Specifies an audio clip to be played by the client as part of the response.
                    properties:
                      - name: 'audioUri'
                        type: String
                        description: |
                          URI of the audio clip. Dialogflow does not impose any validation on this value. It is specific to the client that reads it.
                        required: true
                      - name: 'allowPlaybackInterruption'
                        type: Boolean
                        description: |
                          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.
                        output: true
                  - name: 'telephonyTransferCall'
                    type: NestedObject
                    description: |
                      Represents the signal that telles the client to transfer the phone call connected to the agent to a third-party endpoint.
                    properties:
                      - name: 'phoneNumber'
                        type: String
                        description: |
                          Transfer the call to a phone number in E.164 format.
                        required: true
            - name: 'webhook'
              type: String
              description: |
                The webhook to call. Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/webhooks/<Webhook ID>.
            - name: 'returnPartialResponses'
              type: Boolean
              description: |
                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.
            - name: 'tag'
              type: String
              description: |
                The tag used by the webhook to identify which fulfillment is being called. This field is required if webhook is specified.
            - name: 'setParameterActions'
              type: Array
              description: |
                Set parameter values before executing the webhook.
              item_type:
                type: NestedObject
                properties:
                  - name: 'parameter'
                    type: String
                    description: |
                      Display name of the parameter.
                  - name: 'value'
                    type: String
                    description: |
                      The new JSON-encoded value of the parameter. A null value clears the parameter.
                    state_func: 'func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }'
                    custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
                    custom_expand: 'templates/terraform/custom_expand/json_value.tmpl'
                    validation:
                      function: 'validation.StringIsJSON'
            - name: 'conditionalCases'
              type: Array
              description: |
                Conditional cases for this fulfillment.
              item_type:
                type: NestedObject
                properties:
                  # This object has a recursive schema so we use a string instead of a NestedObject
                  - name: 'cases'
                    type: String
                    description: |
                      A JSON encoded list of cascading if-else conditions. Cases are mutually exclusive. The first one with a matching condition is selected, all the rest ignored.
                      See [Case](https://cloud.google.com/dialogflow/cx/docs/reference/rest/v3/Fulfillment#case) for the schema.
                    state_func: 'func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }'
                    custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
                    custom_expand: 'templates/terraform/custom_expand/json_value.tmpl'
                    validation:
                      function: 'validation.StringIsJSON'
        - name: 'targetPage'
          type: String
          description: |
            The target page to transition to.
            Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/flows/<Flow ID>/pages/<Page ID>.
        - name: 'targetFlow'
          type: String
          description: |
            The target flow to transition to.
            Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/flows/<Flow ID>.
  - name: 'eventHandlers'
    type: Array
    description: |
      Handlers associated with the page to handle events such as webhook errors, no match or no input.
    item_type:
      type: NestedObject
      properties:
        - name: 'name'
          type: String
          description: |
            The unique identifier of this event handler.
          output: true
        - name: 'event'
          type: String
          description: |
            The name of the event to handle.
        - name: 'triggerFulfillment'
          type: NestedObject
          description: |
            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.
          properties:
            - name: 'messages'
              type: Array
              description: |
                The list of rich message responses to present to the user.
              item_type:
                type: NestedObject
                properties:
                  - name: 'channel'
                    type: String
                    description: |
                      The channel which the response is associated with. Clients can specify the channel via QueryParameters.channel, and only associated channel response will be returned.
                  - name: 'text'
                    type: NestedObject
                    description: |
                      The text response message.
                    properties:
                      - name: 'text'
                        type: Array
                        description: |
                          A collection of text responses.
                        item_type:
                          type: String
                      - name: 'allowPlaybackInterruption'
                        type: Boolean
                        description: |
                          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.
                        output: true
                  - name: 'payload'
                    type: String
                    description: |
                      A custom, platform-specific payload.
                    state_func: 'func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }'
                    custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
                    custom_expand: 'templates/terraform/custom_expand/json_schema.tmpl'
                    validation:
                      function: 'validation.StringIsJSON'
                  - name: 'conversationSuccess'
                    type: NestedObject
                    description: |
                      Indicates that the conversation succeeded, i.e., the bot handled the issue that the customer talked to it about.
                      Dialogflow only uses this to determine which conversations should be counted as successful and doesn't process the metadata in this message in any way. Note that Dialogflow also considers conversations that get to the conversation end page as successful even if they don't return ConversationSuccess.
                      You may set this, for example:
                      * In the entryFulfillment of a Page if entering the page indicates that the conversation succeeded.
                      * In a webhook response when you determine that you handled the customer issue.
                    properties:
                      - name: 'metadata'
                        type: String
                        description: |
                          Custom metadata. Dialogflow doesn't impose any structure on this.
                        state_func: 'func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }'
                        custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
                        custom_expand: 'templates/terraform/custom_expand/json_schema.tmpl'
                        validation:
                          function: 'validation.StringIsJSON'
                  - name: 'outputAudioText'
                    type: NestedObject
                    description: |
                      A text or ssml response that is preferentially used for TTS output audio synthesis, as described in the comment on the ResponseMessage message.
                    properties:
                      - name: 'allowPlaybackInterruption'
                        type: Boolean
                        description: |
                          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.
                        output: true
                      - name: 'text'
                        type: String
                        description: |
                          The raw text to be synthesized.
                      - name: 'ssml'
                        type: String
                        description: |
                          The SSML text to be synthesized. For more information, see SSML.
                  - name: 'liveAgentHandoff'
                    type: NestedObject
                    description: |
                      Indicates that the conversation should be handed off to a live agent.
                      Dialogflow only uses this to determine which conversations were handed off to a human agent for measurement purposes. What else to do with this signal is up to you and your handoff procedures.
                      You may set this, for example:
                      * In the entryFulfillment of a Page if entering the page indicates something went extremely wrong in the conversation.
                      * In a webhook response when you determine that the customer issue can only be handled by a human.
                    properties:
                      - name: 'metadata'
                        type: String
                        description: |
                          Custom metadata. Dialogflow doesn't impose any structure on this.
                        state_func: 'func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }'
                        custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
                        custom_expand: 'templates/terraform/custom_expand/json_schema.tmpl'
                        validation:
                          function: 'validation.StringIsJSON'
                  - name: 'playAudio'
                    type: NestedObject
                    description: |
                      Specifies an audio clip to be played by the client as part of the response.
                    properties:
                      - name: 'audioUri'
                        type: String
                        description: |
                          URI of the audio clip. Dialogflow does not impose any validation on this value. It is specific to the client that reads it.
                        required: true
                      - name: 'allowPlaybackInterruption'
                        type: Boolean
                        description: |
                          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.
                        output: true
                  - name: 'telephonyTransferCall'
                    type: NestedObject
                    description: |
                      Represents the signal that telles the client to transfer the phone call connected to the agent to a third-party endpoint.
                    properties:
                      - name: 'phoneNumber'
                        type: String
                        description: |
                          Transfer the call to a phone number in E.164 format.
                        required: true
            - name: 'webhook'
              type: String
              description: |
                The webhook to call. Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/webhooks/<Webhook ID>.
            - name: 'returnPartialResponses'
              type: Boolean
              description: |
                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.
            - name: 'tag'
              type: String
              description: |
                The tag used by the webhook to identify which fulfillment is being called. This field is required if webhook is specified.
            - name: 'setParameterActions'
              type: Array
              description: |
                Set parameter values before executing the webhook.
              item_type:
                type: NestedObject
                properties:
                  - name: 'parameter'
                    type: String
                    description: |
                      Display name of the parameter.
                  - name: 'value'
                    type: String
                    description: |
                      The new JSON-encoded value of the parameter. A null value clears the parameter.
                    state_func: 'func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }'
                    custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
                    custom_expand: 'templates/terraform/custom_expand/json_value.tmpl'
                    validation:
                      function: 'validation.StringIsJSON'
            - name: 'conditionalCases'
              type: Array
              description: |
                Conditional cases for this fulfillment.
              item_type:
                type: NestedObject
                properties:
                  - name: 'cases'
                    type: String
                    description: |
                      A JSON encoded list of cascading if-else conditions. Cases are mutually exclusive. The first one with a matching condition is selected, all the rest ignored.
                      See [Case](https://cloud.google.com/dialogflow/cx/docs/reference/rest/v3/Fulfillment#case) for the schema.
                    state_func: 'func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }'
                    custom_flatten: 'templates/terraform/custom_flatten/json_schema.tmpl'
                    custom_expand: 'templates/terraform/custom_expand/json_value.tmpl'
                    validation:
                      function: 'validation.StringIsJSON'
        - name: 'targetPage'
          type: String
          description: |
            The target page to transition to.
            Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/flows/<Flow ID>/pages/<Page ID>.
        - name: 'targetFlow'
          type: String
          description: |
            The target flow to transition to.
            Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/flows/<Flow ID>.
  - name: 'advancedSettings'
    type: NestedObject
    description: |
      Hierarchical advanced settings for this page. The settings exposed at the lower level overrides the settings exposed at the higher level.
      Hierarchy: Agent->Flow->Page->Fulfillment/Parameter.
    properties:
      - name: 'dtmfSettings'
        type: NestedObject
        description: |
          Define behaviors for DTMF (dual tone multi frequency). DTMF settings does not override each other. DTMF settings set at different levels define DTMF detections running in parallel. Exposed at the following levels:
          * Agent level
          * Flow level
          * Page level
          * Parameter level
        properties:
          - name: 'enabled'
            type: Boolean
            description: |
              If true, incoming audio is processed for DTMF (dual tone multi frequency) events. For example, if the caller presses a button on their telephone keypad and DTMF processing is enabled, Dialogflow will detect the event (e.g. a "3" was pressed) in the incoming audio and pass the event to the bot to drive business logic (e.g. when 3 is pressed, return the account balance).
          - name: 'maxDigits'
            type: Integer
            description: |
              Max length of DTMF digits.
          - name: 'finishDigit'
            type: String
            description: |
              The digit that terminates a DTMF digit sequence.
