jschnurr / botkit-middleware-dialogflow

Botkit middleware for Dialogflow (formerly api.ai). Supports Dialogflow API v1 and V2.
MIT License
29 stars 18 forks source link

Doesn't work action() #21

Open Ilchuk-Mihail opened 5 years ago

Ilchuk-Mihail commented 5 years ago

DialogflowMiddleware.hears - works, but any trigger in action doesn't received.

jschnurr commented 5 years ago

DialogflowMiddleware.hears - works, but any trigger in action doesn't received.

Can you provide an example please?

jsalwen commented 5 years ago

I am getting the same issue.

facebook messenger: botkit v4.5

my-bot/features/dialogflow_action.js

const dialogflow = require('botkit-middleware-dialogflow')({
  keyFilename: './creds.json',  // service account private key file from Google Cloud Console
  structProtoToJson: true,
});
// action of the intent is: weather
module.exports = function(controller) {
  controller.hears('weather', 'direct_message,facebook_postback', dialogflow.action, async (bot, message) => {
    await bot.reply(message, 'action');    
  });
};

error:

(node:2984) UnhandledPromiseRejectionWarning: TypeError: data is not iterable
    at Object.exports.makeArrayOfRegex (c:\my-bot\node_modules\botkit-middleware-dialogflow\src\util.js:20:22)
    at Botkit.middleware.action (c:\my-bot\node_modules\botkit-middleware-dialogflow\src\botkit-middleware-dialogflow.js:64:32)
    at Botkit.<anonymous> (c:\my-bot\node_modules\botkit\lib\core.js:549:75)
    at Generator.next (<anonymous>)
    at fulfilled (c:\my-bot\node_modules\botkit\lib\core.js:4:58)
(node:2984) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)