0

Has anyone experienced this issue?

I am sure the dialogflow connection works because listing the intents works which is (intentsClient.listIntents(request)) and it gives me back all the intents from my dialogflow es agent. So it looks like the credentials should be fine.

Any help would be highly appreciated, Thanks

const dialogflow = require('@google-cloud/dialogflow').v2;
const uuid = require('uuid');
const sessionId = uuid.v4();
const sessionClient = new dialogflow.SessionsClient({ keyFilename: '..........' });

const sessionPath = sessionClient.projectAgentSessionPath(
    projectId,
    sessionId
);


 const query = 'What are the pets rules';


async function detectIntentForQuestion() {
    // The text query request.
    const request = {
        session: sessionPath,
        queryInput: {
            text: {
                text: query,
                languageCode: 'en-US',
            },
        },
        queryParams: {
            sentimentAnalysisRequestConfig: {
                analyzeQueryTextSentiment: true,
            },
        },
    };

    // 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.');
    }
    if (result.sentimentAnalysisResult) {
        console.log('Detected sentiment');
        console.log(
            `  Score: ${result.sentimentAnalysisResult.queryTextSentiment.score}`
        );
        console.log(
            `  Magnitude: ${result.sentimentAnalysisResult.queryTextSentiment.magnitude}`
        );
    } else {
        console.log('No sentiment Analysis Found');
    }
};

1 Answers1

0

you are setting languageCode: 'en-US' for language. Does your agent support this language? If it is set using a different language (ie. Spanish), then it is expected to give you back only the fallback intent response.

other thing that you can do is checking at https://dialogflow.cloud.google.com/#/agent/<your agent name>/history and in your last interactions, you click on the 3 dots in the agent response and go to Raw interaction log. There you can see the information the agent got from your code, how it was interpreted by the agent and how it answered you back.

Luciano Martins
  • 421
  • 1
  • 9