3
votes

Since I upgraded my Dialogflow to use v2 API, I get the following error:

Dialogflow IntentHandler not found for intent: myIntent

For some reasons, my intent is no longer recognized altough the action name is identical - myIntent.

This is how I'm using my NodeJS (express V4) app to return a response:

dialogflowApp.intent('myIntent', (conv, {version}) => {
    conv.close('test');
});

What could have gone wrong?

6
In V2 API, the action name doesn't matter here. Your intent name must be identical to the string you reference in your code, you need to verify that your intent is also named 'myIntent'.Gongqin Shen
What are your imports here, can you include those?Sarah Dwyer

6 Answers

3
votes

Make sure that myIntent is spelled the same in Dialogflow and in your NodeJS webhook function, otherwise you'll get this error. This is how I write and access my functions in the webhook:

//Function execution
dialogflowApp.intent('myIntent', myIntentFunction); 


//Function definition
function myIntentFunction(conv, {version}){
    conv.close('test');
}
1
votes

V2 Actions SDK uses the Intent name instead of the Action Name. The Intent name can be found in your request, or directly from DialogFlow intent interface

Screenshot from Actions on Google Documentation

DialogFlow V1 to V2 Migration Documentation

1
votes

In V2 you have to use the intent name instead of the action name. First you define this at the beginning of the index file:

'use strict';
const {dialogflow} = require('actions-on-google');
const functions = require('firebase-functions');
const app = dialogflow({debug: true});

Then you have to add the code for each intent:

app.intent('intentName1', (conv, {parameterName}) => {
     conv.close('Answer text');
});

app.intent('intentName2', (conv, {parameterName}) => {
     conv.ask('Answer text');
});

Finally, at the end of the index file, it is necessary to set the DialogflowApp object to handle the HTTPS POST request. Like this:

exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app);

In your example:

dialogflowApp.intent('myIntent', (conv, {version}) => {
    conv.close('test');
});

You should check that you have defined 'dialogflowApp' at the begining of index file:

const dialogflowApp = dialogflow({debug: true});

Then you have two options:

  1. Replace 'myIntent' with the name of the intent

  2. Change your intent name to be 'myIntent'

IMPORTANT: You have to make sure that the intent name in dialogflow and that in the code are exactly the same, since it is case sentive.

'version' should be the name of a parameter received from that intent.

Also check that you have this at the end of the index file:

exports.dialogflowFirebaseFulfillment = functions.https.onRequest(dialogflowApp);

Hope this can help! :)

0
votes

Try to put your intent handler outside your express '/' post route:

dialogflowApp.intent('myIntent', (conv, {version}) => {
    conv.close('test');
});
express().post('/', function(req, res)) {
})
0
votes

According to this comment on Github, Actions-on-Google V2 does not match on the action, but instead matches on the intent.name. I have yet to find a smooth way of finding the name property of a Dialogfow intent, but I have been able to find it by looking at the Diagnostic info after testing it in the right column.

Note: What you named the intent at the top of the screen is the Display Name, not the name.

Update: Part of the intent.name can be found in the URL after opening the intent. The intent.name currently is given in the following format:

projects/<username>/agent/intents/<intent-uuid>

The intent-uuid can be found in the last part of the path:

https://console.dialogflow.com/api-client/#/agent/<agent-uuid>/editIntent/<intent-uuid>/

While this is also not ideal either, it can make things a little easier.

0
votes

Try also to remove space from the intent name defined in DialogFlow and in your javascript function call. This solve the problem in my case (running in a Azure function)

before :

app.intent('Open Car Gate', conv => {
    conv.close('OK, je vais ouvrir le portail en grand !');
});

after :

app.intent('OpenCarGate', conv => {
    conv.close('OK, je vais ouvrir le portail en grand !');
});