0

I do detect intent request from NodeJS. I have done the same using Postman and it works to change the currentPage (I am making long-lasting session). But from NodeJS, the Dialogflow gives response but after I test it on Test Agent, the current page doesn't change.

Here is the code on the NodeJS. The session ID is not randomized. It's already exist ID.

'use strict';
const dialogflow = require('@google-cloud/dialogflow');

async function checkDialogFlow(current_page, session_id, project_id = '#####') {
  const agentId = '########';

  const sessionClient = new dialogflow.SessionsClient();
  const sessionPath = sessionClient.projectLocationAgentSessionPath(project_id, 'global', agentId, session_id);
  // The text query request.
  // This is the format the request needs to be in for DialogFlow to understand the query
  const request = {
    session: sessionPath,
    queryInput: {
      text: {
        text: 'djkabdjkbasjkbdkj',
        languageCode: 'en',
      },
    },
    queryParams: {
      timeZone: 'America/Los_Angeles',
      currentPage: current_page,
    },
  };

  // Send request and log result
  const responses = await sessionClient.detectIntent(request);
  console.log('Detected intent');
  const result = responses[0].queryResult;
  console.log(`  Query: ${result.queryText}`);
  console.log(`  Response: ${result.fulfillmentText}`);
  if (result.intent) {
    console.log(`  Intent: ${result.intent.displayName}`);
  } else {
    console.log(`  No intent matched.`);
  }
  
  return result
}

module.exports = { checkDialogFlow };

and here is the response from the DialogFlow

result { fulfillmentMessages:
   [ { platform: 'PLATFORM_UNSPECIFIED',
       text: [Object],
       message: 'text' } ],
  outputContexts:
   [ { name:
        'projects/bilip-user-v2-uwoy/locations/global/agent/sessions/7b39a3cc-fee8-41e1-96ee-ca0ff90cb981/contexts/__system_counters__',
       lifespanCount: 1,
       parameters: [Object] } ],
  queryText: 'djkabdjkbasjkbdkj',
  speechRecognitionConfidence: 0,
  action: 'input.unknown',
  parameters: { fields: {} },
  allRequiredParamsPresent: true,
  fulfillmentText: 'I missed what you said. What was that?',
  webhookSource: '',
  webhookPayload: null,
  intent:
   { inputContextNames: [],
     events: [],
     trainingPhrases: [],
     outputContexts: [],
     parameters: [],
     messages: [],
     defaultResponsePlatforms: [],
     followupIntentInfo: [],
     name:
      'projects/bilip-user-v2-uwoy/locations/global/agent/intents/a54872dc-50b7-48eb-9152-332506829028',
     displayName: 'Default Fallback Intent',
     priority: 0,
     isFallback: true,
     webhookState: 'WEBHOOK_STATE_UNSPECIFIED',
     action: '',
     resetContexts: false,
     rootFollowupIntentName: '',
     parentFollowupIntentName: '',
     mlDisabled: false,
     liveAgentHandoff: false,
     endInteraction: false },
  intentDetectionConfidence: 1,
  diagnosticInfo: { fields: { webhook_latency_ms: [Object] } },
  languageCode: 'en',
  sentimentAnalysisResult:
   { queryTextSentiment:
      { score: 0.30000001192092896, magnitude: 0.30000001192092896 } },
  cancelsSlotFilling: false }
  Query: djkabdjkbasjkbdkj
  Response: I missed what you said. What was that?
  Intent: Default Fallback Intent

I expect the currentPage of the session to change. I have tried using Postman and it works.

5
  • Are you facing any error messages? How is it working when you test using a test agent? Commented Oct 17, 2023 at 13:09
  • No. No error messages. The response from the DialogFlow above, that's all. From test agent, I can change the current page if the detect intent request is from Postman. I suspect this const sessionPath = sessionClient.projectLocationAgentSessionPath(project_id, 'global', agentId, session_id); Is using sessionClient.projectLocationAgentSessionPath correct? Commented Oct 18, 2023 at 1:26
  • 1
    Hi @Viz,since this is a public forum please remove project_id,agent_id..etc.Your code seems to be correct. To investigate this case further,you can create a gcp support case, without looking into your project it is difficult to address your issue. Before that, can you try again with random session_id and please make sure that queryParams is correct(if possible please try without passing query params).Can you take a look at this link also. Commented Oct 18, 2023 at 6:58
  • @kiranmathew Thankyou for the advice. I am pretty sure the query params is correct since I have tried from the Postman and it works. It is not possible to post without query params since the currentPage is inside query params. And for the random session ID, I will try it. Commented Oct 18, 2023 at 8:53
  • @kiranmathew the random session ID, doesn't work. Commented Oct 19, 2023 at 6:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.