question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

help with event listeners (channels and direct message to app or bot)

See original GitHub issue

Description

Hello, I am having trouble with my slack app listening to events. I have this snippet of code:

// Does not work
        this.app.event('message.channels', async ({ event, context }) => {
            console.log('message channels');
        });
       
// This works (simple use case to validate I can listen to messages from channels.)
        this.app.message(RegExp('(.*?)'), async ({ message, say, event, payload }) => {
            console.log('message event');
        });

I double checked and I am subscribed to bot events for message.channels.

I would also like to know how I can subscribe to message.app_home. I am no longer seeing that event as an option inside of the events subscription.

Thanks and sorry if I missed something from the docs.

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

  • bug
  • enhancement (feature request)
  • [ x ] 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:

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.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
roger-kingcommented, Aug 28, 2020

Gotcha! Thanks for answering my questions!

1reaction
seratchcommented, Aug 28, 2020

@roger-king Hi, I do understand this is a bit confusing but the event type in listener registration, it requires event.type in a payload, not the name in the documentation page. 🙇

As an example payload in https://api.slack.com/events/message.channels describes, the event.type for the subscription is "message". Subscribing message.channels in Slack app configuration page and having this.app.event('message', async ({ event, context }) => { in your Bolt app should work for you.

{
    "token": "one-long-verification-token",
    "team_id": "T061EG9R6",
    "api_app_id": "A0PNCHHK2",
    "event": {
        "type": "message",
        "channel": "C024BE91L",
        "user": "U2147483697",
        "text": "Live long and prospect.",
        "ts": "1355517523.000005",
        "event_ts": "1355517523.000005",
        "channel_type": "channel"
    },
    "type": "event_callback",
    "authed_teams": [
        "T061EG9R6"
    ],
    "event_id": "Ev0PV52K21",
    "event_time": 1355517523
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

message event - Slack API
A message is delivered from several sources: ... The channel property is the ID of the channel, private group or DM channel this...
Read more >
Bolt for JavaScript - Slack Platform Developer Tools
To listen to messages that your app has access to receive, you can use the message() method which filters out events that aren't...
Read more >
Java Discord Bot - Event Listeners - YouTube
https://discord.gg/cortexdev Want to Support the Channel ? ... Getting the channel the message was sent in 8:20 Testing the message listener ...
Read more >
Conversation events in your Teams bot - Microsoft Learn
Work with conversation events from your Microsoft Teams bot, channel event updates, team member events, and message reaction events with ...
Read more >
Slack Event Handler - Mango OS Support
This tutorial will cover how to create a slack app, a bot user and install it to your workspace. Mango will utilies the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found