google_dialogflow_cx_test_case

You can use the built-in test feature to uncover bugs and prevent regressions. A test execution verifies that agent responses have not changed for end-user inputs defined in the test case.

To get more information about TestCase, see:

Open in Cloud Shell

Example Usage - Dialogflowcx Test Case Full

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://storage.cloud.google.com/dialogflow-test-host-image/cloud-logo.png"
  enable_stackdriver_logging = true
  enable_spell_correction    = true
  speech_to_text_settings {
    enable_speech_adaptation = true
  }
}

resource "google_dialogflow_cx_page" "page" {
  parent       = google_dialogflow_cx_agent.agent.start_flow
  display_name = "MyPage"

  transition_routes {
    intent = google_dialogflow_cx_intent.intent.id
    trigger_fulfillment {
      messages {
        text {
          text = ["Training phrase response"]
        }
      }
    }
  }

  event_handlers {
    event = "some-event"
    trigger_fulfillment {
      messages {
        text {
          text = ["Handling some event"]
        }
      }
    }
  }
}

resource "google_dialogflow_cx_intent" "intent" {
  parent       = google_dialogflow_cx_agent.agent.id
  display_name = "MyIntent"
  priority     = 1
  training_phrases {
    parts {
      text = "training phrase"
    }
    repeat_count = 1
  }
}

resource "google_dialogflow_cx_test_case" "basic_test_case" {
  parent       = google_dialogflow_cx_agent.agent.id
  display_name = "MyTestCase"
  tags         = ["#tag1"]
  notes        = "demonstrates a simple training phrase response"

  test_config {
    tracking_parameters = ["some_param"]
    page                = google_dialogflow_cx_page.page.id
  }

  test_case_conversation_turns {
    user_input {
      input {
        language_code = "en"
        text {
          text = "training phrase"
        }
      }
      injected_parameters       = jsonencode({ some_param = "1" })
      is_webhook_enabled        = true
      enable_sentiment_analysis = true
    }
    virtual_agent_output {
      session_parameters = jsonencode({ some_param = "1" })
      triggered_intent {
        name = google_dialogflow_cx_intent.intent.id
      }
      current_page {
        name = google_dialogflow_cx_page.page.id
      }
      text_responses {
        text = ["Training phrase response"]
      }
    }
  }

  test_case_conversation_turns {
    user_input {
      input {
        event {
          event = "some-event"
        }
      }
    }
    virtual_agent_output {
      current_page {
        name = google_dialogflow_cx_page.page.id
      }
      text_responses {
        text = ["Handling some event"]
      }
    }
  }

  test_case_conversation_turns {
    user_input {
      input {
        dtmf {
          digits       = "12"
          finish_digit = "3"
        }
      }
    }
    virtual_agent_output {
      text_responses {
        text = ["I didn't get that. Can you say it again?"]
      }
    }
  }
}

Argument Reference

The following arguments are supported:


The test_config block supports:

The test_case_conversation_turns block supports:

The user_input block supports:

The input block supports:

The text block supports:

The event block supports:

The dtmf block supports:

The virtual_agent_output block supports:

The triggered_intent block supports:

The current_page block supports:

The text_responses block supports:

Attributes Reference

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

The last_test_result block contains:

The conversation_turns block supports:

The user_input block supports:

The input block supports:

The text block supports:

The event block supports:

The dtmf block supports:

The virtual_agent_output block supports:

The differences block supports:

The triggered_intent block supports:

The current_page block supports:

The text_responses block supports:

The status block supports:

Timeouts

This resource provides the following Timeouts configuration options:

Import

TestCase can be imported using any of these accepted formats:

In Terraform v1.5.0 and later, use an import block to import TestCase using one of the formats above. For example:

import {
  id = "{{parent}}/testCases/{{name}}"
  to = google_dialogflow_cx_test_case.default
}

When using the terraform import command, TestCase can be imported using one of the formats above. For example:

$ terraform import google_dialogflow_cx_test_case.default {{parent}}/testCases/{{name}}