2
votes

My current slack app is a slash command that will open up some dialogs with interactive buttons using my request URL.

At one point in my application I have a list of direct message channel ID's from various users that are subscribed to the slack app.

My bot so far sends messages to everyone who is on this list of "subscribed" users. I want to be able to save the message that each user sends to the bot.

How do I achieve this? I'm digging through the API but I'm having a hard time finding some kind of "listening" mechanism. I know I could just make a while true loop in python but I'm not sure how to detect when messages are sent to my Bot.

1

1 Answers

2
votes

I would suggest using the Events API from Slack to collect message to your bot.

After setup Slack will automatically send a request to your app for every new message where your bot is mentioned, e.g. by subscribing to the app_mention event. That request will include the actual message along with context information.

Alternatively you can listen too all messages by subscribing to the message event and then filter out the ones that you want to keep.