How can I extract these 6 items from a body of a text into mappable fields?

Hello!

I have a ‘Watch Emails’ module set up and I am trying to extract these 6 fields from the body of text. Example below:

Name: Mark Stephenson
Email: mark@msconsult.com
Telephone: 01564776441
Country: United Kingdom
I’m Enquiring About:: Coaching Offer
Message: I would like to explore your services

The desired result is to fill 6 column fields into Monday.com (Name, Email, etc). I’m fine with that part but need help with the extraction.

Thank you very much in advance.
Dominic

1 Like

Hi there @dom_1, that should be pretty straight forward as long as the content appears in the email is exactly as you’ve described it here. The titles I mean (name, phone, etc). You can use regular expressions to extract the information after each of those titles.
Here’s How

  1. Input a text parser (pattern match) into your scenario
  2. In the section “Pattern” input : Name:\s*(.?)\sEmail:\s*(.?)\sTelephone:\s*(.?)\sCountry:\s*(.?)\sI’m Enquiring About::\s*(.?)\sMessage:\s*(.*)
    NOTE - I’m Enquiring About:: has two colons since that’s what you’ve shown your email has above, if that is not actually how the email is formatted remove one colon.
  3. Then in the “text” section at the bottom of the text parser input the variable you want to parse from.

Hope this was helpful

1 Like

Thank you so much for your reply @KinderTech . I have followed the instructions but its recieving an empty output bundle. Any ideas what I’m doing wrong?

1 Like

Try this Regex

/Name:\s(.+)\nEmail:\s(.+)\nTelephone:\s(.+)\nCountry:\s(.+)\nI'm Enquiring About::\s(.+)\nMessage:\s([\s\S]+)/;

1 Like

Hello @dom_1,
Just try this regular expression which is cleaner with group names.

Name:\s+(?<name>.*?)\nEmail:\s+(?<email>.*?)\nTelephone:\s+(?<telephone>.*?)\nCountry:\s+(?<country>.*?)\nI’m Enquiring About::\s+(?<enquiringAbout>.*?)\nMessage:\s+(?<message>.*)

Proof of matching: regex101: build, test, and debug regex


:bulb:P.S.: Always search first, Check Make Academy. If this is helpful, mark it as a solution :white_check_mark: and :+1:
Need expert help or have questions? Contact or comment below! :point_down:

Thank you @Keshav_Kalra and @dilipborad .

However I am still getting no results with both of those patterns. I’ve attached the blueprint, maybe it would be helpful to see this? :pray:t2:

blueprint (2).json (12.5 KB)

1 Like

Hello @dom_1,
From the “Text parser” module pattern remove “/” from the start, and also remove “/gm” from the end.

Make sure you’ve data comes from the Mail module.

Hi @dom_1

I have updated your blueprint and tested and it worked.

Please import and let us know if it works for you as well.
blueprint (69).json (12.6 KB)

Other way around to do this is using functions. I have attcahed snapshot to get the name. You can do the same for other variables inside monday module. this will just save you one operation.

Regards,
Msquare Automation - Platinum Partner of Make
@Msquare_Automation

Hello @dilipborad thank you so much for the quick response. Changed the pattern but still not working.

1 Like

Hello @dom_1,
See the output I get from using the same expression I shared with you.

What you passed as input is more important here.

Please try to cross-check and share more details if you still get errors.

@dilipborad I think it might be because I am missing the ‘Set multiple variables’ module like you do in your screenshot. I am taking it directly from the ‘Watch Emails’ module. Is that wrong?

If so, please can you share a screenshot of what you have inside that module?

Thank you once again.

1 Like

Hello @dom_1
I need to use Set Multiple Variable because I don’t have that data directly from the Email Module. So used to hold that content.

In your case, you don’t need to set up that.
Just for now, you try this.

Later replace the Text string with your mail content.

Hello @dilipborad thanks again. I believed I’ve followed everything as you instructed. I’ve attached a more complete video showing the scenario. I must be doing something wrong still but can’t figure out what as it looks like the setup is the same as yours:

1 Like

Hello @dom_1,
Thanks for sharing the video. As per the video, everything looks ok.

Now can you please share your input and output bundles? I think that’s makes more sense to test and understand what causes errors.

How to download the input and output bundle.

Click on the this :arrow_down: button

I think this helps me to fix this error.
:+1:

Hey @dilipborad sorry for the late reply, I’ve downloaded the output bundle into this text file. Please see attached. Anything you’re able to see there?

Thank you.
output bundle.pdf (58.6 KB)

1 Like

Hello @dom_1,
It was tricky.

I can’t tell you what the funny issue is. :slight_smile:
It was a different single quote (') used in the text I’m Enquiring About
See the single quote (') difference between I’m Enquiring About and I'm Enquiring About.

Now use this new updated RegExp.

Name:\s+(?<name>.*?)(\n|\\n)Email:\s+(?<email>.*?)(\n|\\n)Telephone:\s+(?<telephone>.*?)(\n|\\n)Country:\s+(?<country>.*?)(\n|\\n)I'm Enquiring About::\s+(?<enquiringAbout>.*?)(\n|\\n)Message:\s+(?<message>.*)

I’ve updated it slightly because I’ve noticed the possibility of the string coming with just \n without a line break.
Now it works with both of them. See the Proof regex101: build, test, and debug regex

I hope this time it works.
:+1:

2 Likes

@dilipborad this worked! Amazing, thanks so much for your help.

1 Like

Hello @dom_1,
Can you please mark this topic as a :white_check_mark: complete?
It helps others to see what is the perfect solution.
:+1:

hello @dilipborad - done.

2 Likes