node package manager
Easy collaboration. Discover, share, and reuse code in your team. Create a free org »



A DynamoDB storage module for Botkit.


A DynamoDB table is required:

Name: botkit Primary partition (hash) key: type (String) Primary sort (range) key: id (String)

Require botkit-storage-dynamodb and pass it a config with the dynamoRegion, dynamoAccessKey and dynamoAccessSecret options set. If your table is not named 'botkit', then you'll need to pass in the name of your table in the dynamoTable option. 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'),
    dynamoStorage = require('botkit-storage-dynamodb')({
      dynamoRegion: 'us-west-2',
      dynamoAccessKey: process.env.DYNAMODB_KEY
      dynamoAccessSecret: process.env.DYNAMODB_SECRET }),
    controller = Botkit.slackbot({
        storage: dynamoStorage
// then you can use the Botkit storage api, make sure you have an id property
var beans = {id: 'cool', beans: ['pinto', 'garbanzo']};;
beans ='cool');

Note: The type field/key is stored automatically with the object based on the type of storage being called. For example, in the code above, the record will have type: teams. If you call users or channels storage, the type will be set to either users or channels. This approach allows for one DynamoDB table, partitioned by storage type.