The information on this page pertains to the legacy version of Botkit, 0.7 and below and may be out of date! Documentation for the new v4+ version of Botkit can be found here.

Storing Information

Botkit has a built in storage system used to keep data on behalf of users and teams between sessions. Botkit uses this system automatically when storing information for Slack Button applications (see below).

By default, Botkit will use json-file-store to keep data in JSON files in the filesystem of the computer where the bot is executed. (Note this will not work on Heroku or other hosting systems that do not let node applications write to the file system.) Initialize this system when you create the bot:

var controller = Botkit.slackbot({
  json_file_store: 'path_to_json_database'

This system supports freeform storage on a team-by-team, user-by-user, and channel-by-channel basis. Basically is a key value store. All access to this system is through the following twelve functions. Example usage:{id: message.user, foo:'bar'}, function(err) { ... });, function(err, user_data) {...});, function(err) {...});, all_user_data) {...});{id:, foo:'bar'}, function(err) { ... });, function(err, channel_data) {...});, function(err) {...});, all_channel_data) {...});{id:, foo:'bar'}, function(err) { ... });, function(err, team_data) {...});, function(err) {...});, all_team_data) {...});

Note that save must be passed an object with an id. It is recommended to use the team/user/channel id for this purpose. [user/channel/team]_data will always be an object while all_[user/channel/team]_data will always be a list of objects.

Writing your own storage module

If you want to use a database or do something else with your data, you can write your own storage module and pass it in.

Make sure your module returns an object with all the methods. See simple_storage.js for an example of how it is done!

Then, use it when you create your bot:

var controller = Botkit.slackbot({
  storage: my_storage_provider

Is something missing or out of date?

This file is managed on Github. click here to view the source, and send us a pull request with your improvements!

Back to top