Slack : last items in the past 30 minutes

Hey to everyone !

I am looking for a solution to replace the lack of a trigger for slack.

I would like to find all messages in a slack channel.

  1. I found a solution with Cron node : access to “history” every 30 minutes
    but this is not very precise : a slack message could appear between each connection

  2. Maybe ther is a solution with the “Oldest” Filter in Slack node

  3. or maybe, we can “store” the id of the latest message that has been downloaded during latest connection

How would you do ?
Which solution would be the best ?

Thanks a lot !

Hi @damienOp, are you looking to react in real-time to events from Slack? I do this via a webhook node which works fine, though mit be a bit cumbersome to set up (as Slack expects a specific to an initial verification request which you’d need to implement first iirc). It’s described here: Using the Slack Events API | Slack. Would this perhaps work for you?

If you’d rather use the polling approach and fetch messages every 30 minutes, there is a number of options to store the last id. You could consider using any database, a Google Sheet, a local file or anything else you can think of really. n8n also lets you store data with your workflow, though this is quite complex, so the aforementioned options might be preferrable. You can then use an IF node to apply the filtering the next time your workflow runs.

1 Like

Thanks a lot for your reply
I think i can go with the polling approach

I can store last id of the last message and then the if node.
Comparison is done with something like :

if newID > lastID then download slack message ?

Hi @damienOp, yes, you could use this comparison assuming the IDs are numeric and incremental. If not, you might want to look at using timestamps instead.

1 Like