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

Function main

dialogflow/set-agent.js:18–44  ·  view source on GitHub ↗
(parentId, displayName)

Source from the content-addressed store, hash-verified

16
17// parentID is the projectID and displayName is customized by user
18async function main(parentId, displayName) {
19 // [START dialogflow_set_agent_sample]
20 const {AgentsClient} = require('@google-cloud/dialogflow');
21
22 // make sure to pass projectID as the input parameter
23 const parent = 'projects/' + parentId + '/locations/global';
24
25 const agent = {
26 parent: parent,
27 displayName: displayName,
28 defaultLanguageCode: 'en',
29 timeZone: 'America/Los_Angeles',
30 };
31
32 const client = new AgentsClient();
33
34 async function setAgent() {
35 const request = {
36 agent,
37 };
38
39 const [response] = await client.setAgent(request);
40 console.log(`response: ${JSON.stringify(response, null, 2)}`);
41 }
42 await setAgent();
43 // [END dialogflow_set_agent_sample]
44}
45
46process.on('unhandledRejection', err => {
47 console.error(err.message);

Callers 1

set-agent.jsFile · 0.70

Calls 1

setAgentFunction · 0.85

Tested by

no test coverage detected