blob: 4bf2a084fad2369a563720770e5866dc04a09009 [file] [log] [blame]
---
# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** Type: MMv1 ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in
# .github/CONTRIBUTING.md.
#
# ----------------------------------------------------------------------------
subcategory: "Dialogflow CX"
description: |-
You can use the built-in test feature to uncover bugs and prevent regressions.
---
# 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:
* [API documentation](https://cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.testCases)
* How-to Guides
* [Official Documentation](https://cloud.google.com/dialogflow/cx/docs)
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=dialogflowcx_test_case_full&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
</a>
</div>
## Example Usage - Dialogflowcx Test Case Full
```hcl
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:
* `display_name` -
(Required)
The human-readable name of the test case, unique within the agent. Limit of 200 characters.
- - -
* `tags` -
(Optional)
Tags are short descriptions that users may apply to test cases for organizational and filtering purposes.
Each tag should start with "#" and has a limit of 30 characters
* `notes` -
(Optional)
Additional freeform notes about the test case. Limit of 400 characters.
* `test_config` -
(Optional)
Config for the test case.
Structure is [documented below](#nested_test_config).
* `test_case_conversation_turns` -
(Optional)
The conversation turns uttered when the test case was created, in chronological order. These include the canonical set of agent utterances that should occur when the agent is working properly.
Structure is [documented below](#nested_test_case_conversation_turns).
* `parent` -
(Optional)
The agent to create the test case for.
Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>.
<a name="nested_test_config"></a>The `test_config` block supports:
* `tracking_parameters` -
(Optional)
Session parameters to be compared when calculating differences.
* `flow` -
(Optional)
Flow name to start the test case with.
Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/flows/<Flow ID>.
Only one of flow and page should be set to indicate the starting point of the test case. If neither is set, the test case will start with start page on the default start flow.
* `page` -
(Optional)
The page to start the test case with.
Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/flows/<Flow ID>/pages/<Page ID>.
Only one of flow and page should be set to indicate the starting point of the test case. If neither is set, the test case will start with start page on the default start flow.
<a name="nested_test_case_conversation_turns"></a>The `test_case_conversation_turns` block supports:
* `user_input` -
(Optional)
The user input.
Structure is [documented below](#nested_user_input).
* `virtual_agent_output` -
(Optional)
The virtual agent output.
Structure is [documented below](#nested_virtual_agent_output).
<a name="nested_user_input"></a>The `user_input` block supports:
* `input` -
(Optional)
User input. Supports text input, event input, dtmf input in the test case.
Structure is [documented below](#nested_input).
* `injected_parameters` -
(Optional)
Parameters that need to be injected into the conversation during intent detection.
* `is_webhook_enabled` -
(Optional)
If webhooks should be allowed to trigger in response to the user utterance. Often if parameters are injected, webhooks should not be enabled.
* `enable_sentiment_analysis` -
(Optional)
Whether sentiment analysis is enabled.
<a name="nested_input"></a>The `input` block supports:
* `language_code` -
(Optional)
The language of the input. See [Language Support](https://cloud.google.com/dialogflow/cx/docs/reference/language) for a list of the currently supported language codes.
Note that queries in the same session do not necessarily need to specify the same language.
* `text` -
(Optional)
The natural language text to be processed.
Structure is [documented below](#nested_text).
* `event` -
(Optional)
The event to be triggered.
Structure is [documented below](#nested_event).
* `dtmf` -
(Optional)
The DTMF event to be handled.
Structure is [documented below](#nested_dtmf).
<a name="nested_text"></a>The `text` block supports:
* `text` -
(Required)
The natural language text to be processed. Text length must not exceed 256 characters.
<a name="nested_event"></a>The `event` block supports:
* `event` -
(Required)
Name of the event.
<a name="nested_dtmf"></a>The `dtmf` block supports:
* `digits` -
(Optional)
The dtmf digits.
* `finish_digit` -
(Optional)
The finish digit (if any).
<a name="nested_virtual_agent_output"></a>The `virtual_agent_output` block supports:
* `session_parameters` -
(Optional)
The session parameters available to the bot at this point.
* `triggered_intent` -
(Optional)
The [Intent](https://cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.intents#Intent) that triggered the response.
Structure is [documented below](#nested_triggered_intent).
* `current_page` -
(Optional)
The [Page](https://cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.flows.pages#Page) on which the utterance was spoken.
Structure is [documented below](#nested_current_page).
* `text_responses` -
(Optional)
The text responses from the agent for the turn.
Structure is [documented below](#nested_text_responses).
<a name="nested_triggered_intent"></a>The `triggered_intent` block supports:
* `name` -
(Optional)
The unique identifier of the intent.
Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/intents/<Intent ID>.
* `display_name` -
(Output)
The human-readable name of the intent, unique within the agent.
<a name="nested_current_page"></a>The `current_page` block supports:
* `name` -
(Optional)
The unique identifier of the page.
Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/flows/<Flow ID>/pages/<Page ID>.
* `display_name` -
(Output)
The human-readable name of the page, unique within the flow.
<a name="nested_text_responses"></a>The `text_responses` block supports:
* `text` -
(Optional)
A collection of text responses.
## Attributes Reference
In addition to the arguments listed above, the following computed attributes are exported:
* `id` - an identifier for the resource with format `{{parent}}/testCases/{{name}}`
* `name` -
The unique identifier of the test case.
Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/testCases/<TestCase ID>.
* `creation_time` -
When the test was created. A timestamp in RFC3339 text format.
* `last_test_result` -
The latest test result.
Structure is [documented below](#nested_last_test_result).
<a name="nested_last_test_result"></a>The `last_test_result` block contains:
* `name` -
(Optional)
The resource name for the test case result.
Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/testCases/<TestCase ID>/results/<TestCaseResult ID>.
* `environment` -
(Optional)
Environment where the test was run. If not set, it indicates the draft environment.
* `conversation_turns` -
(Optional)
The conversation turns uttered during the test case replay in chronological order.
Structure is [documented below](#nested_conversation_turns).
* `test_result` -
(Optional)
Whether the test case passed in the agent environment.
* PASSED: The test passed.
* FAILED: The test did not pass.
Possible values are: `PASSED`, `FAILED`.
* `test_time` -
(Optional)
The time that the test was run. A timestamp in RFC3339 text format.
<a name="nested_conversation_turns"></a>The `conversation_turns` block supports:
* `user_input` -
(Optional)
The user input.
Structure is [documented below](#nested_user_input).
* `virtual_agent_output` -
(Optional)
The virtual agent output.
Structure is [documented below](#nested_virtual_agent_output).
<a name="nested_user_input"></a>The `user_input` block supports:
* `input` -
(Optional)
User input. Supports text input, event input, dtmf input in the test case.
Structure is [documented below](#nested_input).
* `injected_parameters` -
(Optional)
Parameters that need to be injected into the conversation during intent detection.
* `is_webhook_enabled` -
(Optional)
If webhooks should be allowed to trigger in response to the user utterance. Often if parameters are injected, webhooks should not be enabled.
* `enable_sentiment_analysis` -
(Optional)
Whether sentiment analysis is enabled.
<a name="nested_input"></a>The `input` block supports:
* `language_code` -
(Optional)
The language of the input. See [Language Support](https://cloud.google.com/dialogflow/cx/docs/reference/language) for a list of the currently supported language codes.
Note that queries in the same session do not necessarily need to specify the same language.
* `text` -
(Optional)
The natural language text to be processed.
Structure is [documented below](#nested_text).
* `event` -
(Optional)
The event to be triggered.
Structure is [documented below](#nested_event).
* `dtmf` -
(Optional)
The DTMF event to be handled.
Structure is [documented below](#nested_dtmf).
<a name="nested_text"></a>The `text` block supports:
* `text` -
(Required)
The natural language text to be processed. Text length must not exceed 256 characters.
<a name="nested_event"></a>The `event` block supports:
* `event` -
(Required)
Name of the event.
<a name="nested_dtmf"></a>The `dtmf` block supports:
* `digits` -
(Optional)
The dtmf digits.
* `finish_digit` -
(Optional)
The finish digit (if any).
<a name="nested_virtual_agent_output"></a>The `virtual_agent_output` block supports:
* `session_parameters` -
(Optional)
The session parameters available to the bot at this point.
* `differences` -
(Optional)
The list of differences between the original run and the replay for this output, if any.
Structure is [documented below](#nested_differences).
* `triggered_intent` -
(Optional)
The [Intent](https://cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.intents#Intent) that triggered the response.
Structure is [documented below](#nested_triggered_intent).
* `current_page` -
(Optional)
The [Page](https://cloud.google.com/dialogflow/cx/docs/reference/rest/v3/projects.locations.agents.flows.pages#Page) on which the utterance was spoken.
Structure is [documented below](#nested_current_page).
* `text_responses` -
(Optional)
The text responses from the agent for the turn.
Structure is [documented below](#nested_text_responses).
* `status` -
(Optional)
Response error from the agent in the test result. If set, other output is empty.
Structure is [documented below](#nested_status).
<a name="nested_differences"></a>The `differences` block supports:
* `type` -
(Optional)
The type of diff.
* INTENT: The intent.
* PAGE: The page.
* PARAMETERS: The parameters.
* UTTERANCE: The message utterance.
* FLOW: The flow.
Possible values are: `INTENT`, `PAGE`, `PARAMETERS`, `UTTERANCE`, `FLOW`.
* `description` -
(Optional)
A human readable description of the diff, showing the actual output vs expected output.
<a name="nested_triggered_intent"></a>The `triggered_intent` block supports:
* `name` -
(Optional)
The unique identifier of the intent.
Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/intents/<Intent ID>.
* `display_name` -
(Optional)
The human-readable name of the intent, unique within the agent.
<a name="nested_current_page"></a>The `current_page` block supports:
* `name` -
(Optional)
The unique identifier of the page.
Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/flows/<Flow ID>/pages/<Page ID>.
* `display_name` -
(Optional)
The human-readable name of the page, unique within the flow.
<a name="nested_text_responses"></a>The `text_responses` block supports:
* `text` -
(Optional)
A collection of text responses.
<a name="nested_status"></a>The `status` block supports:
* `code` -
(Optional)
The status code, which should be an enum value of google.rpc.Code.
* `message` -
(Optional)
A developer-facing error message.
* `details` -
(Optional)
A JSON encoded list of messages that carry the error details.
## Timeouts
This resource provides the following
[Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options:
- `create` - Default is 40 minutes.
- `update` - Default is 40 minutes.
- `delete` - Default is 20 minutes.
## Import
TestCase can be imported using any of these accepted formats:
* `{{parent}}/testCases/{{name}}`
In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import TestCase using one of the formats above. For example:
```tf
import {
id = "{{parent}}/testCases/{{name}}"
to = google_dialogflow_cx_test_case.default
}
```
When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), TestCase can be imported using one of the formats above. For example:
```
$ terraform import google_dialogflow_cx_test_case.default {{parent}}/testCases/{{name}}
```