hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.33k stars 1.73k forks source link

Dialogflow Intent - Multi-language Support #16393

Open greese-insight opened 12 months ago

greese-insight commented 12 months ago

Community Note

Description

Currently the language_code for an intent is created at the root of the module. This does not allow for an intent to support multiple languages. Additionally, this field is not maintained within state, causing a recreation every time terraform plan or terraform apply is run.

New or Affected Resource(s)

Potential Terraform Configuration

resource "google_dialogflow_cx_agent" "agent" {
  display_name = "dialogflowcx-agent"
  location = "global"
  default_language_code = "en"
  supported_language_codes = ["fr","de","es"]
  time_zone = "America/New_York"
  description = "Example description."
  avatar_uri = "https://cloud.google.com/_static/images/cloud/icons/favicons/onecloud/super_cloud.png"
  enable_stackdriver_logging = true
  enable_spell_correction    = true
    speech_to_text_settings {
        enable_speech_adaptation = true
    }
}

resource "google_dialogflow_cx_intent" "basic_intent" {
  parent       = google_dialogflow_cx_agent.agent.id
  display_name = "Example"
  priority     = 1
  description  = "Intent example"
  training_phrases {
     # new functionality
     language_code = "en"

     parts {
         text = "training"
     }

     parts {
         text = "phrase"
     }

     parts {
         text = "example"
     }

     repeat_count = 1
  }

  training_phrases {
     # new functionality
     language_code = "es"

     parts {
         text = "ejemplo"
     }

     parts {
         text = "de"
     }

     parts {
         text = "frase"
     }

     parts {
         text = "de"
     }

     parts {
         text = "entrenamiento"
     }

     repeat_count = 1
  }

  parameters {
    id          = "param1"
    entity_type = "projects/-/locations/-/agents/-/entityTypes/sys.date"
  }

  labels  = {
      label1 = "value1",
      label2 = "value2"
   } 
} 

References

b/308569101

greese-insight commented 12 months ago

An example of the forced recreation (showing recreation of default start flow null_resource due to change, based on https://github.com/GoogleCloudPlatform/contact-center-ai-samples/blob/main/dialogflow-cx/shirt-order-agent/flows.tf):

image