Import dialogflow cx agent from zip file

Dear Team,

We are trying to import dialogflow cx agent using an “agent.zip” file which is placed under GCS bucket. But we couldn’t find any option under the following resource block to import the agent directly using a zip file.

resource "google_dialogflow_cx_agent" "full_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
  }
  advanced_settings {
    audio_export_gcs_destination {
      uri = "${google_storage_bucket.bucket.url}/prefix-"
    }
    dtmf_settings {
      enabled = true
      max_digits = 1
      finish_digit = "#"
    }
  }
  git_integration_settings {
    github_settings {
      display_name = "Github Repo"
      repository_uri = "https://api.github.com/repos/githubtraining/hellogitworld"
      tracking_branch = "main"
      access_token = "secret-token"
      branches = ["main"]
    }
  }
  text_to_speech_settings {
    synthesize_speech_configs = jsonencode({
      en = {
        voice = {
          name = "en-US-Neural2-A"
        }
      }
      fr = {
        voice = {
          name = "fr-CA-Neural2-A",
        }
      }
    })
  }
}

Appreciate your prompt support!


Regards,
Gurumohan G

Hi @gmcloud27,

I’m not familiar with this resource but in reading the provider documentation is appears there is no direct way of triggering a restore from an object in a GCS bucket using the resource you reference. Which is for deploying the agent resource, as opposed to restoring into it.

However it looks like the git integration elements may provide a different method of doing what you want (e.g… automatically deploying the agent code to the resource), but means you have to have the agent code in source control.

Another possible approach, reviewing the API documentation:
Method: projects.locations.agents.restore | Dialogflow CX | Google Cloud
May be to carry out a RESTful call to the API once the resource is deployed.
The agentUri attribute indicates the URI to restore agent from an object in a GCS bucket. Which appears to be what you need.

You would have to use a suitable provider (perhaps something like terrcurl) and use this alongside other elements such as lifecycle replace_triggered_by and ignore_changes blocks if needed in the google_dialogflow_cx_agent resource block or restAPI call resource block.

Not necessarily a solution for you, but hopefully gives you a few more avenues to investigate.

Good Luck!