Slack Events API not sending channel events - slack

I'm working on a Slack application and I need to listen for new messages across channels.
According to the (awful) Slack documentation, I need to use the Events API:
https://api.slack.com/events-api
And the scope I need to listen for channels messages is channels:history
I'm developing the application locally, so ngrock is being used to expose my endpoint to Slack.
So far I can listen to direct messages, so I assume I'm using the Events API correctly.
The problem is only when I want to listen for new messages in channels, I've added the correct scope to the application and the bot is added to the channel, but still, no event is sent to my endpoint.

You need to invite the bot to the channels you want to listen messages for.

I found the solution to my problem.
I forgot to subscribe the app to bot events. I've only added the scopes to the bot.
Subscribing the app to bot events solved the problem.

Related

Can a slack bot join automatically a channel?

I am building a slack application.
I added "incoming-webhook" to oauth scopes that let me choose the channel I want the App to post messages. However unless I ping the app in the channel to add it. I get a "channel not found" error.
Is it possible to add the app to a channel when installing app via oauth ? Without adding it manually by #app-name or /invite app-name ?
When you add an incoming-webhookscope to your app, the option to add a channel during authentication is specific to incoming webhooks not bot messages. So any messages you send via the incoming webhook will send to the channel you selected during authentication. Messages sent via [chat.postMessage][1] will require your bot to be a member of the destination channel, via invite. Incoming webhooks can only be linked to a single channel. You will have to create a new webhook for every channel you want to post to using webhooks. For that reason, I'd recommend using chat.postMessage instead. If you request the chat:write.public scope your bot will be able to post into any public channel without invitation.

Slack app using Bolt. How do I programatically get the incoming webhook url?

I'm building a Slack app using Bolt (currently hosted by Glitch). When a user adds my app to his channel, I want my app to discover the incoming webhook URL so I can send it off to another app which will post information to that URL.
I've tried (as someone suggested) subscribing to the 'member_joined_channel' event, but the event is not driven when the app is added to the channel.

Microsoft Teams Bot not sending message Edit/Delete events to bot messaging endpoint

I set up an app using the App Studio within Teams and enabled a bot.
I set up the Messaging endpoint for the bot and am able to receive message and conversationUpdate events from the Teams client. This all works fine.
However, if I then edit a message in the Teams client, the messaging endpoint does not receive the text of the edited message at the messaging endpoint.
Similarly, if I delete a message, I do not receive an event indicating that a message has been deleted.
I'm wondering:
Is this expected behavior?
Is there somewhere these events have to be configured in order to receive them?
Is there an alternate way to integrate with Teams/BotFramework in order to receive these events?
Thanks!

How to make Slack Bot not respond to all the messages in the private group?

I want my bot to respond only if anyone mentions its name like #mybot.
How to achieve this?
For that you need to use the Events API and subscribe to the event app_metion.
That way your app will receive all message that directly mention your bot with #mybot.
Those messages will be sent as request from Slack to the endpoint provided for receiving events.

How do I receive only the messages that are direct messages to my bot user?

I have successfully setup my slack bot app, have enabled events etc. I want to receive any direct messages that the members of my slack team send to my bot. For this, I have only enabled Bot Events and No Team Events like below
However, I do not get any event on my webhook on this setting.
If I enable message.im event under Team Events, then I start getting events. But then, I get every message that the user (who has installed the app) sends to any other user in the team.
How do I get only the messages that are sent to my bot user?
Update 1
Based on this SO question I created a private channel with the bot user. Even then, the messages in the private channel do not arrive in my webhook with the above event subscriptions.
Update 2
After reinstalling the app, it seems to be working fine. I have only used it for few minutes after the reinstall so far. I will keep posting here how it goes. It would still be interesting to know what went wrong where.
It is normal behavior that your script receives all messages (for every channel your bot is a member of), not only the messages sent directly to your bot. At this time you can not filter further in the event configuration. So you need to filter out any unwanted message in your script handling the event.
See also this answer.

Resources