0

I've been following tutorials with no experience, and am stuck in making a Slack Bot. My goal is to create a Slack Bot that listens to every message sent within a channel in my workspace, and to detect/ delete any messages that have swearing or profanity in the text. So far I created an app that's running on socket mode, I enabled Events Subscription and assigned all permissions needed (chat.read, chat.write, chat.delete, ect). The bot is installed to the workspace and should have everything it needs to get up and running. I have also created a project in glitch.com and connected the app so that I can input any needed Bolt coding, but I can't figure out what to do to actually get the Bot to start reading messages, and how I can set a list of trigger words for it to know which messgaes to delete.

Thank you in advance for your help!

1 Answers1

0

It sounds like you're on your way to getting your app set up!

Depending on what kind of channel you want to monitor, you should subscribe to the appropriate event. As an example, if you want to receive messages from a channel, you'd subscribe to the message.channels event: https://api.slack.com/events/message.channels.

Within the event itself, you should look at the text value, compare it to a list of profanity words and then do some kind of action based on that.

I hope that gets you unstuck!

Jason
  • 121
  • 1
  • Thank you for taking the time to respond! Where exactly am I looking for the "text" value? I am subscribed to the event and see it listed under the bot_events section of the manifest but I am unable to find anywhere to alter any text field. And the last question I have is I know there is a chat.delete permission that will allow it to delete messages containing these words, but how do I set up the trigger for it to know to delete messages containing those words? Thank you so much again this has been driving me insane! – Kyle Gausselin Aug 02 '22 at 12:11
  • Also would I have to paste any other specific functions that I want into the manifest? – Kyle Gausselin Aug 02 '22 at 16:50
  • You won't find the text value within the manifest, the manifest file is only used to configure your app. The `text` value is in the event itself that is sent to your server. As an example, the text value for the example event is "Live long and prospect." seen [here](http://api.slack.com/events/message.channels) There isn't a way to set up a trigger to delete messages, you'll have to write your own code to do this. – Jason Aug 03 '22 at 01:09
  • Within the manifest, you'll only need to specify the _scope_ needed for a particular method, not the method itself. Scopes grant you the ability to use a particular method. As an example, the `chat:write` scope allows for you to use the `chat.delete` method. There's more info [here](https://api.slack.com/methods/chat.delete). Just as a warning -- For the same reasons that you cannot delete a message that someone else posted, you won't be able to delete messages that haven't been posted by the bot itself (note the bot is a user as well). – Jason Aug 03 '22 at 01:14