bolt-js icon indicating copy to clipboard operation
bolt-js copied to clipboard

Introduce "mention()" middleware for catching all mentions in messages

Open seratch opened this issue 4 years ago • 2 comments

Description

directMention() middleware matches only when a bot user is mentioned as the first person in a message. This is because the middleware was designed to be compatible with Hubot's robot.respond() functionality.

Also, Slapp (the ancestor of Bolt for JS) defines "direct mention" as being mentioned at the start of a message while "mention" means being mentioned anywhere in a message.

With full respect for the original meaning of "direct mention" in Slapp, I propose to add built-in mention() middleware to Bolt for JS. I'll be working on this sometime soon, but if anyone is interested in implementing this, any contribution is welcome!

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

  • [ ] bug
  • [x] enhancement (feature request)
  • [ ] question
  • [ ] documentation related
  • [ ] 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.

seratch avatar Sep 04 '20 06:09 seratch

@seratch I don't see how to use directMention() in the documentation, do you have an example somewhere?

captDaylight avatar Jun 18 '21 15:06 captDaylight

@captDaylight You can use it this way:

const { App, directMention } = require("@slack/bolt");
const app = new App();
app.message(directMention(), "hello", async ({}) => {

});

seratch avatar Jun 19 '21 00:06 seratch