davidverweij
davidverweij

Reputation: 338

DialogFlow v2 Helper intents throw Reference Errors

I am trying to use the Helper intents provided in the Actions on Google Library (for DialogFlow v2), without any luck so far. The code compiles perfectly fine, yet upon execution (both on mobile and the simulator), the invocation throws a Reference error. I have searched the Internet globe, bu no luck so far. Any suggestions?

My Code (based on https://developers.google.com/actions/assistant/helpers#confirmation and nearly identical)

const { dialogflow } = require('actions-on-google');
const app = dialogflow();

...

app.intent('program', conv => {
   if (somestatement) { 
     const parameters =  somedata;
     conv.contexts.set(contextVariable, 1, parameters);
     return conv.ask(new Confirmation('prompt!')); 
   }
});

The thrown Error:

ReferenceError: Confirmation is not defined
    at app.intent.conv (/user_code/index.js:161:25)
    at Function.<anonymous> (/user_code/node_modules/actions-on-google/dist/service/dialogflow/dialogflow.js:146:23)
    at next (native)
    at /user_code/node_modules/actions-on-google/dist/service/dialogflow/dialogflow.js:22:71
    at __awaiter (/user_code/node_modules/actions-on-google/dist/service/dialogflow/dialogflow.js:18:12)
    at Function.handler (/user_code/node_modules/actions-on-google/dist/service/dialogflow/dialogflow.js:84:16)
    at Object.<anonymous> (/user_code/node_modules/actions-on-google/dist/assistant.js:55:32)
    at next (native)
    at /user_code/node_modules/actions-on-google/dist/assistant.js:22:71
    at __awaiter (/user_code/node_modules/actions-on-google/dist/assistant.js:18:12)

I am also using the latest actions-on-google dependency:

"dependencies": {
     "actions-on-google": "^2.1.2",
     "firebase-admin": "^5.12.1",
     "firebase-functions": "^1.0.3",
     "sprintf-js": "^1.1.1"
}

I have even changed the new Confirmation() helper to any of the other helpers, with no luck. On the DialogFlow side, I have an intent as required by the same documentation link above.

Any help is much obliged!

Upvotes: 1

Views: 233

Answers (1)

Prisoner
Prisoner

Reputation: 50731

You need to load the Confirmation object, so replacing your first line with something like this should work:

const { dialogflow, Confirmation } = require('actions-on-google');

Upvotes: 2

Related Questions