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

Problem accessing dialogflow intent with Botkit v4.0.1 #26

Open realnsleo opened 5 years ago

realnsleo commented 5 years ago

Hello, Awesome plugin. Worked great with Botkit 0.7.x. However, I am having trouble integrating with Botkit 4.x.x. I can't seem to access message.intent when using the controller.hears function. See below:

controller.on('message', async(bot, message) => {
    console.log(message) // message contains message.intent
});

controller.hears('hello', 'message', async(bot, message) => {
    console.log(message) // message does not contain message.intent
});

I am not sure what I could be messing. Hopefully you can help me out?

node: 8.11.2 botkit-middleware-dialogflow: 2.1.0 botkit: 4.0.1

realnsleo commented 5 years ago

I realized that if I change this:

controller.middleware.receive.use(dialogflowMiddleware.receive)

to:

controller.middleware.ingest.use(dialogflowMiddleware.receive)

Then my message.intent property is available. Are there any drawbacks of using ingest as opposed to receive?

adantoscano commented 5 years ago

Now there some issues with middleware pipeline in botkit, but using ingest is a good workaround. The biggest drawbacks is tha you are going to send ALL messages that you receive, even convos and for now I don't know how to handle it