0

I am trying to integrate Firebase into Botkit using botkit-storage-firebase, but I am getting this warning on initialization:

FIREBASE WARNING: Exception was thrown by user callback. TypeError: cb is not a function
    at success (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/botkit-storage-firebase/src/index.js:50:13)
    at c (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:240:58)
    at /Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:201:710
    at ec (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:52:165)
    at ac (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:31:216)
    at $b (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:30:1198)
    at Ri (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:224:313)
    at X.h.Gb (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:238:140)
    at X.h.Og (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:240:249)
    at Object.get (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/botkit-storage-firebase/src/index.js:47:31) 
/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:52
(d="0"+d),c+=d;return c.toLowerCase()}var zd=/^-?\d{1,10}$/;function td(a){return zd.test(a)&&(a=Number(a),-2147483648<=a&&2147483647>=a)?a:null}function ec(a){try{a()}catch(b){setTimeout(function(){R("Exception was thrown by user callback.",b.stack||"");throw b;},Math.floor(0))}}function S(a,b){if(t(a)){var c=Array.prototype.slice.call(arguments,1).slice();ec(function(){a.apply(null,c)})}};function Ad(a){var b={},c={},d={},e="";try{var f=a.split("."),b=Pb(id(f[0])||""),c=Pb(id(f[1])||""),e=f[2],d=c.d||{};delete c.d}catch(g){}return{ph:b,Dc:c,data:d,bh:e}}function Bd(a){a=Ad(a).Dc;return"object"===typeof a&&a.hasOwnProperty("iat")?z(a,"iat"):null}function Cd(a){a=Ad(a);var b=a.Dc;return!!a.bh&&!!b&&"object"===typeof b&&b.hasOwnProperty("iat")};function Dd(a){this.Y=a;this.g=a.n.g}function Ed(a,b,c,d){var e=[],f=[];Na(b,function(b){"child_changed"===b.type&&a.g.Ad(b.Le,b.Ma)&&f.push(new H("child_moved",b.Ma,b.Ya))})

TypeError: cb is not a function
    at success (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/botkit-storage-firebase/src/index.js:50:13)
    at c (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:240:58)
    at /Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:201:710
    at ec (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:52:165)
    at ac (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:31:216)
    at $b (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:30:1198)
    at Ri (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:224:313)
    at X.h.Gb (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:238:140)
    at X.h.Og (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:240:249)
    at Object.get (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/botkit-storage-firebase/src/index.js:47:31)

I am initialising it like this.

var Botkit = require('botkit'),
  firebaseStorage = require('botkit-storage-firebase')({firebase_uri: 'https://xxx.firebaseio.com/'}),
      controller = Botkit.slackbot({
          debug: true,
          storage: firebaseStorage
      });

// then you can use the Botkit storage api, make sure you have an id property
var beans = {id: 'cool', beans: ['pinto', 'garbanzo']};
controller.storage.teams.save(beans);
beans = controller.storage.teams.get('cool');
console.log(beans);

However I can see the database entry posted on firebase console succesfully. Problem occurs only on

beans = controller.storage.teams.get('cool');

Any idea how to get around this?

AL.
  • 36,815
  • 10
  • 142
  • 281

1 Answers1

0

botkit-firebase-storage looks really out of date (last updated over a year ago, not updated to firebase 3.0).

Additionally (and sadly), this module (or our products) are named confusingly--it doesn't use Firebase Storage is uses the Firebase Realtime Database for "data storage".

The issue comes from here, where indeed, cb doesn't appear to be a function, given that it's never populated (.get(ref) returns function(id, cb), where is cb initialized from?).

Mike McDonald
  • 15,609
  • 2
  • 46
  • 49