Code Monkey home page Code Monkey logo

node-slack-interactive-messages's Introduction

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

Slack Interactive Messages for Node

Build your Slack Apps with rich and engaging user interactions using block actions, buttons, menus, and dialogs. The package will help you start with sensible and secure defaults.

The adapter gives you a meaningful API to handle actions from all of Slack's interactive message components actions block elements, (buttons, menus, and dialogs). Use it as an independent HTTP server or plug it into an existing server as Express middleware.

This package does not help you compose messages with action blocks, buttons, menus and dialogs to trigger the actions. We recommend using the Block Kit Builder to design interactive Block Kit messages and the Message Builder to design legacy interactive messages. You can send these messages to Slack using the Web API, Incoming Webhooks, and other parts of the platform.

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-interactive-messages's People

Contributors

aoberoi avatar billdybas avatar erwinai avatar hwz avatar mcolyer avatar ntwb avatar roach avatar shaydewael avatar yukimochi 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-slack-interactive-messages's Issues

queue all calls to `respond()` by default

Description

Currently, if you call respond() twice successively, there is no ordering guarantee on how the messages in Slack will update. If this is within an interactive message (button or menu), one call will overwrite the other but its a race condition. If its within a dialog submission (or a button or menu using the replace_original: false argument) then two messages will be created but in an arbitrary order.

The only way to rely on the ordering would be to wait on the first call's HTTP response to complete before sending the second call. This can be done by the developer once the return value of respond() is specified (#37), but its still not intuitive.

We can implement a queue with a max concurrency of 1 in the adapter such that calls to respond() are serially sent to Slack. This would result in more intuitive behavior. One recommendation for implementing this queue is the p-queue package (it's also used in @slack/client).

It may also be useful to add an optional parameter that skips the queue and sends the request as soon as possible.

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.

Support for block actions

Description

With the release of Block Kit, actions embedded in blocks don't quite work with this library.

As a workaround, developers can use a very loose set of matching constraints (such as {}) and get the handler to trigger, but its then up to them to do further matching against the payload.

The payload shape is quite different. This will be tricky to support, and might involve a new method (distinct from .action()) or a breaking change.

A minimal solution would allow for matching on action_id instead of callback_id (since block actions have no callback_id). We should also consider some combination of block_id and action_id. The former can be either explicitly set when creating the message, or generated by Slack, so its not reasonable to require it in the constraints.

The action_id is described as the following:

An identifier for this action. You can use this when you receive an interaction payload to identify the source of the action. Should be unique among all other action_ids used elsewhere by your app.

We need some more clarity about the last statement, because if action_ids are meant to be globally unique, then there's no point in matching against specific ones as a string. At best we can suggest that they all fit a pattern, and then we depend on a RegExp for the constraint.

We would appreciate ideas and discussion regarding the design of this feature.

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.

slackMessages inside or outside slackEvents ?

Description

Hi,
I am using both interactive-messages and events-api in my code. I was wondering what is the best way to organize the listeners. What is the proper way between

slackEvents.on('message', (event) => {
	slackMessages.action('callback_id', (payload) => {
		// ... 
	});
}); 

and

slackMessages.action('callback_id', (payload) => {
	// ... 
});
slackEvents.on('message', (event) => {
	// ... 
});

I may have noticed that on my poor quality development server (localtunnel) the first one works slightly better, but it might be totally unrelated.

Thank you for your input.

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.

Message Actions not propagating because of condition in callback matching

Description

The new recently announced message actions aren't supported https://api.slack.com/actions.

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.

I believe the part that's preventing them from working is the fact that their payloads don't include either actions or submission which fails the validations.

adapter doesn't respond well to Slack. "Darn - that didn't work ..."

I send a message ... i received this as console output.

The user manu in team sibelius pressed the game button. It has the value chess

Excellent! I got the action buttons request back to my app...
But then, no answers in Slack Channel after button pressed.

slackbot [4:06 PM] Only visible to you
Darn – that didn't work. Feel free to give it another go.

My code is here, as in the example.

app.use('/slack/actions', slackMessages.expressMiddleware());
// Attach action handlers
slackMessages.action('welcome_button', (payload) => {
  // The `actions` array contains details about the specific action (button press, menu selection, etc.)
  const action = payload.actions[0];

  // `payload` is JSON that describes an interaction with a message.
  console.log(`The user ${payload.user.name} in team ${payload.team.domain} pressed the ${action.name} button. It has the value ${action.value}`);

  // You should return a JSON object which describes a message to replace the original.
  // Note that the payload contains a copy of the original message (`payload.original_message`).
  let replacement = payload.original_message;
  // Typically, you want to acknowledge the action and remove the interactive elements from the message
  replacement.text = `Welcome ${payload.user.name}`;
  delete replacement.attachments[0].actions;
  return replacement;
});

inspection and removal of action/options handlers

Description

At the moment, there's only API available to add action and options handlers to the adapter. This issue is to track any interest in additional API to read or modify the existing handlers. If you are interested in this feature, please describe how you might use it.

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.

Test coverage goal of 85%

Description

Since the default range for the coverage colors is 70..100; 85 is yellow (halfway from red to green). This issue is to track towards that coverage as a minimum goal.

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.

name or value matching constraints

Description

This issue is to discuss the need for an API to add matchers using the name and value properties of interactive message payloads. Currently, the module only supports matching on callback_id, type, and whether or not its the result of an unfurl. If this is a feature you are interested in, please share how you'd use it.

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 Proxy Issue for signing verification

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
  • [ x] documentation related
  • [ x] testing related
  • [x ] discussion

Requirements

  • [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/client 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.

Document limits to using `respond()`

Description

the total number of times it can be used is 5, and the server is authoritative about that. document what error is expected if the limit is exceeded.

explicitly document that this doesn't interact with other rate limits (Web API, Events API, RTM API).

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.

document release step to build locally before distribution

Description

if you do not build the project before distribution, it will not package the dist directory, and result an an npm package that doesn't work.

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.

Debugging "Parsing request body prohibits request signature verification"

Description

I would like to add interactive messaging to my hubot plugin, but I can't seem to get action handling right. I can create an interactive prompt and I think I'm set up to receive the result (I am receiving something from slack), but the response is consistently throwing Error: Parsing request body prohibits request signature verification, which isn't a particularly descriptive error.

I think I just don't understand the point of that error being thrown - is it encouraging me to write my own middleware? Am I actually parsing the request body somewhere inadvertently? Can I write my own middleware while still taking advantage of this library's verification logic?

Here is a minimal setup for what I'm seeing: I can create an interactive message adapter, receive bot activation hooks and present the user with a message, but the action never fires correctly because expressMiddleware() activates and throws the error.

{ createMessageAdapter } = require '@slack/interactive-messages'
adapter = createMessageAdapter(process.env.SLACK_VERIFICATION_TOKEN)

module.exports = (robot) ->
  # This works fine
  robot.respond /ask me a question/, (context) ->
    context.send(
      "answer yes or no",
      attachments: [{
        text: 'yes or no',
        callback_id: 'yes_or_no',
        actions: [{
          name: 'accept',
          text: 'yes',
          value: 'accept',
          type: 'button',
          style: 'primary'
        },{
          name: 'accept',
          text: 'no',
          value: 'deny',
          type: 'button',
          style: 'danger'
        }]
      }]
    )

  # The expressMiddleware is used and throws an error
  robot.router.use('/slack/actions', adapter.expressMiddleware())
  adapter.action 'yes_or_no', (payload, respond) ->
    # We never get to this point
    console.log(payload)

Does anyone see any obvious issues with this?

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.
    • @ErwinLengkeek mentions the error and says that they fixed it by "Adding the bodyParser to Express after adding the Middleware fixes it", but I'm not using body-parser so I'm not sure if I'm running into the same issue.

Dialog handler must return error array inside object

Description

The Readme indicates that a dialog handler should return an array of errors matching the structure in the API documents, but in fact, the handler must return an object with an errors property which contains the array.

As described in Readme: " Your app returns a list of errors (or a Promise for a list of errors) from the handler. "
which seems to imply:
return [{name:'username', error:'invalid username'}]

However, this is the only way I can get it working:
return {errors: [{name:'username', error:'invalid username'}]}

I'm not sure if this is an error in the documentation or the implementation.

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/interactive-messages version: 1.0.2
node version: 8.12
OS version(s): macOS 10.14.2

Steps to reproduce:

  1. return an array from dialog action handler

Expected result:

Dialog displays errors from array on form fields.

Actual result:

Dialog displays "We had some trouble connecting" error, with "Retry" option.

Attachments:

ngrok response log when returning array:

`HTTP/1.1 200 OK
X-Powered-By: Express
X-Slack-Powered-By: @slack:interactive-messages/1.0.2 darwin/18.2.0 node/8.12.0
Content-Type: application/json
Date: Wed, 09 Jan 2019 18:31:02 GMT
Connection: keep-alive
Content-Length: 139

[{"name":"duration","error":"Duration must be greater than 0 hours"}]`

ngrok response log when returning object with array property:
`HTTP/1.1 200 OK
X-Powered-By: Express
X-Slack-Powered-By: @slack:interactive-messages/1.0.2 darwin/18.2.0 node/8.12.0
Content-Type: application/json
Date: Wed, 09 Jan 2019 18:33:13 GMT
Connection: keep-alive
Content-Length: 150

{"errors":[{"name":"duration","error":"Duration must be greater than 0 hours"}]}`

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/interactive-messages. 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.

Unable to start server locally

Description

Running npm start locally is giving TypeError

/Users/smalugu/code/exp/node-slack-interactive-messages/examples/express-all-interactions/node_modules/@slack/interactive-messages/dist/adapter.js:200
throw error;
^

TypeError: Type must be 'select' or 'button'
at validateActionConstraints (/Users/smalugu/code/exp/node-slack-interactive-messages/examples/express-all-interactions/node_modules/@slack/interactive-messages/dist/adapter.js:87:12)

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

Requirements

  • [ 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/interactive-messages version:
node version:
OS version(s):8.1.2

Steps to reproduce:

1.Clone the repo
2.npm install
3.set the env variables as the docs
4.npm start

Expected result:

server listening on port message

Actual result:

Error message /Users/smalugu/code/exp/node-slack-interactive-messages/examples/express-all-interactions/node_modules/@slack/interactive-messages/dist/adapter.js:200
throw error;
^

TypeError: Type must be 'select' or 'button'
at validateActionConstraints (/Users/smalugu/code/exp/node-slack-interactive-messages/examples/express-all-interactions/node_modules/@slack/interactive-messages/dist/adapter.js:87:12)

Attachments:

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

respond not working for interactive message options / typeahead

Description

I'm having troubles using typeahead / interactive message options with asynchronously loaded options

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

In the readme

slackMessages.options('my_dynamic_menu_callback', (selection, respond) => {
  // You may return options synchronously or use the respond() argument to send them asynchronously
  typeaheadLookup(selection.value)
    .then(formatMatchesAsOptions)
    .then(respond)
    .catch((error) => ({ options: [ { text: `Error: ${error.message}`, value: 'error' } ] }));
});

Now when I make a synchronous response

const simpleAnswer = () => ({ options: [{value: "ok", text: "sniff"}] });
slackMessages.options('my_dynamic_menu_callback', (selection, respond) => {
  return(simpleAnswer())
}

It works perfectly, however I'm not sure how to return a Promise / use respond() to do the same thing

I've tried the following

slackMessages.options('my_dynamic_menu_callback', (selection, respond) => {
  respond(simpleAnswer())
  // or
  new Promise( (resolve, reject) => resolve(simpleAnswer()) ).then(respond)
  // or
  return respond(simpleAnswer())
  // or
  return new Promise( (resolve, reject) => resolve(simpleAnswer()) )
}

to no avail. Is the promise/respond system really working ???

Reproducible in:

@slack/interactive-messages version: "^0.2.0"
node version: v9.5.0
OS version(s): macOS high sierra

helper function to remove interactive elements from an original_message

Description

The recommended practice is to return a message replacement that removes the interactive elements (doesn't apply to every use case, but the majority). We can export a function that given a message, does this for the user.

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 open the Slack dialog

Description

Hi Ankur,

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.

Post signing, I need to open the dialog. It was working fine for the earlier version of Slack Node SDK but after upgrading the Slack Node SDK version, the same is not working.

Please help me in resolving the same. The below code supposed to open a Slack dialog. I am unable to see any error in the console while executing the code

Slack package details : ( Recently upgraded @slack/client 4.8.0 from 3.9.0 and the similar up-gradation for other packages as well )

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

Sample Code:


web: new WebClient(process.env.SLACK_BOT_TOKEN);

const dialogForm = this.getDialog();

openDialog(triggerId, dialogForm) {
	console.log('openDialog::', triggerId);
	const dialog = JSON.stringify(dialogForm);
	this.web.dialog.open(dialog, triggerId).then((res) => {
		if (res.status === 200 && res.data.ok) {
			return Promise.resolve('Successfully posted the dialog');
		}
		return Promise.resolve('Dialog could not be opened');
	}).catch((error) => console.log("Error :: ", error));
}


getDialog(callbackId, title = '', details = '', priority) {

	return {
		title: 'Header',
		callback_id: callbackId,
		submit_label: 'Request',
		elements: [
			{
				label: 'Title',
				type: 'text',
				name: 'title',
				value: title,
				placeholder: 'Summary of the request'
			},
			{
				label: dvPriority,
				type: 'select',
				name: 'priority',
				value: priority,
				options: [
					{ label: 'Low', value: 'Low' },
					{ label: 'Medium', value: 'Medium' },
					{ label: 'High', value: 'High' },
				],
			},
			{
				label: 'Description',
				type: 'textarea',
				name: 'details',
				value: details,
				optional: true,
			},
		],
	};
}

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

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

Requirements

  • [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/client 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.

Example app Glitch instructions, not great

Description

  1. The SLACK_ACCESS_TOKEN variable is only available after install, but if you try to install the app in the order the instructions are presented, it will fail and say you need to add at least one scope.

  2. In enabling interactive components, where do I get the "Glitch URL"? Its in the "Share" menu, but it would be nice to be explicit. Maybe give an example.

  3. Where do I put the environment variables? If you know Glitch, you'll know its in 🗝.env, but many users don't know Glitch. Also, if you're running locally, its not clear that you can put this in .env.

  4. You need a description for the slash command.

  5. PORT needs to be commented out in .env

  6. In package.json, @slack/interactive-messages dependency version specifier should be set to "^0.3.0"

Maybe there should be 2 completely different sets of instructions for setup locally and on Glitch.

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.

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.

reference documentation

Description

Add reference docs to the repository. Preferably generated from the source.

The following can then be put in the README:

Documentation

To learn more, see the reference documentation.

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.

Allow RegExp callback_id constraint matches to expose match results

Description

If the adapter is going to use a RegExp to match against the callback_id, it would be useful to be able to pick out the parts in a capture group so you don't have to once again parse the callback_id inside the handler.

This would probably look like:

  • Change the matching implementation from using RegExp.test() to RegExp.exec()
  • Expose the return value to the handler function, somehow. Ideas:
  • as another argument to the handler, handler(payload, respond, matches) where matches is the value
  • inside an ext property of payload, so that in the future there is a dedicated namespace for new types of data to be exposed to the handler from. so, for example, you might find these results in payload.ext.callbackIdMatches.

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.

Payload type is "interactive_message"

Description

I've had my slack app working fine for some time, but for the past few days, it hasn't been responding to button presses. I've finally narrowed it down to the fact that the request payload type is interactive_message, which is odd because as per the documentation, the only possible values are button, select, or dialog_submission

What type of issue is this?

  • 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/interactive-messages version: ^1.0.0
node version: 8.11.2
OS version(s): Linux

Steps to reproduce:

Expected result:

What you expected to happen

Actual result:

What actually happened

Attachments:

Create the message:

/*  Send initial message  */
  function openIM(userID) {
    web.im
      .open({ user: userID })
      .then(openResp => {
        const userChannel = openResp.channel.id; //Without this, messages would come from the slackbot channel
        console.info("Starting conversation");
        web.chat.postMessage({
          channel: userChannel,
          text: messages[msgID].message.text,
          attachments: messages[msgID].message.attachments
        });
      })
      .catch(err => {
        console.error(err.message);
      });
  }

Button Handler:

slackInteractions.action(/button_/, (payload, respond) => {
  console.log("Button Pressed\n" + JSON.stringify(payload, null, 2));

Abridged Console Output:

   2018-10-04T16:16:25.65-0700 [APP/PROC/WEB/0] OUT Button Pressed
   2018-10-04T16:16:25.65-0700 [APP/PROC/WEB/0] OUT {
   2018-10-04T16:16:25.65-0700 [APP/PROC/WEB/0] OUT   "type": "interactive_message",
   2018-10-04T16:16:25.65-0700 [APP/PROC/WEB/0] OUT   "actions": [
   2018-10-04T16:16:25.65-0700 [APP/PROC/WEB/0] OUT     {
   2018-10-04T16:16:25.65-0700 [APP/PROC/WEB/0] OUT       "name": " recieve-micro-lesson",
   2018-10-04T16:16:25.65-0700 [APP/PROC/WEB/0] OUT       "type": "button",
   2018-10-04T16:16:25.65-0700 [APP/PROC/WEB/0] OUT       "value": "yes"
   2018-10-04T16:16:25.65-0700 [APP/PROC/WEB/0] OUT     }
   2018-10-04T16:16:25.65-0700 [APP/PROC/WEB/0] OUT   ],

Original Message:

{
      "text": "Great!\nEngage@IBM has a playlist of micro lessons and learning nudges for you.",
      "response_type": "in_channel",
      "attachments": [
        {
          "fallback": "Pre-filled because you have actions in your attachment.",
          "color": "#0062ff",
          "mrkdwn_in": ["text", "pretext", "fields"],
          "callback_id": "button_002",
          "attachment_type": "default",
          "text": "*Would you like to receive one now?*",
          "actions": [
            {
              "name": " recieve-micro-lesson",
              "text": " Yes",
              "type": "button",
              "style": "primary",
              "value": "yes"
            },
            {
              "name": "recieve-micro-lesson",
              "text": "Remind me later",
              "type": "button",
              "style": "default",
              "value": "no"
            }
          ]
        }
      ]
    }

I'm not entirely sure how to narrow it down to a reproducible code sample, so I wanted to give you enough information that hopefully you could find something. If interested, I could provide a sample repo. Let me know if there's any additional information I can provide that would be helpful.

Add CI and coverage tools to README

Description

The Travis and CodeCov badges are missing

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.

express-all-interactions example uses old (and undefined) verification token

Description

The express-all-interactions example has mostly switched to using the signing secret for validating requests from Slack. However, the endpoint for the slash commands (function slackSlashCommand of server.js) still uses the undefined constant slackVerificationToken which does not exist anywhere else in the code, which is a bug. It is also not obvious how the slash command endpoint should use the signing secret to validate the request.

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

  • bug

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

The file in question is examples/express-all-interactions/server.js, and more specifically line 217, where slackVerificationToken is used.

Expected result:

Some example code for doing request verification for slash command endpoints would be nice, since it is currently not obvious how this is done. If a body-parser such as the urlencode-parser is used, the req.body property will not be the raw body which is required in the HMAC-calculations.

On the other hand, if a raw-body parser is used, the parsing must be done manually which is cumbersome. Perhaps some convenience middleware performing both validation and parsing could be exported from @slack/interactive-messages or @slack/events-api since the validation is done internally already, just not for slash command endpoints.

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.

Dialog submissions requests always time-out resulting in the dialog modal not closing and a user-facing error

Description

Dialog submissions request time-out with the adapter.

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

Adapter is not falling back to responding with a 200 OK to Dialog Submissions request when not provided with a response in less than 3 seconds — which results in a We had some trouble connection. Try again? user-facing error.

Sending a blank return('') has the same result.

Responding asynchronously using the respond() handler function results in a Error: Request failed with status code 400 and the same user-facing error.

Reproducible in:

@slack/interactive-messages version: 0.20
node version: 9.8.0
OS [version(s):] Mac OS High Sierra

Steps to reproduce:

Respond to a dialog submission with the following action handler

slackMessages.action('<callback_id>', (payload, respond) => {
  // grab user answer from payload
  respond  {}
});

or

slackMessages.action('<callback_id>', (payload) => {
  // grab user answer from payload
});

or

slackMessages.action('<callback_id>', (payload) => {
  // grab user answer from payload
return('');
});

Expected result:

Dialog should close and the action should execute

Actual result:

The action executes but the dialog does not close and results in a user-facing error

Attachments:

screen shot 2018-04-03 at 16 16 36

README has copy/paste errors from @slack/events-api

Description

This README module's was heavily borrowed from @slack/events-api. Some remnants of it still remain in the code examples. Remove 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.

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.

Document respond() response and improve description of the method

Description

In README.md, the async section describes the use of the respond() argument of an .action(). The respond function can be used to get a promise from the API that will resolve with the results of updating the message. However, this promise result behavior is not documented.

In addition, the docs could be clearer about what the respond function does exactly - it says it's "so you can update the message asynchronously" but this could be clearer. I recommend a sentence or two like this (if in fact this is correct - this is my understanding of what the docs say)

Calling the respond() function replaces the message that triggered the action with the replacement provided as the argument. It can be called multiple times as needed to update the message as an asynchronous process develops or if an error is encountered.

  • Add docs for what is returned by the respond method
  • Considerer clearer wording of how to use the respond method
  • Add an example of adding a .then() to the respond method's promise to do things like dealing with a 429 too many requests error or other specific sending errors that Slack might respond with.

For reference, see this question in #slack-api: https://dev4slack.slack.com/archives/C0K8617D5/p1523984611000173

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.

500 Error when interacting with messages

Description

I am currently getting a "500_Service_Error" in slack whenever I respond to an interactive message.

I have checked my slack node service, and there does not seem to be any error. My interactive messages are being received by the service and my service is then updating the original message and sending that response back to my slack channel. All of this works as expected, however, I am getting an additional message that states:

"Darn - that didn't work (error message: 500_service_error). Manage the app at {app name}.

What could possibly cause this problem?

  • 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.

Make respond() function wait until next tick before sending request

Description

Inspired by #68.

Users of this package have the ability to call respond() inside a handler before the handler function has returned. That means that someone may accidentally try updating an interactive message before the interactive message has even been acknowledged (because the handler returning is the signal that we can respond with 200 OK). If the respond() function waited until the next tick to do any work, then the handler function's return would always be before the request to the response_url, and it would prevent these types of issues.

Disclaimer: we're still not sure this was the actual problem with the issue mentioned above.

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.

shasum error

Description

Describe your issue here.

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

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

Requirements

  • [ 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

I am unable to install the packages in the install command due to a shasum error. I am unsure if this is an issue with my setup of npm/node but other packages do install with out any issues. Both Express and Body-parser were installed successfully when the commands were run individually.

Reproducible in:

@slack/interactive-messages version: -
node version: 4.2.6
OS version(s): ubuntu 16.04 LTS

Steps to reproduce:

  1. run 'npm install --save @slack/interactive-messages' or 'npm install --save @slack/interactive-messages express body-parser'

Expected result:

expected to have the packages installed, all smooth like ;)

Actual result:

Linux 4.13.4-041304-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "--save" "@slack/interactive-messages"
npm ERR! node v4.2.6
npm ERR! npm v3.5.2

npm ERR! shasum check failed for /tmp/npm-14277-af63f609/registry.npmjs.org/_40slack/interactive-messages/-/interactive-messages-0.3.0.tgz
npm ERR! Expected: f83c0f7ceff699dd2916a84e8dcef3dedc092df0
npm ERR! Actual: 3c65d4dd6a4fe2dac530a9644528e979d1457bbb
npm ERR! From: https://registry.npmjs.org/@slack/interactive-messages/-/interactive-messages-0.3.0.tgz
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! https://github.com/npm/npm/issues

npm ERR! Please include the following file with any support request:
npm ERR! /home/digital/Documents/projects/Livebot/npm-debug.log
➜ Livebot git:(master) ✗ npm install --save @slack/interactive-messages express body-parser
npm ERR! Linux 4.13.4-041304-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "--save" "@slack/interactive-messages" "express" "body-parser"
npm ERR! node v4.2.6
npm ERR! npm v3.5.2

npm ERR! shasum check failed for /tmp/npm-14636-8ca8c97f/registry.npmjs.org/_40slack/interactive-messages/-/interactive-messages-0.3.0.tgz
npm ERR! Expected: f83c0f7ceff699dd2916a84e8dcef3dedc092df0
npm ERR! Actual: a563d3758e3e1c0beff3b7a6a2878a2c30797386
npm ERR! From: https://registry.npmjs.org/@slack/interactive-messages/-/interactive-messages-0.3.0.tgz
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! https://github.com/npm/npm/issues

npm ERR! Please include the following file with any support request:
npm ERR! /home/digital/Documents/projects/Livebot/npm-debug.log

Attachments:

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

For each type of request, what are acceptable return vals for callback and args for respond

Description

It's not clear on which types of requests, which values can be returned in the callback and/or passed to the respond() function. I've started to build a table to at least describe the current state of things. This has led to uncovering some behaviors that I think are bugs or unintended, but at least we should describe them.


Type of Request cb(): Message cb(): Promise<Message> respond(m: Message) respond(m: Promise<Message>) Notes
Message Action (Button, Select) incl. embeded in App Unfurl synchronous response if resolved under timeout, synchronous response; else response_url request response_url request (can be used several times) error: axios will likely throw
Dialog Submission synchronous response synchronous response response_url request (can be used several times) - not a replacement, used as follow up error: axios will likely throw A warning is logged if the synchronous response takes longer than the timeout
Menu Options synchronous response synchronous response - - A warning is logged if the synchronous response takes longer than the timeout

Edit: updated according to changes in #28

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.

Interactive Message Filtering Bricked in Latest Update

Description

Describe your issue here.

  • [X ] bug
  • [X ] question

Bug Report

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

Steps to reproduce:

  1. Use block kit found here
  2. Send to interactive message app
  3. Middleware can't filter properly for this message

slackInteractions.action({'action_id': "escalation_response"}, escalationResponseHandler)

Expected result:

I expect middleware to be able to detect it when I use action id as a filter. The version from to 1.1.0 did that successfully. This version does not.

Actual result:

What actually happened, middleware skips this.

Request:

  1. How do I fix my middleware to be able to listen to the messages I have in the block kit?
  2. How do I set up a catch all filter so I can record all unrelated events?
  3. Could the slack team add me to the slack team where I Can message them directly please? Customer support was not helpful.

Export a function to verify request signatures

Description

It would be useful to expose a function that verifies request signatures, even when not using the request handler. This functionality would duplicate the work in
slackapi/node-slack-events-api#70. We could implement this by extracting that into a shared dependency of both of these packages, but that’s not required.

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

Make dispatch async

Description

This is the result of the discussion (heh) in #30.

Adjust the SlackMessageAdapter#dispatch() method's signature to the following:

dispatch(payload): Promise<{ status: number, content: any }> | undefined

Arguments

  • payload: the JSON-parsed payload in the body of the incoming request. the verification token should already have been verified.

Return value: When the request was matched by the adapter's callbacks a Promise is returned, otherwise undefined is returned. The Promise will resolve to an object with two properties: status and content.

  • status: the status code for the response to the incoming request
  • content: an object which can be JSON serialized into a application/json body of the response

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.

Should adapter.dispatch() be async?

Description

pro:

  • simplifies the caller's work. currently the return value of dispatch always needs to be inspected for if the content contains a promise or not, and then the promise needs to be resolved/rejected before continuing. the fact of the matter is the implementation always returns a Promise, so there's very limited benefit of a synchronous response. current callers whose work would be simplified include the express middleware and the tests. in the future if any other server interfaces were supported, those would also be simplified.

con:

  • delays the signal back to the server interface that a request was indeed matched to a callback, which can potentially delay any further processing by "next" middleware we could return a Promise right away, the resolution/rejection would come later.
  • currently the response status is available synchronously, which could be used without having the whole body. the timing of the response is all currently controlled by the adapter, and there's no possibility of a streaming response, so it seems a little futile to send a status code before the rest of the response.

we want to sort this out before any additional server interfaces are created (in addition to adapter.expressMiddleware().

a proposed interface using typescript syntax for illustration:

interface JSONObject {}; // what you might expect

interface DispatchResult {
  status: number;
  content?: string | JSONObject;
};

// if this function returns undefined, then there was no matching callback and the server should proceed to another handler
adapter.dispatch(payload: JSONObject): Promise<DispatchResult>?;

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.

Button presses handler never gets triggered

Description

Hello! As the title suggests, I'm having a hard time making it work. I have this code:

This servers as a '/slack' path router, where I would like your package to take care of the interactive route.

...
const router = Express.Router()

router.use(bodyParser.json())
router.use(bodyParser.urlencoded({ extended: true }))

router.get('/oauth/login', oauth.login)
router.get('/oauth/callback', oauth.callback)

router.use('/interactive', interactionsAdapter)

export default router
...
...
app.use('/slack', slackRouter)
...

The interactions adapter looks like follow:

import { createMessageAdapter } from '@slack/interactive-messages'

// Create the adapter using the app's signing secret, read from environment variable
const slackInteractions = createMessageAdapter(process.env.SLACK_CLIENT_SECRET)

slackInteractions.action({ type: 'button' }, (payload, respond) => {
  console.log(payload)

  const reply = payload.original_message
  return reply
})

// Attach the adapter to the Express application as a middleware
// NOTE: The path must match the Request URL and/or Options URL configured in Slack
export default slackInteractions.expressMiddleware()

But no matter what I type into the .action parameters, the function never gets triggered with the press of the button. I tried setting up callback_ids and other filters described in the situation, but it still never gets run. I'm not that experienced developer, so the error is most likely on my side, but I'm not sure where to look.

I've double checked what I'm getting from the slack servers and everything seems to be ok.

Thank you

EDIT:

When running the whole thing with ngrok, it is giving me errors like POST /slack/interactive 500 Internal Server Error but the express application itself is not printing out anything.

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 repo shows 0.1.1 while build here is 0.1.0

Description

I not able to use the NPM repository. NPM is not able to find the 0.1.1 version. I had to build this 0.1.0 version from source and link it that way.

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

  • [x ] 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

Actual result:

What actually happened

Attachments:

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

Reference docs improvements

Description

Capturing some of the shortcomings of the reference docs:

  • @external reference links do not render. should probably file a bug with jsdoc2md/jsdoc-to-markdown.
  • no output for @enum members, specifically errorCodes in index.js

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.

all respond messages treated string (not message object).

Description

In v1.0.0
All respond messages treated string (not message object).
So, serialized json shown in slack as is.

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/interactive-messages version:v1.0.0
node version:v10.9.0
OS version(s):Heroku

Steps to reproduce:

1.receive some interaction.(slackInteractions.action('some_action', (payload, respond) => {})
2.return message object (payload.original_message) as pending message.
3.shown serialized json in slack screen.

Expected result:

Show complete message in slack screen.

Actual result:

Show serialized json text in slack screen.

Attachments:

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

Plain request listener server interface (remove express and body-parser dep)

Description

implement a server interface (like expressMiddleware()) called requestListener() to handling incoming HTTP requests and outgoing HTTP responses by invoking adapter.dispatch() accordingly.

the main advantage is that this would plug into any instance of node's http.Server as the request listener function. it would also have no dependencies on middleware like body-parser or packages like express.

its possible that express-middleware.js could be rewritten to utilize this request listener, and then it too would have no dependency on body-parser. however this might not be desirable if you're integrating into an existing express application where some earlier middleware is doing body parsing with more content types.

the only part of body-parser that is used is the urlencoded piece. its also only used with the option extended: false, which means its just using the built-in querystring module. depending on if incoming messages from slack use gzip or not, we may need to implement inflating of deflated bodies (relatively easy to do with built-in zlib). the remaining options are not useful in this context.

response serialization is always always a basic string or JSON, which are easy to implement using built-ins and the raw server response API.

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.

RegEx constraint matching is broken

Description

coming from @hwz:

I dont think the regex matching for the events api adapter works

I’m getting TypeError: constraints.callbackId.text is not a function errors for adapter.js

it looks like a simple typo on L193: text() -> test()

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.1
node version: all
OS version(s): all

Steps to reproduce:

  1. add an action with a RegEx for callbackId
  2. trigger the action

Expected result:

action callback is called

Actual result:

TypeError is thrown

add debugging docs

Description

some of the time limit issues are only visible to the developer if they know how to turn on debugging. we should document how a developer might do that.

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.

Defining a message handler in a module

Description

I've followed the Express All Interactions Example and it defines all interactive message handlers inside server.js, which is fine for a small project, but I'm trying to understand how best to define message handlers for use in a large project composed of many different modules.

For example, say I have a project module, and I want this to contain the logic for an updateProject action. I've been able to do this using the following structure:

// server.js
const project = require('./path/to/project')
const slackInteractions = createMessageAdapter(process.env.SLACK_VERIFICATION_TOKEN);
app.use('/slack/actions', slackInteractions.expressMiddleware());
project.initInteractionHandlers(slackInteractions)

// project.js
module.exports.initInteractionHandlers = function(slackInteractions) {
  slackInteractions.action('updateProject', (payload, respond) => {
    console.log(`The user ${payload.user.name} in team ${payload.team.domain} submitted a dialog`);
  }
}

The above example works, but I'm not sure if this is the correct way to handle this. Can someone please let me know if I'm on the right track, or if there's a better way to handle it?

Ideally, it would be great to have another example added to the Express All Interactions Example to show exactly how to define a handler outside of server.js. Thanks!

What type of issue is this?

  • question

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.

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.