botpress / botpress-api.ai

☠ 301 – Moved here (user Botpress NLU) --->
https://github.com/botpress/modules
GNU General Public License v3.0
14 stars 10 forks source link

TypeError: Cannot read property 'id' of undefined #9

Open fedealconada opened 6 years ago

fedealconada commented 6 years ago

I noticed that when using api.ai module AND webhooks module at the same time, this error appears:

TypeError: Cannot read property 'id' of undefined at incomingMiddleware (/Users/me/project/node_modules/botpress-api.ai/bin/webpack:/src/index.js:42:21) at exec (/Users/me/project/node_modules/mware/index.js:50:23) at next (/Users/me/project/node_modules/mware/index.js:60:9) at processIncoming (/Users/fedealconada/Documents/Desarrollo/Sirius ...

fedealconada commented 6 years ago

This is because api.ai incoming middleware is catching the webhook request but no event.user is defined. My proposed solution is to check if the user exists and if not, just skip it and continue (next()).

https://github.com/botpress/botpress-api.ai/pull/10

@slvnperron @DanyFS