Skip to main content
Question

How do I filter Slack messages based on keywords in Google Sheets?

  • 10 May 2024
  • 7 replies
  • 67 views

 

Hey folks,

 

I’m trying to make a current zap more scalable to my team’s needs.

 

The setup is:

  • Event - New message posted to Private Channel in Slack
  • Continue only if… “text” contains certain company names, which are manually listed as “or” groups
  • Action - Send Channel Message in Slack

 

I’d like to reduce the manual work involved in adding each of the company names as separate “or” items under the “continue only if...” filter by having Zapier reference a Google Sheet cell range (a column, ideally). So, if the Slack message text contains any of the text in a referenced Google Sheet cell range, then the zap continues.

 

We need this because the key company list can change from week to week, and said list is maintained in a centrally referenced Google Sheet. So, manually changing the Zapier keywords every week is a pain and also risks having an out-of-date list due to human error.

 

I’ve searched and found this previous post, but it doesn’t quite nail my needs on the head because the solution provided has an action originating in Google Sheets, not Slack.

 

Here are the screenshots of the current zap:

 

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

7 replies

Userlevel 7
Badge +14

Hi @SAmb2024 

What you are trying to do is possible, but may become Task heavy.

Based on the logic below the Zap would use 2 Tasks each time it runs just to determine if it should continue.

 

STEPS

  1. Trigger: Slack - New Message Posted to Private Channel
  2. Action: GSheets - Lookup Row(s)
  3. Action: Code
    1. Used to check if the message matches the data from the returned GSheet rows
  4. Action: Filter
    1. Only continue when conditions are met
  5. Action: Slack - Send Channel Message
Userlevel 3
Badge +3

Hi @SAmb2024 I may be able to help as I was dealing with a similar case before. May I confirm that your company names in the slack private channel and gsheet database are usually exact matches? Or you would need to apply some sort of fuzzy matching given sometimes people have typos in slack! I will also private message you to see if you need help setting this up. 

Userlevel 7
Badge +11

Hey there @SAmb2024! 👋

Just wanted to check in here to see how you’re getting on with this. Were you able to able to get this working using the trigger and actions as suggested by Troy?

If you’re still stuck at all, do share some screenshots showing the setup of any trigger or action that’s not working as expected, and we’ll be happy to take a look! Please remove/hide any private information (like names, emails, addresses etc.) from any screenshots before sharing.

Looking forward to hearing from you!

P.S. @fiona819 - just want to give a quick reminder that all troubleshooting assistance should be shared directly in the public-facing thread here and not carried out in a private message. This ensures that everyone in the Community is able to benefit from the information and troubleshooting advice shared. Thanks! 

Userlevel 1

@fiona819 The setup would be totally fine if we had it set for exact matches and not fuzzy parameters. The messages being sent have been spellchecked/copy-edited (they’re captions being shared for social media posts) so we don’t have many typing error instances to worry about slipping through the cracks.

 

@Troy Tessalone Thank you for the suggestions here. Do you think this can be set up by someone who isn’t especially code-savvy given the “Code” action you recommended in the workflow? I was looking at Zapier’s article on the Code action and it looks like I could eventually get there with some self-learning time. Part of the appeal of using Zapier is not having to dig into coding, but I understand that comes with its limitations.

 

(Thanks for checking in @SamB)

Userlevel 7
Badge +14

@SAmb2024 

Zapier Code steps have AI built in that can help: https://help.zapier.com/hc/en-us/articles/15666688064013-Generate-a-Code-step-using-AI-Beta

 

ChatGPT is another resource to leverage to work with code.

Userlevel 3
Badge +3

@SAmb2024 I just tested out the flow and it works. The JS code you need is pretty straightforward, can you verify this is the workflow you want? I put in my gsheet a column of names to look up from. 

 

 

Userlevel 3
Badge +3

@SAmb2024 I came up with a better way to do this leveraging chatGPT. Let me know if you want to learn a bit more about it. Thanks :)