Comments (4)
Hi @t6adev, thanks again. This is because your app subscribes both app_mention and message events. Regardless whether your app subscribes app_mention events, message events delivers all visible message events to your app endpoint. If you want to skip the bot mentioned message events, you can check message.text string if it does not have the mention.
Let me close this issue now, but if you have further to ask, feel free to write in!
from slack-edge.
Ok, thank you.
Since the app.use
(= postAuthorizeMiddleware) runs before handling events, I believe we can mark the mentioned message inside Cloudflare worker's fetch (it's messyπ
)
export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
...
const current = { isAppMention: false };
app.use(async ({ body }) => {
const slackRequestBody = body as SlackRequestBody;
if (slackRequestBody.type === PayloadType.EventsAPI) {
if (slackRequestBody.event?.type === 'app_mention') {
current.isAppMention = true;
}
}
});
...
}
}
Lines 638 to 647 in 2785568
from slack-edge.
Since the fetch handler can be invoked per request, your approach never works as you expect. In other words, your fetch function is always stateless (as long as you don't store the state in a database) so that your message listener never knows the current was set by a different app_mention request.
Alternatively, your message event listener can check if your app's bot user ID is mentioned in the message event. This is not specific to this slack-edge library. When you build a Slack app that subscribes both app_mention and message events, your code is responsible to handle these events.
If you need more assistance this, I am happy to help you in Japanese. Feel free to mention @seratch_ja
(@seratch
for English) on X. Since this is the issue tracker for managing this library's issues (bugs, enhancement ideas), I would like to stop discussing this here. It'd be appreciated if you could understand this.
from slack-edge.
Thank you, I respect your opinion on how you manage this repo. (I also prefer to discuss something on the GitHub discussion page.)
from slack-edge.
Related Issues (17)
- Token rotation HOT 2
- [Discussion] Lazy vs Ack Race Condition HOT 2
- TypeScript usage HOT 2
- Custom Page Redirection After OAuth in SlackOAuthApp HOT 2
- Interactivity routing support HOT 1
- [Deno] Potential type issue with SlackApp's SlackEdgeAppEnv HOT 2
- TypeError in request-verification.js after upgrading from Next.js v13 to v14 with Edge Functions HOT 5
- Customization of the OAuth flow page rendering HOT 3
- Issue running Vercel Edge Functions example from README. SlackApp is not returning challenge from API Verification + More HOT 4
- Unexpected Behavior with SlackOAuthApp's stateStore, onStateValidationError, and callback Functions HOT 1
- removing handlers HOT 7
- Completing the Ack handler of a slash command prematurely terminates the lazy handler HOT 2
- Interruption of Long Responses in Slack App Using Vercel Edge Functions with OpenAI's Chat API HOT 3
- SLACK_BOT_SCOPES and SLACK_USER_SCOPES should not be Env variables HOT 2
- The anyMessage() function is misleading HOT 3
- Question: FileElement Cc vs EmailAddress? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from slack-edge.