Slack "New Event" setup. How to check new messages in private channel?

Here are the steps I went through

Step 1: we create the App in Slack (Slack API: Applications | Slack)
In our context, Oauth2 is not really needed unless we want connect to Slack from Make to send messages as a user or as a bot, or to do any other action.
I added the redirect urls for User and Bot connections in case we need it later, but it’s not mandatory if we only want to subscribe to events.
Redirect URLs I used:
https://www.integromat.com/oauth/cb/slack2
https://www.integromat.com/oauth/cb/slack3

Step 2: In Make we create a new Custom Webhook, and we copy its URL
This step is classic, it allows us to generate the URL we need in the Slack App

Step 3: We configure the Event Subscription in Slack (part1)
See the recording and see my explanation below


We have copied the URL of the Webhook, and we enabled Event Subscriptions in the Slack App
You notice that when we added the url of the webhook, it failed. It’s because Slack expects a response from the webhook during configuration. I show the documentation. It expects the webhook scenario to return the challenge. It’s next step below :blush:

Step 4: We continue to configure the Event Subscription in Slack (part2)


As you see, since the scenario was off, the message is still in the queue, so we run the scenario; it will help us see the structure of the data sent by Slack for testing.
We add a webhook response with relevant body and header, and we run the scenario. Then in Slack we retry => passed!!

Step 5: We continue to configure the Event Subscription in Slack (part3)


This part is key. You can see there are 2 types:

  • Bots event
  • On behalf of users
    I configured only for Bot, but you can use any of the 2, for any type of event, it’s just amazing!
    I don’t know everything about the behaviour for other events, but for the one I chose “Message.groups”, here is the behaviour according to the type you choose:
  • Bots Event (the one I chose in the video): Only the Private Channels where the Slack App is invited will be monitored!
  • On behalf of users
    I’m not completely sure it works everywhere, but so far, all my private channels were monitored, I didn’t need to invite the Slack App
    IMHO, Bot event is better in that case. We’ll see later how to invite the App to a private channel.

Step 6: Deploy the Slack App in the Slack Workspace

Step 7: Invite the Slack app to any Private Channel we want to monitor

Step 8: adapt the webhook scenario and test

TADAAAAAAAA!!!
As you can see, we no longer need the Webhook Response since it was used during configuration.
And we had a message in the queue => This is important, you will also receive notifications when the Slack App is invited or removed to/from a Private Channel. Can be useful when you want to prepare some database for instance

Voilà, I hope it was clear. Please give it a try, and let me know the outcome.

Have fun!

Benjamin

8 Likes