botkit-storage-dynamodb

0.2.0 • Public • Published

botkit-storage-dynamodb

A DynamoDB storage module for Botkit.

Usage

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 region, accessKeyId and secretAccessKey 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')({
      region: 'us-west-2',
      accessKeyId: process.env.AWS_ACCESS_KEY_ID
      secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY }),
    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']};
controller.storage.teams.save(beans);
beans = controller.storage.teams.get('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.

Readme

Keywords

Package Sidebar

Install

npm i botkit-storage-dynamodb

Weekly Downloads

3

Version

0.2.0

License

MIT

Unpacked Size

12.1 kB

Total Files

9

Last publish

Collaborators

  • joshuahoover