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

Function detectIntent

dialogflow/detect.js:42–74  ·  view source on GitHub ↗
(
    projectId,
    sessionId,
    query,
    contexts,
    languageCode
  )

Source from the content-addressed store, hash-verified

40 const sessionClient = new dialogflow.SessionsClient();
41
42 async function detectIntent(
43 projectId,
44 sessionId,
45 query,
46 contexts,
47 languageCode
48 ) {
49 // The path to identify the agent that owns the created intent.
50 const sessionPath = sessionClient.projectAgentSessionPath(
51 projectId,
52 sessionId
53 );
54
55 // The text query request.
56 const request = {
57 session: sessionPath,
58 queryInput: {
59 text: {
60 text: query,
61 languageCode: languageCode,
62 },
63 },
64 };
65
66 if (contexts && contexts.length > 0) {
67 request.queryParams = {
68 contexts: contexts,
69 };
70 }
71
72 const responses = await sessionClient.detectIntent(request);
73 return responses[0];
74 }
75
76 async function executeQueries(projectId, sessionId, queries, languageCode) {
77 // Keeping the context across queries let's us simulate an ongoing conversation with the bot

Callers 1

executeQueriesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected