A MongoDB storage driver for Botkit

Downloads in past


54151.0.76 years ago8 years agoMinified + gzip package size for botkit-storage-mongo in KB


npm David npm bitHound Overall Score
A Mongo storage module for Botkit that provides a simple system for storing information about a user, a channel, or a team.
This project is an extension to Botkit Core, a richly featured developer toolkit for building bots and conversational apps.
This module conforms to Botkit's storage plugin convention.


Just require botkit-storage-mongo and pass it a config with a mongoUri option. In addition, you may pass a tables parameter, which will create methods for accessing additional tables (other than user, channel and team) in your Mongo database. Then pass the returned storage when creating your Botkit controller. Botkit will do the rest.
Make sure everything you store has an id property, that's what you'll use to look it up later.
var Botkit = require('botkit'),
    mongoStorage = require('botkit-storage-mongo')({mongoUri: '...', tables: ['optional','list', 'of', 'custom','tables', 'to', 'add']}),
    controller = Botkit.slackbot({
        storage: mongoStorage

// then you can use the Botkit storage api, make sure you have an id property
var beans = {id: 'cool', beans: ['pinto', 'garbanzo']};;'cool', function(error, beans){
    // do something with beans

You can also get all entries from a table or find a selected set depending on a parameters.
storage.users.all(function(error, users){
    // do something with users

storage.users.find({team_id: team_id}, function(error, users){
    // do something with users

As of 1.0.6, all functions also support Promise syntax:
storage.users.all().then(function(list_of_users) {

  // do something