bolt-js: app_home_opened event never fires handler

Description

Even after following the proper instructions to enabling App Home, it is impossible to listen to the app_home_opened, and thus not possible to use App Home with Bolt.

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:

key value
package version 1.4.1
node version 10.13.x
OS version(s) ??? containerized Linux

Steps to reproduce:

  1. Create a empty Bolt app;
  2. Set up App Home;
  3. Add a handler to app_home_opened with a simple console.log("Hi");
  4. Access your bot’s home tab.

Optionally, forward your bot through a logger/webhook inspector to see the transactions.

Expected result:

Handler to be fired.

Actual result:

Handler is not fired, despite webhook being called.

Attachments:

I’ve contacted Slack support and they helped debug this issue, See attached text transcript for everything we tested: slack_support_logs.txt

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (4 by maintainers)

Most upvoted comments

I’m afraid you haven’t enabled subscription of app_home_opened events yet.

Enabling App Home doesn’t automatically add app_home_opened subscription at https://api.slack.com/apps/{app id}/event-subscriptions for you.

Screen Shot 2019-11-05 at 12 48 41

I have the same issue now. App home events worked yesterday in my app, but the event doesn’t fire today. I’ve tried both through Socket Mode and through Http (ngrok) and ngrok doesn’t register any incoming traffic and the home page says " This is still a work in progress" - it probably times out after 3 seconds.

It looks like the event is not sent at all. For sanity, I’ve also check if node express app receives something, but no. Any request would show up in ngrok in the first place.

If you need info for debugging, I was expecting “app_home_opened” event sent to “https://df1e-185-186-152-216.eu.ngrok.io/slack/events” endpoint at 2023-01-23 19:47 UTC time.

=====EDIT======= Looks like the root cause was that I was missing “app_home_opened” scope in my Event Subscriptions -> Bot Events ^_^" I’m leaving this comment here, since someone may fall for the same issue.

@kroltan

as many, my end of year schedule is pretty busy

👋 I hope you’re having a wonderful time.

I’d like to suggest two things for this question.

  1. Make sure if your endpoint receives requests from Slack

If you use ngrok, you can check the requests on its screen.

Having the following middleware in your Bolt app also may be helpful to check what requests came in.

app.use(args => {
  console.log(JSON.stringify(args.body, null, 2));
  args.next();
});
  1. Remove ack function call

This is already mentioned above but ack function is not available in Events API listeners. For Events API, Bolt automatically acknowledges requests for you.

Sure! It’s copied straight from the doc example:

app.event("app_home_opened", async ({ context, event, say, ack }) => {
  ack();
  
  // check the message history if there was a prior interaction for this App DM
  const history = await app.client.im.history({
    token: context.botToken,
    channel: event.channel,
    count: 1 // we only need to check if >=1 messages exist
  });

  // if there was no prior interaction (= 0 messages),
  // it's save to send a welcome message
  if (!history.messages.length) {
    say("Hia");
  }
});

But even a simpler one like below is never invoked.

app.event("app_home_opened", async ({ ack }) => {
  ack();
  console.log("Blah");
});