johnagan / serverless-slack Goto Github PK
View Code? Open in Web Editor NEWA Slack App Framework for AWS Lambda / Serverless.js
License: MIT License
A Slack App Framework for AWS Lambda / Serverless.js
License: MIT License
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.
The Serverless application crashes if there is no TABLE_NAME
environment variable, variable that isn't used to anything.
Hi,
Is this project stable enough to be production ready?
Did you plan to make a stable release? :-)
Thanks
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:
Please discuss.
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?
I'm interested in logging when a new team is created, so a hook into https://github.com/johnagan/serverless-slack/blob/master/src/index.js#L38 would allow me to log and do any other operations based on a team save or error.
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...
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.
Hi @johnagan ,
I am trying to implement a slash command which executes a query taking longer than 3 seconds. Slack API docs (https://api.slack.com/slash-commands#responding_to_a_command) mention a way to use delayed responses. Can you give an example how to achieve this with serverless-stack? Thanks in advance!
Hi,
@bdcrouchman worked on a few improvements for this library (currently private).
Let me know if you are interested and I can create a PR with all his changes.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.