npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

wingbot-dynamodb

v3.4.2

Published

DynamoDB storage for wingbot

Downloads

327

Readme

DynamoDB plugin for wingbot

DynamoDB tables definition

All tables uses ${self:custom.prefix} to be able to use configuration on different bots and environments.

Conversation States and bot configuration

StatesTable:
    Type: AWS::DynamoDB::Table
    Properties:
    TableName: ${self:custom.prefix}-states
    AttributeDefinitions:
      - AttributeName: senderId
        AttributeType: S
      - AttributeName: pageId
        AttributeType: S
    KeySchema:
      - AttributeName: senderId
        KeyType: HASH
      - AttributeName: pageId
        KeyType: RANGE
    ProvisionedThroughput:
      ReadCapacityUnits: 1
      WriteCapacityUnits: 1

BotConfigTable:
    Type: AWS::DynamoDB::Table
    Properties:
    TableName: ${self:custom.prefix}-botconfig
    AttributeDefinitions:
      - AttributeName: k
        AttributeType: S
    KeySchema:
      - AttributeName: k
        KeyType: HASH
    ProvisionedThroughput:
      ReadCapacityUnits: 1
      WriteCapacityUnits: 1

Chat Logs (optional)

ChatlogTable:
    Type: AWS::DynamoDB::Table
    Properties:
    TableName: ${self:custom.prefix}-chatlog
    AttributeDefinitions:
      - AttributeName: userId
        AttributeType: S
      - AttributeName: timestamp
        AttributeType: N
    KeySchema:
      - AttributeName: userId
        KeyType: HASH
      - AttributeName: timestamp
        KeyType: RANGE
    ProvisionedThroughput:
      ReadCapacityUnits: 1
      WriteCapacityUnits: 1

Chatbot tokens (optional)

BottokensTable:
    Type: AWS::DynamoDB::Table
    Properties:
    TableName: ${self:custom.prefix}-bottokens
    AttributeDefinitions:
      - AttributeName: senderId
        AttributeType: S
      - AttributeName: token
        AttributeType: S
      - AttributeName: pageId
        AttributeType: S
    KeySchema:
      - AttributeName: senderId
        KeyType: HASH
      - AttributeName: pageId
        KeyType: RANGE
    GlobalSecondaryIndexes:
        - IndexName: token
        KeySchema:
            - AttributeName: token
            KeyType: HASH
        Projection:
            ProjectionType: ALL
        ProvisionedThroughput:
            ReadCapacityUnits: 1
            WriteCapacityUnits: 1
    ProvisionedThroughput:
        ReadCapacityUnits: 1
        WriteCapacityUnits: 1

Facebook Attachment cache (optional)

AttachmentsTable:
  Type: AWS::DynamoDB::Table
  Properties:
    TableName: ${self:custom.prefix}-attachments
    AttributeDefinitions:
      - AttributeName: url
        AttributeType: S
    KeySchema:
      - AttributeName: url
        KeyType: HASH
    ProvisionedThroughput:
      ReadCapacityUnits: 1
      WriteCapacityUnits: 1

API

Classes

Typedefs

StateStorage

Conversation state DynamoDB storage

Kind: global class

new StateStorage([tableName], [dynamoDbService])

| Param | Type | Default | Description | | --- | --- | --- | --- | | [tableName] | string | "states" | | | [dynamoDbService] | AWS.DynamoDB | | preconfigured dynamodb service |

stateStorage.getState(senderId, pageId) ⇒ Promise.<(State|null)>

Kind: instance method of StateStorage

| Param | Type | | --- | --- | | senderId | string | | pageId | string |

stateStorage.getOrCreateAndLock(senderId, pageId, [defaultState], [timeout]) ⇒ Promise.<Object>

Kind: instance method of StateStorage Returns: Promise.<Object> - - conversation state

| Param | Type | Default | Description | | --- | --- | --- | --- | | senderId | string | | sender identifier | | pageId | string | | page/channel identifier | | [defaultState] | Object | | default state of the conversation | | [timeout] | number | 300 | given default state |

stateStorage.saveState(state) ⇒ Promise.<Object>

Kind: instance method of StateStorage

| Param | Type | Description | | --- | --- | --- | | state | Object | conversation state |

BotTokenStorage

Conversation DynamoDB state storage

Kind: global class

new BotTokenStorage([tableName], [tokensIndexName], [dynamoDbService])

| Param | Type | Default | Description | | --- | --- | --- | --- | | [tableName] | string | "wingbot-tokens" | the table name | | [tokensIndexName] | string | "token" | index to query table by token | | [dynamoDbService] | AWS.DynamoDB | | preconfigured dynamodb service |

botTokenStorage.findByToken(token) ⇒ Promise.<(Token|null)>

Kind: instance method of BotTokenStorage

| Param | Type | | --- | --- | | token | string |

botTokenStorage.getOrCreateToken(senderId, pageId, customTokenFactory) ⇒ Promise.<(Token|null)>

Kind: instance method of BotTokenStorage

| Param | Type | | --- | --- | | senderId | string | | pageId | string | | customTokenFactory | Object |

botTokenStorage._getToken(senderId, pageId) ⇒ Promise.<({senderId:string, token:string}|null)>

Kind: instance method of BotTokenStorage

| Param | Type | | --- | --- | | senderId | string | | pageId | string |

ChatLogStorage

DynamoDB Chat Log storage

Kind: global class

new ChatLogStorage([tableName], [dynamoDbService], [log])

| Param | Type | Default | Description | | --- | --- | --- | --- | | [tableName] | string | "chatlog" | | | [dynamoDbService] | AWS.DynamoDB | | preconfigured dynamodb service | | [log] | Object | | console like logger |

chatLogStorage.log(userId, responses, request) ⇒ Promise

Log single event

Kind: instance method of ChatLogStorage

| Param | Type | Description | | --- | --- | --- | | userId | string | | | responses | Array.<Object> | list of sent responses | | request | Object | event request |

BotConfigStorage

Storage for wingbot.ai conversation config

Kind: global class

new BotConfigStorage([tableName], [dynamoDbService])

| Param | Type | Default | Description | | --- | --- | --- | --- | | [tableName] | string | "wingbot-config" | the table name | | [dynamoDbService] | AWS.DynamoDB | | preconfigured dynamodb service |

botConfigStorage.api([onUpdate], [acl]) ⇒ Object

Returns botUpdate API for wingbot

Kind: instance method of BotConfigStorage

| Param | Type | Description | | --- | --- | --- | | [onUpdate] | function | async update handler function | | [acl] | function | Array.<string> | acl configuration |

botConfigStorage.invalidateConfig() ⇒ Promise

Invalidates current configuration

Kind: instance method of BotConfigStorage

botConfigStorage.getConfigTimestamp() ⇒ Promise.<number>

Kind: instance method of BotConfigStorage

botConfigStorage.updateConfig(newConfig) ⇒ Promise.<T>

Kind: instance method of BotConfigStorage Template: T

| Param | Type | | --- | --- | | newConfig | T |

botConfigStorage.getConfig() ⇒ Promise.<(Object|null)>

Kind: instance method of BotConfigStorage

AttachmentCache

Storage for Facebook attachment ids

Kind: global class

new AttachmentCache([tableName], [dynamoDbService])

| Param | Type | Default | Description | | --- | --- | --- | --- | | [tableName] | string | "wingbot-attachment-cache" | the table name | | [dynamoDbService] | AWS.DynamoDB | | preconfigured dynamodb service |

attachmentCache.findAttachmentByUrl(url) ⇒ Promise.<(number|null)>

Kind: instance method of AttachmentCache

| Param | Type | | --- | --- | | url | string |

attachmentCache.saveAttachmentId(url, attachmentId) ⇒ Promise

Kind: instance method of AttachmentCache

| Param | Type | | --- | --- | | url | string | | attachmentId | number |

State : Object

Kind: global typedef Properties

| Name | Type | | --- | --- | | senderId | string | | pageId | string | | state | Object |

Token : Object

Kind: global typedef Properties

| Name | Type | | --- | --- | | senderId | string | | pageId | string | | token | string |