Code Monkey home page Code Monkey logo

serverless-slack's People

Contributors

carlovsk avatar czerasz avatar hamxiaoz avatar johnagan avatar modmac avatar theconnman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

serverless-slack's Issues

Required DynamoDB table

On the current flow, a DynamoDB table is required to store the OAuth data from slack (correct me if I'm wrong). However, since the library is using the aws-sdk package, the table needs to be created manually. My proposal is to change to dynamoose, because it creates the table automatically.

I can help with that, but I also need some help with the table and what it does specifically.

Stable release?

Hi,

Is this project stable enough to be production ready?

Did you plan to make a stable release? :-)

Thanks

Configurable DynamoDB DocumentClient

https://github.com/johnagan/serverless-slack/blob/master/src/dynamo.js#L4

To work with the offline local environment using serverless plugins:

plugins:
  - serverless-dynamodb-local
  - serverless-offline

additional configuration of DocumentClient is required.
Since Dynamo service is a hardcoded dependency there is no way to inject it on the implementation level. Two ways of resolving this issue:

  1. Using env variables for DocumentClient config ( like in here, but with additional params: https://github.com/serverless/serverless-slack/blob/master/lib/models/team.js#L12 )
  2. Dependency injection model

Please discuss.

As a bot, how can I tell when my name is mentioned?

Given a message event payload that looks like this:

{ token: <token>,
  team_id: 'T8C5ZU2R4',
  api_app_id: 'A8BA4HGEN',
  event: 
   { type: 'message',
     user: 'U8B7MNP5Z',
     text: 'Hey <@U8BBXDGJ0>',
     ts: '1513796283.000314',
     channel: 'C8AKW54SC',
     event_ts: '1513796283.000314' },
  type: 'event_callback',
  event_id: 'Ev8H34TQ1X',
  event_time: 1513796283,
  authed_users: [ 'U8BBXDGJ0' ] }

How can I tell what the bot's user ID is? Is it given that the first id in authed_users belongs to the bot user?

Unhandled promise rejection on bot object?

We are developing a serverless Slack application and your framework is a great help - thanks for your effort!

Our handler code looks like this:

'use strict';

const slack = require('serverless-slack');
exports.handler = slack.handler.bind(slack);

slack.on('message', (msg, bot) => {
    bot.send('channels.info', { channel: msg.event.channel }).then(data => {
        console.log("channel: " + JSON.stringify(data.channel));
    });
    bot.send('users.info', { channel: msg.event.user }).then(data => {
        console.log("user: " + JSON.stringify(data.user));
    });
});

Slack successfully sends us events, so we get notified, when someone posts a message,
Unfortunately, calling bot.send() results in following exception:
UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): [object Object]
This happens for all methods on the bot object, so it seems to me that it's not properly initiated.

I'm quiet new to al this technology, so any hint why this happens and how I can debug/fix the issue would be great! Or maybe somehow Slack's API has changed over time?

EDIT: Adding catch() to log the error I see the problem:

{ "ok": false, "error": "not_authed" }

The documentation states that the bot is automatically authenticated correctly, so I'm bit surprised...

Using Store

Are there any working examples of using store?

slack.store.save(data).then(results => {
  // the save results
});

slack.store.get(id).then(record => {
  // return a single record by key
});

I've been having trouble getting these to work properly. I'm questioning if they work at all considering they're not used in the example application.

Thanks for any advice.

Contributing back

Hi,

@bdcrouchman worked on a few improvements for this library (currently private).

  • The bot.reply() function should not return a promise that ALWAYS rejects (currently expects data.ok === 'ok' but data === 'ok', so it rejects the promise)
  • Expose the callback passed to the lambda. Without it isn't possible to have user issued commands show up in slack (without having the bot respond, but this causes the Slack bot to say it and the channel to look one-sided and ugly)
  • Replying forcibly hides the slack response to http requests. This information is potentially useful. (swapped to using callback)
  • Add errorstack config to the lambda handler. Currently gives no feedback when it crashes. Makes debugging more challenging.
  • Other minor things

Let me know if you are interested and I can create a PR with all his changes.

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.