0
votes

i am developing chat bot application with google dialog flow. i am using node js client https://github.com/dialogflow/dialogflow-nodejs-client-v2 to access the data of my chat bot. i have enabled small talk from the dialog flow console and it works fine when i use it from the dialog flow web demo or the console it self

enter image description here

for the same chat application i have implemented a api by using dialogflow node js client.

 if (req.body.text) {
        query = req.body.text;
    }
    // Get the city and date from the request
    var request = {
        session: sessionPath,
        queryInput: {
            text: {
                text: query,
                languageCode: languageCode,
            },
        },
    };
    // Send request and log result
    sessionClient
        .detectIntent(request)
        .then(responses => {
            console.log('Detected intent');
            const result = responses[0].queryResult;
            console.log(`  Query: ${result.queryText}`);
            console.log(`  Response: ${result.fulfillmentText}`);
            if (result.intent) {
                res.json({ "text": result.fulfillmentText });
            } else {
                res.json({ 'fulfillmentText': "No intent matched" });
                console.log(`  No intent matched.`);
            }
        })
        .catch(err => {
            console.error('ERROR:', err);
        }); 

there i dont get the result i want. instead it goes to a different intent

enter image description here

what i have done incorrectly here..

1
How do you set a sessionPath variable? - Aza T
@AzaTulepbergenov sessionClient.sessionPath(projectId, sessionId); sessionId is a random no for each individual user. - pavithra rox
What is the output of console.log statements in your code? - Aza T
@AzaTulepbergenov i tried that now. but it goes to "No intent matched" part now. if a send something about a intent it gives me the correct answer. - pavithra rox
Can you please elaborate what do you mean by "sending something about a intent"? - Aza T

1 Answers

1
votes

Queries defined in Small Talk section of your Dialogflow agent will not have an associated intent. If there was a matching intent, then you shouldn't have really added that query into Small Talk. Therefore, since there is not matching intent, the Dialogflow Node library will return an unmatched intent.