Skip to content

PulsarAI/botkit-storage-dynamodb

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 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']};
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.

About

A DynamoDB storage module for Botkit.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%