CxTestCase

class CxTestCase : KotlinCustomResource

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:

Example Usage

Dialogflowcx Test Case Full

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.diagflow.CxAgent;
import com.pulumi.gcp.diagflow.CxAgentArgs;
import com.pulumi.gcp.diagflow.inputs.CxAgentSpeechToTextSettingsArgs;
import com.pulumi.gcp.diagflow.CxIntent;
import com.pulumi.gcp.diagflow.CxIntentArgs;
import com.pulumi.gcp.diagflow.inputs.CxIntentTrainingPhraseArgs;
import com.pulumi.gcp.diagflow.CxPage;
import com.pulumi.gcp.diagflow.CxPageArgs;
import com.pulumi.gcp.diagflow.inputs.CxPageTransitionRouteArgs;
import com.pulumi.gcp.diagflow.inputs.CxPageTransitionRouteTriggerFulfillmentArgs;
import com.pulumi.gcp.diagflow.inputs.CxPageEventHandlerArgs;
import com.pulumi.gcp.diagflow.inputs.CxPageEventHandlerTriggerFulfillmentArgs;
import com.pulumi.gcp.diagflow.CxTestCase;
import com.pulumi.gcp.diagflow.CxTestCaseArgs;
import com.pulumi.gcp.diagflow.inputs.CxTestCaseTestConfigArgs;
import com.pulumi.gcp.diagflow.inputs.CxTestCaseTestCaseConversationTurnArgs;
import com.pulumi.gcp.diagflow.inputs.CxTestCaseTestCaseConversationTurnUserInputArgs;
import com.pulumi.gcp.diagflow.inputs.CxTestCaseTestCaseConversationTurnUserInputInputArgs;
import com.pulumi.gcp.diagflow.inputs.CxTestCaseTestCaseConversationTurnUserInputInputTextArgs;
import com.pulumi.gcp.diagflow.inputs.CxTestCaseTestCaseConversationTurnVirtualAgentOutputArgs;
import com.pulumi.gcp.diagflow.inputs.CxTestCaseTestCaseConversationTurnVirtualAgentOutputTriggeredIntentArgs;
import com.pulumi.gcp.diagflow.inputs.CxTestCaseTestCaseConversationTurnVirtualAgentOutputCurrentPageArgs;
import com.pulumi.gcp.diagflow.inputs.CxTestCaseTestCaseConversationTurnUserInputInputEventArgs;
import com.pulumi.gcp.diagflow.inputs.CxTestCaseTestCaseConversationTurnUserInputInputDtmfArgs;
import static com.pulumi.codegen.internal.Serialization.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var agent = new CxAgent("agent", CxAgentArgs.builder()
.displayName("dialogflowcx-agent")
.location("global")
.defaultLanguageCode("en")
.supportedLanguageCodes(
"fr",
"de",
"es")
.timeZone("America/New_York")
.description("Example description.")
.avatarUri("https://storage.cloud.google.com/dialogflow-test-host-image/cloud-logo.png")
.enableStackdriverLogging(true)
.enableSpellCorrection(true)
.speechToTextSettings(CxAgentSpeechToTextSettingsArgs.builder()
.enableSpeechAdaptation(true)
.build())
.build());
var intent = new CxIntent("intent", CxIntentArgs.builder()
.parent(agent.id())
.displayName("MyIntent")
.priority(1)
.trainingPhrases(CxIntentTrainingPhraseArgs.builder()
.parts(CxIntentTrainingPhrasePartArgs.builder()
.text("training phrase")
.build())
.repeatCount(1)
.build())
.build());
var page = new CxPage("page", CxPageArgs.builder()
.parent(agent.startFlow())
.displayName("MyPage")
.transitionRoutes(CxPageTransitionRouteArgs.builder()
.intent(intent.id())
.triggerFulfillment(CxPageTransitionRouteTriggerFulfillmentArgs.builder()
.messages(CxPageTransitionRouteTriggerFulfillmentMessageArgs.builder()
.text(CxPageTransitionRouteTriggerFulfillmentMessageTextArgs.builder()
.texts("Training phrase response")
.build())
.build())
.build())
.build())
.eventHandlers(CxPageEventHandlerArgs.builder()
.event("some-event")
.triggerFulfillment(CxPageEventHandlerTriggerFulfillmentArgs.builder()
.messages(CxPageEventHandlerTriggerFulfillmentMessageArgs.builder()
.text(CxPageEventHandlerTriggerFulfillmentMessageTextArgs.builder()
.texts("Handling some event")
.build())
.build())
.build())
.build())
.build());
var basicTestCase = new CxTestCase("basicTestCase", CxTestCaseArgs.builder()
.parent(agent.id())
.displayName("MyTestCase")
.tags("#tag1")
.notes("demonstrates a simple training phrase response")
.testConfig(CxTestCaseTestConfigArgs.builder()
.trackingParameters("some_param")
.page(page.id())
.build())
.testCaseConversationTurns(
CxTestCaseTestCaseConversationTurnArgs.builder()
.userInput(CxTestCaseTestCaseConversationTurnUserInputArgs.builder()
.input(CxTestCaseTestCaseConversationTurnUserInputInputArgs.builder()
.languageCode("en")
.text(CxTestCaseTestCaseConversationTurnUserInputInputTextArgs.builder()
.text("training phrase")
.build())
.build())
.injectedParameters(serializeJson(
jsonObject(
jsonProperty("some_param", "1")
)))
.isWebhookEnabled(true)
.enableSentimentAnalysis(true)
.build())
.virtualAgentOutput(CxTestCaseTestCaseConversationTurnVirtualAgentOutputArgs.builder()
.sessionParameters(serializeJson(
jsonObject(
jsonProperty("some_param", "1")
)))
.triggeredIntent(CxTestCaseTestCaseConversationTurnVirtualAgentOutputTriggeredIntentArgs.builder()
.name(intent.id())
.build())
.currentPage(CxTestCaseTestCaseConversationTurnVirtualAgentOutputCurrentPageArgs.builder()
.name(page.id())
.build())
.textResponses(CxTestCaseTestCaseConversationTurnVirtualAgentOutputTextResponseArgs.builder()
.texts("Training phrase response")
.build())
.build())
.build(),
CxTestCaseTestCaseConversationTurnArgs.builder()
.userInput(CxTestCaseTestCaseConversationTurnUserInputArgs.builder()
.input(CxTestCaseTestCaseConversationTurnUserInputInputArgs.builder()
.event(CxTestCaseTestCaseConversationTurnUserInputInputEventArgs.builder()
.event("some-event")
.build())
.build())
.build())
.virtualAgentOutput(CxTestCaseTestCaseConversationTurnVirtualAgentOutputArgs.builder()
.currentPage(CxTestCaseTestCaseConversationTurnVirtualAgentOutputCurrentPageArgs.builder()
.name(page.id())
.build())
.textResponses(CxTestCaseTestCaseConversationTurnVirtualAgentOutputTextResponseArgs.builder()
.texts("Handling some event")
.build())
.build())
.build(),
CxTestCaseTestCaseConversationTurnArgs.builder()
.userInput(CxTestCaseTestCaseConversationTurnUserInputArgs.builder()
.input(CxTestCaseTestCaseConversationTurnUserInputInputArgs.builder()
.dtmf(CxTestCaseTestCaseConversationTurnUserInputInputDtmfArgs.builder()
.digits("12")
.finishDigit("3")
.build())
.build())
.build())
.virtualAgentOutput(CxTestCaseTestCaseConversationTurnVirtualAgentOutputArgs.builder()
.textResponses(CxTestCaseTestCaseConversationTurnVirtualAgentOutputTextResponseArgs.builder()
.texts("I didn't get that. Can you say it again?")
.build())
.build())
.build())
.build());
}
}

Import

TestCase can be imported using any of these accepted formats:

$ pulumi import gcp:diagflow/cxTestCase:CxTestCase default {{parent}}/testCases/{{name}}

Properties

Link copied to clipboard
val creationTime: Output<String>

When the test was created. A timestamp in RFC3339 text format.

Link copied to clipboard
val displayName: Output<String>

The human-readable name of the test case, unique within the agent. Limit of 200 characters.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard

The latest test result. Structure is documented below.

Link copied to clipboard
val name: Output<String>

The unique identifier of the page. Format: projects//locations//agents//flows//pages/.

Link copied to clipboard
val notes: Output<String>?

Additional freeform notes about the test case. Limit of 400 characters.

Link copied to clipboard
val parent: Output<String>?

The agent to create the test case for. Format: projects//locations//agents/.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val tags: Output<List<String>>?

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

Link copied to clipboard

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.

Link copied to clipboard

Config for the test case. Structure is documented below.

Link copied to clipboard
val urn: Output<String>