GithubHelp home page GithubHelp logo

miklosaubert / botkit-storage-dynamodb Goto Github PK

View Code? Open in Web Editor NEW

This project forked from joshuahoover/botkit-storage-dynamodb

0.0 1.0 0.0 34 KB

A DynamoDB storage module for Botkit.

License: MIT License

JavaScript 100.00%

botkit-storage-dynamodb's Introduction

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.

botkit-storage-dynamodb's People

Contributors

joshuahoover avatar miklosaubert avatar pmacca avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.