MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / main

Function main

dialogflow-cx/create-agent.js:19–50  ·  view source on GitHub ↗
(projectId, displayName)

Source from the content-addressed store, hash-verified

17process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
18
19async function main(projectId, displayName) {
20 // [START dialogflow_set_agent_sample]
21
22 const parent = 'projects/' + projectId + '/locations/global';
23
24 const api_endpoint = 'global-dialogflow.googleapis.com';
25
26 const agent = {
27 displayName: displayName,
28 defaultLanguageCode: 'en',
29 timeZone: 'America/Los_Angeles',
30 };
31
32 const {AgentsClient} = require('@google-cloud/dialogflow-cx');
33
34 const client = new AgentsClient({apiEndpoint: api_endpoint});
35
36 async function setAgentSample() {
37 const request = {
38 agent,
39 parent,
40 };
41
42 const [response] = await client.createAgent(request);
43 console.log(`response: ${JSON.stringify(response, null, 2)}`);
44
45 // Delete created agent resource
46 client.deleteAgent({name: response.name});
47 }
48 await setAgentSample();
49 // [END dialogflow_set_agent_sample]
50}
51
52process.on('unhandledRejection', err => {
53 console.error(err.message);

Callers 1

create-agent.jsFile · 0.70

Calls 1

setAgentSampleFunction · 0.85

Tested by

no test coverage detected