dialogflow / dialogflow-nodejs-client

Node.js SDK for Dialogflow
Apache License 2.0
659 stars 287 forks source link

linebot.js do not return Promise #106

Open h-nasu opened 6 years ago

h-nasu commented 6 years ago

Gets below error every time doing Line webhook call because processMessage in linebot.js do not return Promise and doing error handling inside....

[ERROR] Error while message processing TypeError: Cannot read property 'catch' of undefined

      apiaiRequest.on('response', (response) => {
          this.processAiResponse(chatId, response, message.replyToken)
              .then(() => this.log('Message sent'))
              .catch((err) => this.logError(err))
        });

Fix Just check if return value is valid. app.js

          var result = bot.processMessage(item, res);
          if (result) {
            result.catch(err => console.error(err));
          }

or just delete '.catch(err => console.error(err));'