Some products and features are in the process of being renamed. Generative playbook and flow features are also being migrated to a single consolidated console. See the details.
Stay organized with collections
Save and categorize content based on your preferences.
When listing data with the API,
some list method requests provide a filter field.
You can use these filters to only return results you are interested in.
This
filtering feature
is common across many Google Cloud APIs.
The following examples show how to filter the response
when listing test case results.
importcom.google.cloud.dialogflow.cx.v3.ListTestCaseResultsRequest;importcom.google.cloud.dialogflow.cx.v3.ListTestCaseResultsRequest.Builder;importcom.google.cloud.dialogflow.cx.v3.TestCaseResult;importcom.google.cloud.dialogflow.cx.v3.TestCasesClient;importcom.google.cloud.dialogflow.cx.v3.TestCasesSettings;importjava.io.IOException;publicclassListTestCaseResults{publicstaticvoidmain(String[]args)throwsIOException{// TODO(developer): Replace these variables before running the sample.StringprojectId="my-project-id";StringagentId="my-agent-id";StringtestId="my-test-id";Stringlocation="my-location";listTestCaseResults(projectId,agentId,testId,location);}publicstaticvoidlistTestCaseResults(StringprojectId,StringagentId,StringtestId,Stringlocation)throwsIOException{Stringparent="projects/"+projectId+"/locations/"+location+"/agents/"+agentId+"/testCases/"+testId;Builderreq=ListTestCaseResultsRequest.newBuilder();req.setParent(parent);req.setFilter("environment=draft");TestCasesSettingstestCasesSettings=TestCasesSettings.newBuilder().setEndpoint(location+"-dialogflow.googleapis.com:443").build();// Note: close() needs to be called on the TestCasesClient object to clean up resources// such as threads. In the example below, try-with-resources is used,// which automatically calls close().try(TestCasesClientclient=TestCasesClient.create(testCasesSettings)){for(TestCaseResultelement:client.listTestCaseResults(req.build()).iterateAll()){System.out.println(element);}}}}
fromgoogle.cloud.dialogflowcx_v3.services.test_cases.clientimportTestCasesClientfromgoogle.cloud.dialogflowcx_v3.types.test_caseimportListTestCaseResultsRequestdeflist_test_case(project_id,agent_id,test_id,location):req=ListTestCaseResultsRequest()req.parent=f"projects/{project_id}/locations/{location}/agents/{agent_id}/testCases/{test_id}"req.filter="environment=draft"client=TestCasesClient(client_options={"api_endpoint":f"{location}-dialogflow.googleapis.com"})# Makes a call to list all test case results that match filterresult=client.list_test_case_results(request=req)print(result)returnresult
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-26 UTC."],[[["\u003cp\u003eMany Google Cloud APIs, including Dialogflow, allow you to filter list method requests using a \u003ccode\u003efilter\u003c/code\u003e field to narrow down the results you get.\u003c/p\u003e\n"],["\u003cp\u003eThe provided examples demonstrate how to filter test case results in Dialogflow using Java, Node.js, and Python.\u003c/p\u003e\n"],["\u003cp\u003eWhen listing test case results, you can set a filter such as \u003ccode\u003eenvironment=draft\u003c/code\u003e to retrieve specific data.\u003c/p\u003e\n"],["\u003cp\u003eYou can make use of Application Default Credentials to properly authenticate with Dialogflow APIs.\u003c/p\u003e\n"]]],[],null,["# List data with a filter\n\nWhen listing data with the API,\nsome list method requests provide a `filter` field.\nYou can use these filters to only return results you are interested in.\nThis\n[filtering feature](https://google.aip.dev/160)\nis common across many Google Cloud APIs.\n\nThe following examples show how to filter the response\nwhen listing test case results. \n\n### Java\n\n\nTo authenticate to Dialogflow, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n\n import com.google.cloud.dialogflow.cx.v3.https://cloud.google.com/java/docs/reference/google-cloud-dialogflow-cx/latest/com.google.cloud.dialogflow.cx.v3.ListTestCaseResultsRequest.html;\n import com.google.cloud.dialogflow.cx.v3.https://cloud.google.com/java/docs/reference/google-cloud-dialogflow-cx/latest/com.google.cloud.dialogflow.cx.v3.ListTestCaseResultsRequest.html.Builder;\n import com.google.cloud.dialogflow.cx.v3.https://cloud.google.com/java/docs/reference/google-cloud-dialogflow-cx/latest/com.google.cloud.dialogflow.cx.v3.TestCaseResult.html;\n import com.google.cloud.dialogflow.cx.v3.https://cloud.google.com/java/docs/reference/google-cloud-dialogflow-cx/latest/com.google.cloud.dialogflow.cx.v3.TestCasesClient.html;\n import com.google.cloud.dialogflow.cx.v3.https://cloud.google.com/java/docs/reference/google-cloud-dialogflow-cx/latest/com.google.cloud.dialogflow.cx.v3.TestCasesSettings.html;\n import java.io.IOException;\n\n public class ListTestCaseResults {\n\n public static void main(String[] args) throws IOException {\n // TODO(developer): Replace these variables before running the sample.\n String projectId = \"my-project-id\";\n String agentId = \"my-agent-id\";\n String testId = \"my-test-id\";\n String location = \"my-location\";\n listTestCaseResults(projectId, agentId, testId, location);\n }\n\n public static void listTestCaseResults(\n String projectId, String agentId, String testId, String location) throws IOException {\n String parent =\n \"projects/\"\n + projectId\n + \"/locations/\"\n + location\n + \"/agents/\"\n + agentId\n + \"/testCases/\"\n + testId;\n\n Builder req = https://cloud.google.com/java/docs/reference/google-cloud-dialogflow-cx/latest/com.google.cloud.dialogflow.cx.v3.ListTestCaseResultsRequest.html.newBuilder();\n\n req.setParent(parent);\n req.setFilter(\"environment=draft\");\n\n https://cloud.google.com/java/docs/reference/google-cloud-dialogflow-cx/latest/com.google.cloud.dialogflow.cx.v3.TestCasesSettings.html testCasesSettings =\n https://cloud.google.com/java/docs/reference/google-cloud-dialogflow-cx/latest/com.google.cloud.dialogflow.cx.v3.TestCasesSettings.html.newBuilder()\n .setEndpoint(location + \"-dialogflow.googleapis.com:443\")\n .build();\n\n // Note: close() needs to be called on the TestCasesClient object to clean up resources\n // such as threads. In the example below, try-with-resources is used,\n // which automatically calls close().\n try (https://cloud.google.com/java/docs/reference/google-cloud-dialogflow-cx/latest/com.google.cloud.dialogflow.cx.v3.TestCasesClient.html client = https://cloud.google.com/java/docs/reference/google-cloud-dialogflow-cx/latest/com.google.cloud.dialogflow.cx.v3.TestCasesClient.html.create(testCasesSettings)) {\n for (https://cloud.google.com/java/docs/reference/google-cloud-dialogflow-cx/latest/com.google.cloud.dialogflow.cx.v3.TestCaseResult.html element : client.listTestCaseResults(req.build()).iterateAll()) {\n System.out.println(element);\n }\n }\n }\n }\n\n### Node.js\n\n\nTo authenticate to Dialogflow, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n const parent = `projects/${projectId}/locations/${location}/agents/${agentId}/testCases/${testId}`;\n\n const {TestCasesClient} = require('https://cloud.google.com/nodejs/docs/reference/dialogflow-cx/latest/overview.html');\n\n const client = new https://cloud.google.com/nodejs/docs/reference/dialogflow-cx/latest/overview.html({\n apiEndpoint: 'global-dialogflow.googleapis.com',\n });\n const req = {\n parent,\n filter: 'environment=draft',\n };\n\n const res = await client.listTestCaseResults(req);\n\n console.log(res);\n\n### Python\n\n\nTo authenticate to Dialogflow, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n\n from google.cloud.dialogflowcx_v3.services.test_cases.client import TestCasesClient\n from google.cloud.dialogflowcx_v3.types.test_case import ListTestCaseResultsRequest\n\n\n def list_test_case(project_id, agent_id, test_id, location):\n req = ListTestCaseResultsRequest()\n req.parent = f\"projects/{project_id}/locations/{location}/agents/{agent_id}/testCases/{test_id}\"\n req.filter = \"environment=draft\"\n client = TestCasesClient(\n client_options={\"api_endpoint\": f\"{location}-dialogflow.googleapis.com\"}\n )\n # Makes a call to list all test case results that match filter\n result = client.list_test_case_results(request=req)\n print(result)\n return result\n\n\u003cbr /\u003e"]]