importcom.google.cloud.dialogflow.v2.Agent;importcom.google.cloud.dialogflow.v2.Agent.Builder;importcom.google.cloud.dialogflow.v2.AgentsClient;importcom.google.cloud.dialogflow.v2.AgentsSettings;importjava.io.IOException;publicclassSetAgent{publicstaticvoidmain(String[]args)throwsIOException{StringprojectId="my-project-id";// The display name will set the name of your agentStringdisplayName="my-display-name";setAgent(projectId,displayName);}publicstaticAgentsetAgent(Stringparent,StringdisplayName)throwsIOException{AgentsSettingsagentsSettings=AgentsSettings.newBuilder().build();try(AgentsClientclient=AgentsClient.create(agentsSettings)){// Set the details of the Agent to createBuilderbuild=Agent.newBuilder();build.setDefaultLanguageCode("en");build.setDisplayName(displayName);Agentagent=build.build();// Make API request to create agentAgentresponse=client.setAgent(agent);System.out.println(response);returnresponse;}}}
const{AgentsClient}=require('@google-cloud/dialogflow');// make sure to pass projectID as the input parameterconstparent='projects/'+parentId+'/locations/global';constagent={parent:parent,displayName:displayName,defaultLanguageCode:'en',timeZone:'America/Los_Angeles',};constclient=newAgentsClient();asyncfunctionsetAgent(){constrequest={agent,};const[response]=awaitclient.setAgent(request);console.log(`response: ${JSON.stringify(response,null,2)}`);}awaitsetAgent();