Git Product home page Git Product logo

node-slack-events-api's Introduction

⚠️ This project has been moved to slackapi/node-slack-sdk

Slack Events API adapter for Node

Build your Slack apps by reacting to messages, emojis, files, and many more types of interesting events in the Events API. This package will help you start with sensible and secure defaults.

The adapter gives you a simple and highly configurable Node-style EventEmitter to attach functions to handle events.


Support

Need help? Join the Bot Developer Hangout team and talk to us in #slack-api.

You can also create an Issue right here on GitHub.

node-slack-events-api's People

Contributors

aoberoi avatar billdybas avatar erwinai avatar ianwsperber avatar pichsenmeister avatar roach avatar sidbav 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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

node-slack-events-api's Issues

how to get direct message

Description

Describe your issue here.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

slack-events version:
node version:
OS version(s):

Steps to reproduce:

Expected result:

What you expected to happen
node-slack-events-api is working for public channel, i can sniff all public channel message but can't sniff direct message

Actual result:

What actually happened
no response coming for direct message in slackEvents.on('message', (event)=> {}

Attachments:

Logs, screenshots, screencast, sample project, funny gif, etc.

Example does not work (local machine and glitch)

Description

Describe your issue here.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

When I run the greet and react example on my local machine or on glitch i end up getting errors on both. Both of the files are glitch and the example on github are different (atleast the .env files and package.json is as well, not sure about are not the same either so I am not sure if I am running into an error

Reproducible in:

Local Machine

@slack/events-api version: 2.0.0

Glitch

@slack/events-api version: 1.0.0

Local Machine

node version: v10.1.0

Glitch

node version: v8.11.3

OS version(s): Microsoft Windows [Version 10.0.17134.228]

Steps to reproduce:

Local Machine

  1. git clone https://github.com/slackapi/node-slack-events-api.git
  2. cd example/greet-and-react
  3. npm i
  4. rename .env.sample to .env
  5. fill in info in the .env file
  6. node index.js

Expected result:

What you expected to happen

  • program runs

Actual result:

What actually happened
brings up an error (see below)

Glitch

  1. Fill in info in .env file (which btw are not the same in the repo and the file)
  2. Go to your slack app (create on if you haven't already)
  3. Go to the events subscription section, fill in your glitch url + /slack/events

Expected result:

What you expected to happen

  • Slack brings up no errors

Actual result:

What actually happened
slack brings up an error (see below)

Attachments:

When running on my Local Machine:

image

When running on Glitch:

image

I hope all this info is enough to help!

add a `stop()` method to adapter

Description

A SlackEventAdapter instance can start(port) to start a server. Once that server is started, there is no graceful API to shut it down. A stop() method would gracefully close the server.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Record gifs of configuration steps

Description

This would make the configuration of the Events API much clearer. Can use something similar to the instructions in https://github.com/slackapi/node-slack-interactive-messages

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

New event type: 'retry'

Description

I'd like to propose a new event type that the SlackEventAdapter could emit: retry.

Currently, the only way to be informed that an event is a retry is to use the includeHeaders option and then in each event handler inspect the headers argument. This would have to be done in each event type's handler.

My hypothesis is that the use cases for knowing about retries are usually across all event types, and therefore we could emit it one new event type. The idea is that one incoming HTTP request from Slack's Events API would emit both a retry event and the named event the request contains (if the request was a retry).

Before:

function handleRetry (event, headers) {
  if (headers['x-slack-retry-num']) {
    // do some handling
    console.log(`event ${event.type} retried ${headers['x-slack-retry-num']} times because ${headers['x-slack-retry-reason']}`);
  }
}

slackEvents.on('message', (event, headers) => {
  handleRetry(event, headers);

  // do some handling
  console.log(`user ${event.user} said ${event.text}`);
});

slackEvents.on('group_open', (event, headers) => {
  handleRetry(event, headers);

  // do some handling
  console.log(`user ${event.user} opened private channel ${event.channel}`);
});

After:

slackEvents.on('retry', (retry) => {
  // do some handling
  console.log(`event ${retry.event.type} retried ${retry.num} times because ${retry.reason}`);
});

slackEvents.on('message', (event) => {
  // do some handling
  console.log(`user ${event.user} said ${event.text}`);
});

slackEvents.on('group_open', (event) => {
  console.log(`user ${event.user} opened private channel ${event.channel}`);
});

Open questions:

  • Would the waitForResponse option interact with the retry event in any special way? It seems unlikely given that the hypothesis is that you'd want to handle the real event in a different handler, and that handler would be given the respond() callback, and your app should only invoke it once.
  • Would the includeHeaders and includeBody options have an effect on this event? It seems reasonable.

It would be fantastic to get some feedback on this issue, especially if you can bring up use cases where you'd want to know about retries and what you might do with them.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Unable to authorize using OAuth

I tried to run this script to receive messages using examples/greet-and-react but getting the following error:
Error: Failed to serialize user into session application.js:630 at pass (e:\Convee\Telegram\node_modules\passport\lib\authenticator.js:281:19) at Authenticator.serializeUser (e:\Convee\Telegram\node_modules\passport\lib\authenticator.js:299:5) at SessionManager.logIn (e:\Convee\Telegram\node_modules\passport\lib\sessionmanager.js:14:8) at IncomingMessage.req.login.req.logIn (e:\Convee\Telegram\node_modules\passport\lib\http\request.js:50:33) at SlackStrategy.strategy.success (e:\Convee\Telegram\node_modules\passport\lib\middleware\authenticate.js:248:13) at verified (e:\Convee\Telegram\node_modules\passport-oauth2\lib\strategy.js:177:20) at Object.passport.use.SlackStrategy [as verify] (e:\Convee\Telegram\app.js:44:3) at SlackStrategy._verify (e:\Convee\Telegram\node_modules\@aoberoi\passport-slack\dist\strategy.js:78:24) at e:\Convee\Telegram\node_modules\passport-oauth2\lib\strategy.js:184:24 at skipIt (e:\Convee\Telegram\node_modules\passport-oauth2\lib\strategy.js:348:12)

Slack API's are so complex to work with. I just want to receive the messages which is sent from my app/bot on any channel but unable to find any solution. And in this library also, you need to maintain many keys,secrets, token and then authentication etc. why not to make it simple as telegarm, facebook,kik,skype bots? A big Downvote Slack!!!!

Simplify installation steps regarding generation of verification token

Description

The verification token is now generated as soon as the app is created, so the setup steps can be simplified.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Rename createSlackEventAdapter to createEventAdapter

Description

The export name is pretty verbose and often results in having to use two lines to initialize the object. The "Slack" portion of the name is redundant since the package is @slack/....

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

verifyRequestSignature does not consider body-parser's req.rawBody

Description

The current implementation of verifying the request signature does not take into account that body-parser package does expose a raw body as the request.rawBody variable.

Currently, both the node-slack-events-api and the node-slack-interactive-messages api use the same code. I've tried using both API's with Google Cloud Functions (and Firebase Functions, built on top of that service). Unfortunately, the request is pre-parsed before it even reaches the Cloud Function. This causes the slack middleware to deny attaching the listener. (adapter.js L75).

The raw-body package is used in both node-slack-events-api and the node-slack-interactive-messages api, which takes the request object as a parameter. This package does not work with body-parser's request.rawBody.

Perhaps make use of body-parser's ability to provide a raw body and check if it's there. If not, only then use the raw-body package? This will allow developers to use body-parser in their code, but won't break any existing code depending on node-slack-events-api and node-slack-interactive-messages.

It will also allow Google Cloud Functions (and Firebase Functions) to be used, which probably opens up some interesting opportunities for Slack API.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Reproducible in:

@slack/events-api version: 2.1.1 (latest)

node version: any

OS version(s): any

Attachments:

https://stackoverflow.com/questions/18710225/node-js-get-raw-request-body-using-express
https://stackoverflow.com/questions/42950561/how-can-i-get-the-raw-request-body-in-a-google-cloud-function
https://cloud.google.com/functions/docs/writing/http#handling_content_types
https://cloud.google.com/functions/docs/writing/http#parsing_http_requests

Greet and React Permissions

Description

When using the example greet and react app, the instructions lack information on OAuth permissions for the application to read messages in a channel and respond.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • [x ] documentation related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • [x ] I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • [x ] I've read and agree to the Code of Conduct.
  • [x ] I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

After inviting the new bot to a channel and typing "hi", my glitch application returns this error:
No authorization found for this team. Did you install this app again after restarting?

This project is moving to slackapi/node-slack-sdk

As a part of the next version of the Node Slack SDK, we'll be moving this package to live along side its siblings in a single repository.

This is great news, because many users of this package are already using the WebClient, RTMClient, or IncomingWebhook objects from the @slack/client package, so that means there will be one place to file issues, read documentation, and look for help.

Please note that the package itself, including its API, is not changing in any meaningful way. The code will live at a different URL, but the package on npm will still be @slack/events-api. There are new packages that are being created from @slack/client, and we encourage you to migrate to them if you're already using that package.

In order to complete the transition, we will be closing all open issues in this repo, and opening new ones to represent them at https://github.com/slackapi/node-slack-sdk/issues. We'll clearly leave links so that there's no lost context or history. You can expect this to happen as soon as v5.0.0 is complete, which we're targeting for early March 2019.

If you have any questions or concerns, please leave a comment in the announcement issue.

Move as much functionality as possible into the adapter class

Description

try to bring token verification, error creation, and/or emit argument building into the adapter class. one day this may become shared among multiple web framework outlets.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Add support for request signing

Description

Request signing went live and we should add support into our SDKs. https://api.slack.com/docs/verifying-requests-from-slack

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Use an npmignore file to only publish the output of babel to npm

Description

Recently we ran into some security issues in another package because npm publish will tar any files in the project directory, even the ones that are git ignored. Since this wasn't clear until npm@6, we didn't notice that random local files were being uploaded into the package.

On top of security, this would decrease the package size significantly, which is a big win.

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Demonstrate data persistence in the demo example

Description

I recently tested a modified version of the demo on Heroku and everything worked fine until I re-deployed. I suspect seeing the message No authorization found for this team. Did you install this app again after restarting? in the logs means the authorizations are not persisted.

// Initialize a data structures to store team authorization info (typically stored in a database)

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

@slack/events-api version: 2.1.0

node version: 6.11.0

OS version(s): Heroku

Steps to reproduce:

  1. Deploy the demo app to Heroku
  2. Authenticate
  3. Redeploy
  4. See No authorization found for this team. Did you install this app again after restarting?

Expected result:

I think it'd be very useful to show an example of how to persist data in the provided demo.

Put body-parser in the installation

Description

The body-parser module is required for normal use of the module, so it should be in the npm install --save line.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Add requestListener usage to README

Description

We currently describe using the built-in server and the express middleware, but using this adapter as a request listener is also a valid usage.

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Export helper methods such as `verifyRequestSignature`

Description

Hey all! First of all congrats on the 2.0.0 release! I'm excited to use this library to build a slack integration, but have found that I want more flexibility in my request handler than provided through the provided adapter abstraction and its express middleware. It would be nice if users had access to some of the helper methods used by the adapter. Specifically I'd like to be able to import the verifyRequestSignature method, so that I do not need to handroll that somewhat complicated bit of logic. I'm happy to create a PR for this change if you think it'd be of value. Unsure if there might be other methods worth exporting as well. Thanks!

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

dialog.open method to generate drop down value based on another element selected value.

Description

I am using dialog.open method, in this there are two elements with select option, I have selected value from drop down menu in the first element, and from second element I need to select the options based on first element selected values, which is not getting in the "dialog_suggestion" payload.

Is it possible to send the selected value from the first element, before select the value from second element drop down?

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

@slack/events-api version: 1.3.0

node version: v10.15.0

OS version(s): CentOS Linux release 7.5.1804 (Core)

Steps to reproduce:

  1. use dialog.open method with two elements, select the value from drop down.
  2. try to select the value from second drop down based on the first drop down value.

Expected result:

I should be able to generated dynamic values based on the first element selected values.

Actual result:

I am not able to get the value to decide which is selected from the first element from the dialog_suggestion payload.

Attachments:

Logs, screenshots, screencast, sample project, funny gif, etc.

image

Listen for any event

Description

You might want to structure an application such that all incoming events are handled by the same function. Maybe you want to use the signature verification facilities of this package, but want to dispatch to your own routing system. Or maybe your application forwards all events on to another micro-service or system. Maybe your application wants to log all events it sees, or implement some other form of "middleware" on event processing.

It would be useful to design a solution where all the mentioned use cases can be addressed. At this point, I'm not proposing a specific API, but the maintainers are interested in hearing proposals for APIs from the community.

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

I can't verify Production URL for events API

Description

Hello, everyone! I'm trying to integrate Slack API to my web app using node-slack-events-api (v2.1.1)
But I'm getting error every time when I'm trying to verify my production URL.

@slack/events-api version: 2.1.1
node version: 10.13.0

Attachments:

screen shot 2018-12-08 at 8 52 55 pm

screen shot 2018-12-08 at 9 03 14 pm

Code

const path = require('path')
const express = require('express')
const http = require('http')
const { createEventAdapter } = require('@slack/events-api')
const slackEvents = createEventAdapter(process.env.SLACK_SIGNING_SECRET)

const port = process.env.PORT || 3000

const app = express()
const server = http.createServer(app)

app.use('/slack/events', slackEvents.expressMiddleware())

// Attach listeners to events by Slack Event "type". See: https://api.slack.com/events/message.im
slackEvents.on('message', event => {
  console.log(
    `Received a message event: type: ${event.type}, user ${
      event.user
    } in channel ${event.channel} says ${event.text}`
  )
  if (clients.length > 0) {
    clients.map(clientWs => {
      clientWs.send(
        JSON.stringify({
          channel: event.channel,
          author: event.user,
          text: event.text
        })
      )
    })
  }
})

// *** Handle errors ***
slackEvents.on('error', error => {
  console.error(error)
})


server.listen(port, function(err) {
  if (err) {
    return console.error(err)
  }

  console.log('Listening at port: ', port)
})

Not found in npm

Description

Seems package not published to npm

Bug Report

npm ERR! Darwin 16.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--save" "@slack/events-api"
npm ERR! node v6.6.0
npm ERR! npm v3.10.8
npm ERR! code E404

npm ERR! 404 Not found : @slack/events-api
npm ERR! 404
npm ERR! 404 '@slack/events-api' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

Steps to reproduce:

npm install --save @slack/events-api

Remove System.import() syntax

Description

The latest version of the babel transform can transform the import() syntax just fine.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Slack Node SDK signing verification issue in Proxy environment

Description

Hi Team,
I am building an APP using Node Slack SDK. I am able to authenticate the user by using auth.test URL and also able to post start up message using im.open or chat.postMessage in the slack.

However, in Proxy environment, I am getting the following error. I am not getting the error message in the no-Proxy setup.

{ Error: Slack request signing verification failed
   at verifyRequestSignature (/opt/app-root/src/node_modules/@slack/events-api/dist/http-handler.js:84:18)
   at /opt/app-root/src/node_modules/@slack/events-api/dist/http-handler.js:189:11
   at <anonymous>
   at process._tickCallback (internal/process/next_tick.js:189:7)
 code: 'SLACKHTTPHANDLER_REQUEST_SIGNATURE_VERIFICATION_FAILURE' } 

Slack package details :

"@slack/client": "^4.8.0",
"@slack/events-api": "^2.1.1",
"@slack/interactive-messages": "^1.0.2",

Sample Code:

const { WebClient } = require('@slack/client');
const axios = require('axios');
const r = require('request');
const HttpsProxyAgent = require('https-proxy-agent');
const proxyUrl = `${process.env.proxyUrl}:${process.env.proxyPort}`;
var request = r.defaults({'proxy': proxyUrl});

 web: new WebClient(process.env.SLACK_BOT_TOKEN, { agent: new HttpsProxyAgent(proxyUrl) }),

getAuthorizedUser() {
    const AuthStr = 'Bearer '.concat(process.env.SLACK_CLIENT_TOKEN);
    let options  = {
      url:'https://slack.com/api/auth.test?token='+process.env.SLACK_CLIENT_TOKEN,
      headers:{
        'Content-Type':'application/json',
        'Authorization': AuthStr
      },
      json: true
    }

    var context = this;
    request.get(options, function(err, res, body) {  
        if(err){
          console.log("error in code ::: ", err);
        }        
    })
    .on('data', function(data) {
      var locData = JSON.parse(Buffer.from(data).toString());
      context.approver_user_id = locData.user_id;
      context.decisionseeker = locData.user_id;
      context.adminUser();
    })
}

adminUser() {
    var text = `Welcome to app! I'm here to help your team`;
    
    this.web.im.open({user:this.approver_user_id})
      .then((res) => {
        this.web.chat.postMessage({channel:res.channel.id, text, as_user: true, parse: 'full'})}
      )
      .catch((err) => {
        console.log("admin user error code ::: ", err);
      });
  },

As per the Version 4 guide i am using SLACK_SIGNING_SECRET.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • [x ] question
  • documentation related
  • [x ] testing related
  • [x ] discussion

Requirements (place an x in each of the [ ])

  • [x ] I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • [x ] I've read and agree to the Code of Conduct.
  • [x ] I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

@slack/events-api version: 4.8.0
node version:8.9.4
OS version(s): Windows 10

Steps to reproduce:

Expected result:

What you expected to happen

Actual result:

What actually happened

Attachments:

Logs, screenshots, screencast, sample project, funny gif, etc.

Improve release instructions

Description

There's room for improvement here, just as in slackapi/node-slack-interactive-messages#18.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

waitForResponse option doesn't always work for errors

Description

If the waitForResponse option is enabled and the event handling code throws or has a runtime error, then the adapter will catch it and emit an 'error' event. In this case, that event will only have an argument for the error value. Since the response callback is not given, the http request will hang and time out.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

slack-events version: 1.0.0
node version: 6.x
OS version(s): macOS 10.12.3

Steps to reproduce:

  1. enable waitForResponse option for the SlackEventAdapter.
  2. attach a handler for a Slack event that throws
  3. attach an error handler that accepts an error and a callback argument.
  4. actuate the Slack event.

Expected result:

the callback argument should be a function with signature (error, responseOptions) and upon calling it the response should be sent for the request.

Actual result:

the callback arugument is undefined

Debugging support

Description

Its difficult to understand what is happening at the HTTP level when you run into problems using this module. For instance, I am getting a bunch of retries for events from Slack and I don't understand why. I assume that my application is responding with 200 OKs but I cannot inspect that to make sure.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

errors thrown in handlers without an error handler terminate the process

Description

errors thrown inside handlers when there is no error handler defined should throw (outside the middleware) and terminate the process. see #21 for discussion.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

`verifyRequestSignature` does not create a signature that's the same as slack's

Description

verifyRequestSignature does not seem to be working, maybe doesn't work very well with the body-parser package

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

verifyRequestSignature does not seem to be working, either debug steps should be created or an example snippet. Here is my code:

const { verifyRequestSignature } = require('@slack/events-api');

const { SLACK_SIGNING_SECRET } = require('../config');

const receiveWebhook = (botCtrl) => async (req, res) => {
  const { body } = req;
  const ts = req.headers['x-slack-request-timestamp'];
  const signature = req.headers['x-slack-signature'];

  payload = qs.stringify(body, { format: 'RFC1738' });

  return verifyRequestSignature({
      signingSecret: SLACK_SIGNING_SECRET,
      requestSignature: signature,
      requestTimestamp: ts,
      body: payload,
    });

  // always returns false
}

My node.js express code looks like this:

const bodyParser = require('body-parser');
const compression = require('compression');
const cookieParser = require('cookie-parser');
const cors = require('cors');
const express = require('express');
const methodOverride = require('method-override');
const morgan = require('morgan');
const path = require('path');
const { errorHandler: bodyErrorHandler } = require('bodymen');

const winston = require('./lib/logger');
const { error } = require('./api/responses');

module.exports = (apiRoot, routes) => {
  const app = express();

  app.use(cors());
  app.use(compression());
  app.use(morgan('combined', { stream: winston.stream }));
  app.use(express.static(path.join(__dirname, 'public')));

  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(cookieParser());

  app.use(
    methodOverride((req) => {
      if (req.body && typeof req.body === 'object' && '_method' in req.body) {
        const method = req.body._method;
        delete req.body._method;
        return method;
      }
    }),
  );

  app.get('/favicon.ico', (req, res) => res.sendStatus(204));
  app.use(apiRoot, routes);

  app.use(bodyErrorHandler());

  app.use((req, res, next) => {
    const err = new Error('Not Found');
    err.status = 404;
    next(err);
  });

  app.use((err, req, res, next) => {
    if (err.status) {
      next(err);
    } else {
      console.error(err);
      error(res, err.message);
    }
  });

  return app;
};

Reproducible in:

@slack/events-api version: 2.1.1

node version: v10.12.0

OS version(s): macOS 10.12.6

Steps to reproduce:

  1. Set up Slack Events API, and node.js express server, and entrypoint for slack events http request
  2. Import the verification code above
  3. Install app to your slack workspace
  4. Go to the bot in your slack workspace and send a DM
  5. Look at node.js logs and see it fail to verify the payload

Expected result:

verifyRequestSignature should return true

Actual result:

verifyRequestSignature returns false

Attachments:

None, just code.

TypeScript definitions

Description

Get some typing built into this package.

My 2c is that we should steer away from over-typing the actual events, but we could document at least a couple of "baseline" properties that all events have.

It shouldn't be too hard to describe the actual API of the module though. We should figure out how much JSDoc will do for us since the typescript language service can read JSDoc comments for types now. At this point I don't think there's any need to port to code to .ts, but open to hear feedback on this.

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Add error handler to examples and README

Description

Error handling is a best practice, and the examples should demonstrate that.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

propagateErrors should be mutually exclusive with triggering an error event handler

Description

the propagateErrors option should be mutually exclusive with triggering an error event handler. see #21 for discussion.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Friendly error messages in example app

Description

When running the example app greet-and-react with missing environment variables, users may see quite a nasty error like this:

TypeError: SlackStrategy requires a clientSecret option
10:43 AM
    at new SlackStrategy (/rbd/pnpm-volume/ac2b9b2a-b6f4-455c-ba84-a33b4efcbe69/node_modules/.registry.npmjs.org/@aoberoi/passport-slack/1.0.5/node_modules/@aoberoi/passport-slack/dist/strategy.js:131:13)
10:43 AM
Jump to
at Object.<anonymous> (/app/src/index.js:37:14)
10:43 AM
    at Module._compile (internal/modules/cjs/loader.js:688:30)
10:43 AM
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
10:43 AM
    at Module.load (internal/modules/cjs/loader.js:598:32)
10:43 AM
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
10:43 AM
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
10:43 AM
    at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
10:43 AM
    at startup (internal/bootstrap/node.js:285:19)
10:43 AM
    at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)

This is not very helpful to a new user who is just trying to get things running and hasn't yet followed the next step about setting environment variables. Instead, we should catch the errors from the SlackEventAdapter constructor and the SlackStrategy constructor and output a more friendly error message. The following seems a little more pleasant:

Could not start up the application. Have you set your environment variables correctly yet? See ...

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Error handling patterns

Description

We need to make a decision on the error handling pattern for cases where there are no event handlers attached to the error event. There are a number of variables and cases at play.

Let's consider this case:

slackEvents.on('message', event => event.foo.bar());

The handler throw a TypeError into the middleware, which will attempt to emit an error event on the adapter (slackEvents). Since there is no handler for that event type, the .emit() call will throw in the middleware. Let's take the case where there is no next middleware defined (the default if you are using the all-in-one API). The final handler from Express will respond with a 500 Internal Server Error. Express will also print the stacktrace of the error to stdout. Then, Slack will attempt reties over and over with the same result until the retries are exhausted and eventually your event subscription may be turned off on the Slack app.

This is not ideal because as the app developer, you may or may not have any indication that something is going wrong. You will see the same event hit your server three times, you will not get the result you expect, and you'll wonder what actually happened with the response. If you were listening to the error event, or listening to the proposed retry event, or using the middleware with an express application that had another error handler and chose to use the propagateErrors option, or you used the includeHeaders option and noticed the retry headers; then you would have more information about what is happening.

Another option is to "swallow" the error in the middleware and send a 200 OK response regardless. This would result in the event only showing up at your server once. But this doesn't really help us surface the error.

The EventEmitter (which SlackEventAdapter inherits from) in node core has a convention where if there is no error handler defined, then an error is thrown, with the intention that if it is not caught at the top level scope, you get one final chance to handle it in process's uncaughtException event before terminating the process. Since SlackEventAdapter is an EventEmitter, and that's the only interface a user of the all-in-one API would ever know, this feels like a strong contender for the convention this package should follow. This is at odds with Express' opinion of "keep the server up, just respond with 500 on unhandled errors".


Another distinct question is how propagateErrors should relate to the error handling system. Specifically, if propagateErrors is enabled, and the error is given to the next middleware, should the adapter also emit the error? Given the tricky nature of what happens with emitting an error, it seems simpler if propagating errors is mutually exclusive with handling them on the EventEmitter interface.

OPINIONS PLEASE!

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

npm install fails because of missing dist files

Description

npm install fails because of missing dist files

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

slack-events version: v1.0.0-beta.1
node version: v7
OS version(s): macOS v10.12.2

Steps to reproduce:

  1. npm install --save @slack/events-api@beta

Expected result:

successful installation

Actual result:

ankur:test-node-events-api/ $ npm install --save @slack/events-api@beta
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm ERR! Darwin 16.3.0
npm ERR! argv "/Users/ankur/.nvm/versions/node/v7.2.0/bin/node" "/Users/ankur/.nvm/versions/node/v7.2.0/bin/npm" "install" "--save" "@slack/events-api@beta"
npm ERR! node v7.2.0
npm ERR! npm  v4.0.2
npm ERR! path /Users/ankur/Developer/play/test-node-events-api/node_modules/@slack/events-api/dist/verify.js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod

npm ERR! enoent ENOENT: no such file or directory, chmod '/Users/ankur/Developer/play/test-node-events-api/node_modules/@slack/events-api/dist/verify.js'
npm ERR! enoent ENOENT: no such file or directory, chmod '/Users/ankur/Developer/play/test-node-events-api/node_modules/@slack/events-api/dist/verify.js'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/ankur/Developer/play/test-node-events-api/npm-debug.log

Add node 8 to test matrix

Description

node major version 8 has been released.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

./node_modules/.bin/slack-verify No such file or directory

Description

Thanks for putting this together guys! Can't wait to get this app up and running.

The problem:
In Step 1 of Configuration I run a command like:
./node_modules/.bin/slack-verify --token XXXREDACTEDXXX [--path=/slack/events] [--port=3000]

but get the following error:
-bash: ./node_modules/.bin/slack-verify: No such file or directory

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

slack-events version:
node version: v6.9.2
OS version(s): 10.12.3

Steps to reproduce:

  1. git clone repository to a directory and run npm install --save @slack/events-api
  2. ./node_modules/.bin/slack-verify --token XXXREDACTEDXXX [--path=/slack/events] [--port=3000]

Expected result:

something that wasn't an error

Actual result:

/slack-verify --token XXXREDACTEDXXX [--path=/slack/events] [--port=3000]
-bash: ./node_modules/.bin/slack-verify: No such file or directory

Thanks!

Migrate README examples to later version of JS

Description

This is subjective, but it seems like the best strategy for documenting this module is to use the syntax of JavaScript (ECMAScript) in the earliest release of the active LTS version of node (currently 6.0.0).

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

New project structure: move to monorepo

Description

We've created a discussion around a proposal in slackapi/node-slack-sdk#677 that would affect this package. We would appreciate any feedback you might have about this change in that issue. Thanks!

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Slack Dialog not closing

Description

Describe your issue here.
Im using node-slack-interactive-messages to open a dialog and get some data from the user.
After submit the dialog would not close and I get internal_error.
This is what Im trying in the slackMessages.action

slackMessages.action('create_resource_form_submit', (payload, respond) => {
let errors = {
"errors": [
{
"name": "resource_type",
"error": "Some ERROR"
},
{
"name": "location",
"error": "Some ERROR"
}
]
};
respond(errors)
.then((r)=>{
console.log("Result is " , r);
})
.catch((e)=>{
console.log("ERROR IN REPOND Is " , e);
});
});

I also tried sending an empty response with {status : 200} just to close the dialog,
but got invalid_request_data error.

Can anyone please provide any help on this?

What type of issue is this? (place an x in one of the [ ])

  • [x ] bug
  • enhancement (feature request)
  • [ x] question
  • documentation related
  • testing related
  • discussion

npm ERR! Unexpected end of JSON input while parsing near '..."require-directory":"'

Description

Describe your issue here.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

@slack/events-api version:

node version:

OS version(s):

Steps to reproduce:

Expected result:

What you expected to happen

Actual result:

What actually happened

Attachments:

Logs, screenshots, screencast, sample project, funny gif, etc.

Provide a simpler example that doesn't require OAuth implementation

Description

Now that internal integrations are a part of Slack apps, there is an opportunity to either simplify the greet-and-react example or build another example which has a much simpler implementation. The simplicity would be a result of removing any code related to OAuth and the lookup of tokens for the team.

This would also require revising the blog post where the example is referenced.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Synthetic event types -- event types that are deduced from combinations of event properties

We can infer some missing event types by looking at event.type + event.subtype , e.g.

if (type === 'message') {
  if (subtype === 'message_changed') // message_changed
  else if (! subtype) // message_created
}

Backwards works too -- going from specific to generic, e.g.

if (type === 'reaction_added' || type === 'reaction_removed') // reaction_changed

Would you be willing to add such event types this to this library?

Thanks in advance.

Proxy connection through a gateway

Description

What if we could remove the need for a development proxy (ngrok/localtunnel) by allowing a developer to stand up a gateway service very easily. Then a config flag could be introduced in this module that transparently (without needing any additional code changes) would connect to that gateway using a long-lived connection (such as websocket or HTTP SSE) and receive individual HTTP requests from the gateway. This may ease the use of the Events API substantially by not having to have a sidecar process running while developing. This could be as simple as creating a Heroku Button for deploying the gateway service to Heroku (or other cloud providers).

On the flip side, it introduces some level of non-parity between development and production, which is notoriously a source of bugs in general.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

createServer()'s path option is unused, deprecate?

Description

It seems that we've introduced an issue where the path argument to SlackEventAdapter#createServer() is unused (besides the log messages). This was likely the result of the refactor which made Express no longer required (#59).

It doesn't seem to have created any issues since the behavior is that all incoming requests are valid, regardless of which URL they are sent to. The only point of using path would be to block incoming requests that had a URL that didn't match, and possibly throw some kind of error (or pass it forward in the case of Express middleware - but we don't do this for any existing error).

Given that nobody seems to have complained, and this issue has existed for over 7 months, I don't think there's any demand for new path matching and error handling functionality like this.

Instead, I propose that we deprecate the path argument, and while we're at it, deprecate the expressMiddleware() method. For the latter, it doesn't add any value since it does the exact same thing as requestListener(), but just returns a function with a different arity. Express would be fine with a handler that has no next (an arity of 2), and the only thing we'd lose is the opportunity to forward errors through the middleware chain, something we're not doing at all today.

Deprecation would simply look like logging warnings when those options are used.

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

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.