Question

How to make Zapier filter just the name and phone number that comes within the email I received?

  • 13 December 2023
  • 9 replies
  • 79 views

Userlevel 1

Hi, 

I have created a Zip to link my gmail account to Google Sheets but I want to filter the email and just receive the name and phone number that come within the email and not the whole email (like what is happening now)

Below, you have screenshots that explain better what I did and the output.

 

 

 

Thank you in advance for any help provided!

Best regards,

Azhar


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

9 replies

Userlevel 7
Badge +14

Hi @Azhar Bondi 

We would need to see more screenshots with how your Zap Filter step is configured and how your Steps 4 & 5 are configured.

Userlevel 1

Hi @Troy Tessalone ! Thank you for your message ! 

I will be sharing the screenshots below!

 

 

 

 

 

 

 

 

 

Thank you !! 

Userlevel 7
Badge +14

@Azhar Bondi 

As an example, you would need to map the data output variable from the Formatter in Step 3.

 

Userlevel 1

How could I do that ? Can you provide me with an example please?

 

these are the options I am getting !! and the closest I found that made more sense was the body plain

 

Userlevel 7
Badge +14

@Azhar Bondi 

You would need to scroll down and select a variable from the Formatter step.

 

Userlevel 1
Badge

Hey Azhar, 

You getting the entire email body text as string in the zap. I have found this difficult to separate out the easily with just the formatter. It usually better to add a code block to grab what you need from it.

 Below is a quick grab from chatGPT using python and regex to get the email address and telephone number. (I prefer python over javascript but it’s likely you could do the same thing.)
 

import re

# Example input from the email body
email_body = input_data['email_body'] # Replace with the actual input variable from Zapier

# Regex patterns for email and phone number
email_pattern = r"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}"
phone_pattern = r"\+?\d[\d -]{8,12}\d" # Adjust as needed

# Searching for matches
email_match = re.search(email_pattern, email_body)
phone_match = re.search(phone_pattern, email_body)

# Extracting the matches
email_address = email_match.group(0) if email_match else "No email found"
phone_number = phone_match.group(0) if phone_match else "No phone number found"

# Returning the results
output = {'email': email_address, 'phone_number': phone_number}

You would then use the variables from the code step to add to your google sheet.

To grab the name from the subject line if <meet> persons name from is always in the subject line then you could use something like this to separate it 

import re

# Example input from the subject line
subject_line = input_data['subject_line'] # Replace with the actual input variable from Zapier

# Regex pattern to match text between <meet> and from you can change this to match you pattern
pattern = r"<meet>\s*(.*?)\s*from"

# Searching for the match
match = re.search(pattern, subject_line, re.IGNORECASE)

# Extracting the match
extracted_text = match.group(1) if match else "No match found"

# Returning the result
output = {'extracted_text': extracted_text}

They can be combined in one code block and it would then give you the variables you need for you google sheet. 

I have done this sort of thing to search Shopify line item properties on orders.

I hope it helps.   

Userlevel 1

Thank you for your help @Troy Tessalone  and @Badger  ! I ended up using the email parser by zapier 

Userlevel 7
Badge +6

That’s awesome @Azhar Bondi! We’re glad to hear you’re able to find an alternative for this one.

If you have any other questions, please don’t hesitate to reach out to the Community. We’re always happy to help! 🤗

Userlevel 1

That’s awesome @Azhar Bondi! We’re glad to hear you’re able to find an alternative for this one.

If you have any other questions, please don’t hesitate to reach out to the Community. We’re always happy to help! 🤗

Thank you @ken.a