Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

member_left_channel event not firing #1847

Closed
coleerikson opened this issue May 19, 2023 · 3 comments
Closed

member_left_channel event not firing #1847

coleerikson opened this issue May 19, 2023 · 3 comments
Labels
question M-T: User needs support to use the project

Comments

@coleerikson
Copy link

Sorry if this isn't a proper issue/bug. I'm at a loss.

Reproducible in:

The Slack SDK version

"@slack/bolt": "^3.13.1",

Node.js runtime version

v16.17.1

OS info

ProductName:            macOS
ProductVersion:         13.0
BuildVersion:           22A380
CPU:ARM

Steps to reproduce:

I have a oauth enabled app running and functioning with all other events, message, commands... no problems.

Interestingly, I have the event user_joined_channel implemented and working as expected. However, user_left_channel doesn't seem to work at all.

  1. Both events have identical scopes so I believe that's setup correctly.
  2. I read this shouldn't be an issue but I have ignoreSelf: false set.
  3. Subscribe to bots is setup and expecting user_left_channel, again I have this working with user_joined_channel
  4. Interactivity is_enabled: true
  5. My bot when invited to a channel triggers the user_joined_channel, removing it does nothing.
  6. Adding a 'real' user, same story, triggers the joined event, that user leaving the channel does nothing.
  7. I also implemented the left_channel event, this works! However, the response doesn't give me the user that left the channel. Here's that event cb:
{
type: 'channel_left',
channel: 'C03etc...',
actor_id: 'U99999etc..',
event_ts: '1684999.etc'
}

Expected result:

The callback as outlined in the member_left_channel API docs:
{
"type": "member_left_channel",
"user": "W06GH7XHN",
"channel": "C0698JE0H",
"channel_type": "C",
"team": "T024BE7LD"
}

Actual result:

Nothing. No console logs, no error.

@zimeg zimeg added question M-T: User needs support to use the project and removed untriaged labels May 19, 2023
@zimeg
Copy link
Member

zimeg commented May 19, 2023

Hey @coleerikson, thanks for writing in! 👋

In my testing, the member_joined_channel and member_left_channel events seem to be working fine (example code here), so their might be something unexpected happening in your implementations.

You've already done some solid troubleshooting, but there are a few more things we can check. You're right that the scopes of these two events match for public and private channels, and you've already subscribed to the member_left_channel event, so since member_joined_channel is working fine I'm wondering if you're attaching the member_left_channel event handler to your app instance?

If you could provide a snippet of your handler, I'd be happy to take a look!

You can also check that you're receiving this event (even if you're not handling it) by toggling debug logging for your app. Hopefully, with this enabled, a WebSocket message with event information will be logged to your terminal after you leave a channel. If this isn't happening, you might consider checking the event subscriptions once more.

Let me know if either of these solves the problem! If not, we can look into more ways to troubleshoot this!

@coleerikson
Copy link
Author

coleerikson commented May 20, 2023

Thank you for your response @E-Zim. I have it working. 🙏

App side listeners and events were all good. Identical to your repo example. Thank you for sharing.

Subscription/events/permissions were good too but just as a sanity check I remove/toggled them all off and back on again. (home router style 😎 )

I then saw member_left_channel was firing in the http logs. I console.logged the event param and it worked! 🎉

@ankitshubham97
Copy link

Just writing in case it helps anyone else:
If you try to add a person in a channel where the bot is not already added, the event won't be fired. It started firing when I added the bot to the same channel where the person was later added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question M-T: User needs support to use the project
Projects
None yet
Development

No branches or pull requests

3 participants