Create a Hubot robot.respond() equivalent middleware
See original GitHub issueDescription
I’ve been playing around with Bolt to replace Botkit and I’m having some trouble getting directMention to work for messages sent in direct message to the bot. Code snippet and debug logs below.
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:
package version: 1.5.0
node version: 12.14.1
OS version(s): Windows 10
Steps to reproduce:
- See code snippet below
Expected result:
A channel of the type “im” should be considered a directMention.
Actual result:
app.message never executes if directMention is used.
Attachments:
app.js
const { App, directMention, LogLevel } = require('@slack/bolt');
// Initializes your app with your bot token and signing secret
const app = new App({
token: process.env.SLACK_BOT_TOKEN,
signingSecret: process.env.SLACK_SIGNING_SECRET,
logLevel: LogLevel.DEBUG
});
function logPayload({payload, next}) {
console.log(
`Inside logPayload
Type: ${payload.type}, Text: ${payload.text}, Channel Type: ${payload.channel_type}`
);
next()
}
app.use(logPayload);
(async () => {
// Start your app
await app.start(process.env.PORT || 3001);
console.log('⚡️ Bolt app is running!');
})();
app.message(directMention(), 'howdy', ({ message, say }) => {
console.log(
`Inside howdy
Type: ${message.type}, Text: ${message.text}, Channel Type: ${message.channel_type}`
);
say('Howdy back');
});
Debug logs with results from above.
[DEBUG] The logLevel given to WebClient was ignored as you also gave logger
[DEBUG] initialized
[DEBUG] apiCall('auth.test') start
[DEBUG] will perform http request
⚡️ Bolt app is running!
[DEBUG] http response received
[DEBUG] Conversation context not loaded: Conversation not found
Inside logPayload
Type: message, Text: howdy, Channel Type: im
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Create a Hubot robot.respond() equivalent middleware #389
Description I've been playing around with Bolt to replace Botkit and I'm having some trouble getting directMention to work for messages sent ...
Read more >Scripting | HUBOT - GitHub
Response middleware runs for every response sent to a message. Execution Process and API. Similar to Express middleware, Hubot executes middleware in definition ......
Read more >Patterns - Hubot - GitHub
Deprecating or Renaming Listeners · Create a bundled script in the scripts/ directory of your Hubot instance called deprecations.coffee · Copy any old...
Read more >v2.19.0 (2016-05-0-6) | HUBOT
Allow robot.respond to work when there is preceding whitespace; Update robot.parseHelp to be synchronous, so it's easier to test; Reduce Heroku ping ...
Read more >Implementation Notes | HUBOT - GitHub
middleware.execute next returns to listener.call , which executes the matched Listener's callback and then calls the robot.receive callback.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Digressing to the original ask (instead of creating a separate issue): In Hubot, I could use
robot.respond()
and it would do two things:Since directMention requires an @mention (regardless of the conversation type), I think a nice enhancement here would be for either a new middleware to act like this, or an update to directMention() that will handle both. That way, developers can easily create something that doesn’t require users to @mention the bot within a DM (which is somewhat redundant)
@jacklein Let me answer on behalf of him. Unfortunately, the Slack team doesn’t have plans to offer a similar ability for private channels and DMs at the moment. As I guided at #401, your feedback from the Help Center would be greatly appreciated.