Alguns produtos e recursos estão sendo renomeados. Os recursos de playbook generativo e de fluxo também estão sendo migrados para um único console consolidado. Confira os detalhes.
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Ao atualizar os dados do agente com a API, você pode optar por substituir o tipo de dados inteiro ou substituir apenas campos específicos do tipo de dados.
Em geral, é melhor substituir campos específicos, para evitar substituir acidentalmente todos os seus dados.
Para substituir campos específicos, forneça um FieldMask à sua solicitação de atualização.
Os exemplos a seguir mostram como fornecer um FieldMask
para atualizar o nome de exibição em um tipo Intent.
Selecione um protocolo e uma versão para a referência de intent:
importcom.google.cloud.dialogflow.cx.v3.Intent;importcom.google.cloud.dialogflow.cx.v3.Intent.Builder;importcom.google.cloud.dialogflow.cx.v3.IntentsClient;importcom.google.cloud.dialogflow.cx.v3.UpdateIntentRequest;importcom.google.protobuf.FieldMask;importjava.io.IOException;publicclassUpdateIntent{publicstaticvoidmain(String[]args)throwsIOException{// TODO(developer): Replace these variables before running the sample.StringprojectId="my-project-id";StringagentId="my-agent-id";StringintentId="my-intent-id";Stringlocation="my-location";StringdisplayName="my-display-name";updateIntent(projectId,agentId,intentId,location,displayName);}// DialogFlow API Update Intent sample.publicstaticvoidupdateIntent(StringprojectId,StringagentId,StringintentId,Stringlocation,StringdisplayName)throwsIOException{// Note: close() needs to be called on the IntentsClient object to clean up resources// such as threads. In the example below, try-with-resources is used,// which automatically calls close().try(IntentsClientclient=IntentsClient.create()){StringintentPath="projects/"+projectId+"/locations/"+location+"/agents/"+agentId+"/intents/"+intentId;BuilderintentBuilder=client.getIntent(intentPath).toBuilder();intentBuilder.setDisplayName(displayName);FieldMaskfieldMask=FieldMask.newBuilder().addPaths("display_name").build();Intentintent=intentBuilder.build();UpdateIntentRequestrequest=UpdateIntentRequest.newBuilder().setIntent(intent).setLanguageCode("en").setUpdateMask(fieldMask).build();// Make API request to update intent using fieldmaskIntentresponse=client.updateIntent(request);System.out.println(response);}}}
const{IntentsClient}=require('@google-cloud/dialogflow-cx');constintentClient=newIntentsClient();//TODO(developer): Uncomment these variables before running the sample.// const projectId = 'your-project-id';// const agentId = 'your-agent-id';// const intentId = 'your-intent-id';// const location = 'your-location';// const displayName = 'your-display-name';asyncfunctionupdateIntent(){constagentPath=intentClient.projectPath(projectId);constintentPath=`${agentPath}/locations/${location}/agents/${agentId}/intents/${intentId}`;//Gets the intent from intentPathconstintent=awaitintentClient.getIntent({name:intentPath});intent[0].displayName=displayName;//Specifies what is being updatedconstupdateMask={paths:['display_name'],};constupdateIntentRequest={intent:intent[0],updateMask,languageCode:'en',};//Send the request for update the intent.constresult=awaitintentClient.updateIntent(updateIntentRequest);console.log(result);}updateIntent();
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-18 UTC."],[[["\u003cp\u003eWhen using the API to update agent data, you have the option to either overwrite all data or modify only specific fields.\u003c/p\u003e\n"],["\u003cp\u003eIt is generally recommended to update specific fields to prevent the accidental overwriting of all your data.\u003c/p\u003e\n"],["\u003cp\u003eTo update specific fields, a \u003ccode\u003eFieldMask\u003c/code\u003e must be included in the update request to indicate the fields to be modified.\u003c/p\u003e\n"],["\u003cp\u003eThe examples provided illustrate how to use a \u003ccode\u003eFieldMask\u003c/code\u003e to specifically update the display name for an \u003ccode\u003eIntent\u003c/code\u003e type across REST, Java, Node.js and Python.\u003c/p\u003e\n"]]],[],null,["# Update data with a FieldMask\n\nWhen updating agent data with the API,\nyou can choose to overwrite the entire data type\nor to overwrite only specific fields of the data type.\nIt is usually best to overwrite specific fields,\nso you avoid accidentally overwriting all of your data.\nTo overwrite specific fields,\nsupply a\n[`FieldMask`](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask)\nto your update request.\n\nThe following examples show how to supply a `FieldMask`\nto update the display name for an `Intent` type.\n\n\nGo to the Intent API reference \n**Select a protocol and version for the Intent reference:**\n\nClose\n\n\u003cbr /\u003e\n\n### REST\n\n\nBefore using any of the request data,\nmake the following replacements:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: your Google Cloud project ID\n- \u003cvar translate=\"no\"\u003eAGENT_ID\u003c/var\u003e: your agent ID\n- \u003cvar translate=\"no\"\u003eREGION_ID\u003c/var\u003e: your [region ID](/dialogflow/cx/docs/concept/region)\n- \u003cvar translate=\"no\"\u003eINTENT_ID\u003c/var\u003e: your intent ID\n- \u003cvar translate=\"no\"\u003eDISPLAY_NAME\u003c/var\u003e: your desired display name\n\n\nHTTP method and URL:\n\n```\nPATCH https://REGION_ID-dialogflow.googleapis.com/v3/projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID/intents/INTENT_ID?updateMask=displayName\n```\n\n\nRequest JSON body:\n\n```\n{\n \"displayName\": \"DISPLAY_NAME\"\n}\n```\n\nTo send your request, expand one of these options:\n\n#### curl (Linux, macOS, or Cloud Shell)\n\n| **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](/sdk/gcloud/reference/init) or [`gcloud auth login`](/sdk/gcloud/reference/auth/login) , or by using [Cloud Shell](/shell/docs), which automatically logs you into the `gcloud` CLI . You can check the currently active account by running [`gcloud auth list`](/sdk/gcloud/reference/auth/list).\n\n\nSave the request body in a file named `request.json`,\nand execute the following command:\n\n```\ncurl -X PATCH \\\n -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"x-goog-user-project: PROJECT_ID\" \\\n -H \"Content-Type: application/json; charset=utf-8\" \\\n -d @request.json \\\n \"https://REGION_ID-dialogflow.googleapis.com/v3/projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID/intents/INTENT_ID?updateMask=displayName\"\n```\n\n#### PowerShell (Windows)\n\n| **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](/sdk/gcloud/reference/init) or [`gcloud auth login`](/sdk/gcloud/reference/auth/login) . You can check the currently active account by running [`gcloud auth list`](/sdk/gcloud/reference/auth/list).\n\n\nSave the request body in a file named `request.json`,\nand execute the following command:\n\n```\n$cred = gcloud auth print-access-token\n$headers = @{ \"Authorization\" = \"Bearer $cred\"; \"x-goog-user-project\" = \"PROJECT_ID\" }\n\nInvoke-WebRequest `\n -Method PATCH `\n -Headers $headers `\n -ContentType: \"application/json; charset=utf-8\" `\n -InFile request.json `\n -Uri \"https://REGION_ID-dialogflow.googleapis.com/v3/projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID/intents/INTENT_ID?updateMask=displayName\" | Select-Object -Expand Content\n```\n\nYou should receive a JSON response similar to the following:\n\n```\n{\n \"name\": \"projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID/intents/INTENT_ID\",\n \"displayName\": \"DISPLAY_NAME\",\n ...\n}\n```\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.Intent.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.Intent.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.IntentsClient.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.UpdateIntentRequest.html;\n import com.google.protobuf.https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.FieldMask.html;\n import java.io.IOException;\n\n public class UpdateIntent {\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 intentId = \"my-intent-id\";\n String location = \"my-location\";\n String displayName = \"my-display-name\";\n updateIntent(projectId, agentId, intentId, location, displayName);\n }\n\n // DialogFlow API Update Intent sample.\n public static void updateIntent(\n String projectId, String agentId, String intentId, String location, String displayName)\n throws IOException {\n\n // Note: close() needs to be called on the IntentsClient 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.IntentsClient.html client = https://cloud.google.com/java/docs/reference/google-cloud-dialogflow-cx/latest/com.google.cloud.dialogflow.cx.v3.IntentsClient.html.create()) {\n String intentPath =\n \"projects/\"\n + projectId\n + \"/locations/\"\n + location\n + \"/agents/\"\n + agentId\n + \"/intents/\"\n + intentId;\n\n Builder intentBuilder = client.getIntent(intentPath).toBuilder();\n\n intentBuilder.setDisplayName(displayName);\n https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.FieldMask.html fieldMask = https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.FieldMask.html.newBuilder().https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.FieldMask.Builder.html#com_google_protobuf_FieldMask_Builder_addPaths_java_lang_String_(\"display_name\").build();\n\n https://cloud.google.com/java/docs/reference/google-cloud-dialogflow-cx/latest/com.google.cloud.dialogflow.cx.v3.Intent.html intent = intentBuilder.build();\n https://cloud.google.com/java/docs/reference/google-cloud-dialogflow-cx/latest/com.google.cloud.dialogflow.cx.v3.UpdateIntentRequest.html request =\n https://cloud.google.com/java/docs/reference/google-cloud-dialogflow-cx/latest/com.google.cloud.dialogflow.cx.v3.UpdateIntentRequest.html.newBuilder()\n .setIntent(intent)\n .setLanguageCode(\"en\")\n .setUpdateMask(fieldMask)\n .build();\n\n // Make API request to update intent using fieldmask\n https://cloud.google.com/java/docs/reference/google-cloud-dialogflow-cx/latest/com.google.cloud.dialogflow.cx.v3.Intent.html response = client.updateIntent(request);\n System.out.println(response);\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\n const {IntentsClient} = require('https://cloud.google.com/nodejs/docs/reference/dialogflow-cx/latest/overview.html');\n\n const intentClient = new https://cloud.google.com/nodejs/docs/reference/dialogflow-cx/latest/overview.html();\n\n //TODO(developer): Uncomment these variables before running the sample.\n // const projectId = 'your-project-id';\n // const agentId = 'your-agent-id';\n // const intentId = 'your-intent-id';\n // const location = 'your-location';\n // const displayName = 'your-display-name';\n\n async function updateIntent() {\n const agentPath = intentClient.projectPath(projectId);\n const intentPath = `${agentPath}/locations/${location}/agents/${agentId}/intents/${intentId}`;\n\n //Gets the intent from intentPath\n const intent = await intentClient.getIntent({name: intentPath});\n intent[0].displayName = displayName;\n\n //Specifies what is being updated\n const updateMask = {\n paths: ['display_name'],\n };\n\n const updateIntentRequest = {\n intent: intent[0],\n updateMask,\n languageCode: 'en',\n };\n\n //Send the request for update the intent.\n const result = await intentClient.updateIntent(updateIntentRequest);\n console.log(result);\n }\n\n updateIntent();\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 from google.cloud.dialogflowcx_v3.services.intents import IntentsClient\n from google.protobuf import field_mask_pb2\n\n\n def update_intent(project_id, agent_id, intent_id, location, displayName):\n intents_client = IntentsClient()\n\n intent_name = intents_client.intent_path(project_id, location, agent_id, intent_id)\n\n intent = intents_client.get_intent(request={\"name\": intent_name})\n\n intent.display_name = displayName\n update_mask = field_mask_pb2.FieldMask(paths=[\"display_name\"])\n response = intents_client.update_intent(intent=intent, update_mask=update_mask)\n return response\n\n\u003cbr /\u003e"]]