Search Email Text for a name, from a Google Sheets column of 400+ possible names

EDIT: I believe I found a solution by using regex to search the email text using every name in the column, by aggregating the names into a list separated by “|”. So, email comes in, then 1. Table Aggregator to aggregate the colum rows into a list separated by “|”, and 2. Text Parser module with the Pattern set to the list created by the Table Aggregator, and the Text set to the email text. In other words I used the formula
x = re.findall(“John Smith|Jane Doe”, emailtxt).

I have a list (google sheets column) of over 400 names. I am trying to make a workflow which, when an email arrives, searches the text of that email for any of those 400+ names. If the name is found in the Email, it writes that to a different Sheet.

In other words: If [Name] in [Email Text], output [Name]. (##[Name] could be any one of 400+ possibilities)

For example, I have the following column in Sheets:

Name
John Doe
Jane Doe
John Smith
Jane Smith

And I want to search the following email Text for any of these terms (since I don’t know which will be in the email), and then ouput the matched term into another Sheet (I can handle that last part).

I believe I could use an Iterator or other method to search the email text for each Name one at a time. However, I don’t want to use 400+ operations each time an email comes in. Is there any way to search the email Text with all the names from the Sheets column using a single / a few operations? If I aggregate the column rows? Or somehow using “Search Rows (Advanced)” using a Query? Or am I stuck having to search the email text once per possible name?

Also note that the emails that come in will have varying formats, so I don’t think I can do a regex match / extract based on a pattern.

Thanks for any help!!

Welcome to the Make community!

Could you please provide example text and example email for us to test on?

Don’t forget to format the text when you paste it here!

  • Either add three backticks ``` before and after the code, like this:

    ```
    text content goes here
    ```

  • Or use the format code button in the editor:
    Screenshot_2023-10-02_191027

Following these steps will allow others to assist you here. Thanks!

samliewrequest private consultation

Join the unofficial Make Discord server to chat with us!

1 Like

Hi @Dan_C
You can use the text aggregator to combine all the names seperated by ‘|’.

image

And as the filter you can check if the aggregated text contains the name you want.
image

If you require additional assistance, please don’t hesitate to reach out to us.
MSquare Support
| Book Live Implementation
Visit us here
Youtube Channel

1 Like