botframework-sdk: [Bug] Facebook integration error with Node -[TypeError: Cannot read property 'logger' of undefined]

Pre-flight checklist


System Information (Required)

  • SDK Platform: node
  • SDK Version: botbuilder@3.8.3
  • Development Environment: localhost

Issue Description

Describe the issue here. I’ve deployed my simple chatbot to heroku/beanstalk and encountered an error with facebook integration. As soon as the server received the first message, an (internal) error was found on the server log.

Note: The code worked well with the webchat on botframework.com and slack integration.

Example Code

The complete bot code that reproduces the issue.

var builder = require('botbuilder');
var restify = require('restify');
var apiairecognizer = require('api-ai-recognizer');
var request = require('request');

// Setup Restify Server

var server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () {
    console.log('%s listening to %s', server.name, server.url);
});

// Create chat bot
var connector = new builder.ChatConnector({
    appId: process.env.MICROSOFT_APP_ID,
    appPassword: process.env.MICROSOFT_APP_PASSWORD
});


server.post('/api/messages', connector.listen());
var bot = new builder.UniversalBot(connector, [
    function (session, args, next) {
        if (!session.userData.name) {
            // Ask user for their name
            builder.Prompts.text(session, "Hello... What's your name?");
        } else {
            // Skip to next step
            next();
        }
    },
    function (session, results) {
        // Update name if answered
        if (results.response) {
            session.userData.name = results.response;
        }

        // Greet the user
        session.send("Hi %s!", session.userData.name);
        session.beginDialog('/mainMenu');
    }
]);
var recognizer = new apiairecognizer(process.env.APIAI_CLIENT_ACCESS_TOKEN);
var intents = new builder.IntentDialog({
    recognizers: [recognizer]
});
bot.dialog('/mainMenu', [
    function (session) {
        builder.Prompts.choice(session, "How may I help?", ["1. XXXX","2. FAQ"]);
    },
    function (session, results) {
        switch (results.response)
        {
            case "2":
                session.beginDialog('/faq');
        };
        session.endDialog();
    }
]);
bot.dialog('/faq',intents, [
    function (session) {
        builder.Prompts.text(session, "What's your question?");
    }
]);
intents.matches('smalltalk.greetings.hello',function(session, args){
    var fulfillment = builder.EntityRecognizer.findEntity( args.entities, 'fulfillment');
    if (fulfillment){
        var speech = fulfillment.entity;
        session.send(speech);
    }else{
        session.send('Sorry...not sure how to respond to that');
    }
});
var cache = [];
processIntent (intents, 'welab.faq');

intents.onDefault(function(session){
    session.send("Sorry...can you please rephrase?");
});
function processIntent (intents, intentName){
    intents.matches(intentName,function(session, args){
        var fulfillment = builder.EntityRecognizer.findEntity(args.entities, 'fulfillment');
        if (fulfillment){
            var speech = fulfillment.entity;
            session.send(speech);

            showIntentMeassage(intentName, session);

        }else{
            session.send('Sorry...not sure how to respond to that');
        }
    });
}

function showIntentMeassage(intentName, session){
    session.send("inTentName: " + intentName);
}

Steps to Reproduce

  1. Configure the facebook integration on botframework.com
  2. Send a message, such as ‘hi’ from facebook messenger.
  3. The error occured

Expected Behavior

What you expected to happen. I expect facebook messenger would receive a response from the chatbot

Actual Results

What actually happened. Please give examples and support it with screenshots, copied output or error messages.

The following error occured

2017-05-29T02:39:49.801852+00:00 app[web.1]: /app/node_modules/promise/lib/done.js:10
2017-05-29T02:39:49.801865+00:00 app[web.1]:       throw err;
2017-05-29T02:39:49.801867+00:00 app[web.1]:       ^
2017-05-29T02:39:49.801868+00:00 app[web.1]: 
2017-05-29T02:39:49.801869+00:00 app[web.1]: TypeError: Cannot read property 'logger' of undefined
2017-05-29T02:39:49.801871+00:00 app[web.1]:     at UniversalBot.Library.findActiveDialogRoutes (/app/node_modules/botbuilder/lib/bots/Library.js:135:20)
2017-05-29T02:39:49.801871+00:00 app[web.1]:     at /app/node_modules/botbuilder/lib/bots/Library.js:243:31
2017-05-29T02:39:49.801872+00:00 app[web.1]:     at /app/node_modules/async/lib/async.js:718:13
2017-05-29T02:39:49.801873+00:00 app[web.1]:     at async.forEachOf.async.eachOf (/app/node_modules/async/lib/async.js:233:13)
2017-05-29T02:39:49.801874+00:00 app[web.1]:     at _parallel (/app/node_modules/async/lib/async.js:717:9)
2017-05-29T02:39:49.801875+00:00 app[web.1]:     at Object.async.parallel (/app/node_modules/async/lib/async.js:731:9)
2017-05-29T02:39:49.801876+00:00 app[web.1]:     at /app/node_modules/botbuilder/lib/bots/Library.js:241:23
2017-05-29T02:39:49.801876+00:00 app[web.1]:     at UniversalBot.Library.recognize (/app/node_modules/botbuilder/lib/bots/Library.js:68:13)
2017-05-29T02:39:49.801877+00:00 app[web.1]:     at UniversalBot.Library.defaultFindRoutes (/app/node_modules/botbuilder/lib/bots/Library.js:236:14)
2017-05-29T02:39:49.801877+00:00 app[web.1]:     at UniversalBot.Library.findRoutes (/app/node_modules/botbuilder/lib/bots/Library.js:85:18)
2017-05-29T02:39:49.868006+00:00 heroku[web.1]: Process exited with status 1
2017-05-29T02:39:49.881799+00:00 heroku[web.1]: State changed from up to crashed

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 5
  • Comments: 17 (3 by maintainers)

Most upvoted comments

I can confirm that the Middleware solution @TrejGun suggested works for this issue in Slack, however, the syntax that worked for me was: bot.use(builder.Middleware.dialogVersion({ version: 1.0, resetCommand: /^reset/i }));

I’m also receiving the same error for skype client. But I’m using the botbuilder-calling and botbuilder node.js skype client botbuilder-calling

var restify = require('restify');
var builder = require('botbuilder');
var calling = require('botbuilder-calling');
// Setup Restify Server
var server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () {
   console.log('%s listening to %s', server.name, server.url); 
});
// Create chat bot
var chatConnector = new builder.ChatConnector({
     appId: process.env.MICROSOFT_APP_ID,
    appPassword: process.env.MICROSOFT_APP_PASSWORD
});
var chatBot = new builder.UniversalBot(chatConnector);
server.post('/api/messages', chatConnector.listen());
// Create calling bot
var connector = new calling.CallConnector({
    callbackUrl: 'https://<your host>/api/calls',
    appId: process.env.MICROSOFT_APP_ID,
    appPassword: process.env.MICROSOFT_APP_PASSWORD
});
var callingBot = new calling.UniversalCallBot(connector);
server.post('/api/calls', connector.listen());
// Add root dialog
chatBot.dialog('/', function (session) {
    session.send('Hi... Please call me to interact with me.'); 
});

callingBot.dialog('/', function (session) {
    session.send('Watson... come here!');
});;

run the node app.js

The following error occured

/home/marcus/advbot/node_modules/botbuilder/node_modules/promise/lib/done.js:10
      throw err;
      ^

TypeError: Cannot read property 'logger' of undefined
    at UniversalBot.Library.findActiveDialogRoutes (/home/marcus/advbot/node_modules/botbuilder/lib/bots/Library.js:135:20)
    at /home/marcus/advbot/node_modules/botbuilder/lib/bots/Library.js:243:31
    at /home/marcus/advbot/node_modules/botbuilder/node_modules/async/lib/async.js:718:13
    at async.forEachOf.async.eachOf (/home/marcus/advbot/node_modules/botbuilder/node_modules/async/lib/async.js:233:13)
    at _parallel (/home/marcus/advbot/node_modules/botbuilder/node_modules/async/lib/async.js:717:9)
    at Object.async.parallel (/home/marcus/advbot/node_modules/botbuilder/node_modules/async/lib/async.js:731:9)
    at /home/marcus/advbot/node_modules/botbuilder/lib/bots/Library.js:241:23
    at UniversalBot.Library.recognize (/home/marcus/advbot/node_modules/botbuilder/lib/bots/Library.js:68:13)
    at UniversalBot.Library.defaultFindRoutes (/home/marcus/advbot/node_modules/botbuilder/lib/bots/Library.js:236:14)
    at UniversalBot.Library.findRoutes (/home/marcus/advbot/node_modules/botbuilder/lib/bots/Library.js:85:18)

Please guide

@stevengum97 I’m only working on skype client and not yet tried with FB Messenger.

Now Today again I’m receiving the same error message. TypeError: Cannot read property ‘logger’ of undefined. Does it because of I’m deploying the files continuously and testing my bot on skype client?