Shortening text parser

Output from mailhook


Text parser 1 through to 6
image
image
image
image
image

I then parse just the first date from one of the outputs to break it down more.
image

How can I combine this into one with labeled variables?
@samliew

Do you think you can anonymise private information from the mailhook output bundle, and paste the text sample here?

E.g.: for email address, you can change it to a ficticious one like “test@example.com”

Format your text on this forum by editing three backticks ``` before and after the code, like this:

```
input/output bundle text goes here
```

2 Likes
You have an upcoming event

John Smith - +61412234532
Tuesday 17 Oct 2023 ⋅ 10:17pm – 11:17pm (Australian Eastern Standard Time -
Brisbane)
Phone: 04999999
Address: 8 Address St, Suburb
Appointment: 17 Oct 11:17 PM to 18 Oct 12:17 AM
Attendee: employee@domain.com
Location8 Address St, Suburb
View map <https://www.google.com/maps/search/8+Address+St,+Suburb?hl=en-GB>
Guests
Employee Name <employee@domain.com>
View all event details
<https://calendar.google.com/calendar/r?eid=RANDOM LETTERS TO CALENDAR=1>

Invitation from Google Calendar <https://calendar.google.com/calendar/>

You are receiving this email because you are subscribed to Calendar
notifications. To stop receiving these emails, go to Calendar settings
<https://calendar.google.com/calendar/r/settings>, select this calendar and
change ’Other notifications’.

Forwarding this invitation could allow any recipient to send a response to
the organiser, be added to the guest list, invite others regardless of
their own invitation status or modify your RSVP. Learn more
<https://support.google.com/calendar/answer/37135#forwarding>

The information I need parsing is:
Customer’s Name: John Smith
Customer’s Phone Number: +61412234532
Note In the email it’s formatted like Name - Number but it may be formatted like Name Number (without the hyphen)
Appointment: 17 Oct 11:17 PM
Location: 8 Address St, Suburb
Employee: employee@domain.com

Hello there.

What about using ChatGPT to do the work instead of using complicated parser?
Here is a prompt that do the job :

Ignore all previous instructions. You are a meticulous secretary with 10 years of experience. I will provide you with the content of an invitation confirmation email, and you will return the following informations with '||' as separator : 

<INSERT EMPLOYEE'S NAME>||<INSERT EMPLOYEE'S PHONE NUMBER HERE>||<INSERT APPOINTMENT DATE HERE>||<INSERT APPOINTMENT LOCATION HERE>||<INSERT EMPLOYEE'S EMAIL HERE>

Here is the email confirmation to process : 

EMAIL

Answer directly with the output.

After the OpenAI module, you could:

  • get your data in an array by using the Split() function using the || as separator
  • format your end result as you want (if you only want a text as final result, you can directly ask ChatGPT to give it to you)

The risk with this approach would be ChatGPT hallucinations / errors / API down. The 2 first risks can be handled with a request temperature to 0.2 (strict and deterministic results), the 3rd would need more complex error handling :thinking:

1 Like

Hello Levai,

You can use a Text Parser “Match Pattern” module with this regular expression pattern

(?<name>[\w ]+) - (?<phone>\+?\d+)[\w\W]+?(?<date>\d{1,2} [A-Z][a-z]{2} \d+:\d+ [AP]M)[\w\W]+?Attendee: (?<email>[^\n]+)[\w\W]+?Location:? ?(?<location>[^\n]+)

Demo: https://regex101.com/r/9qu3K7

Make sure Global Match is set to NO:

Output:

Then, you can use these variables in your Email mapping module to format the result in the final form.

Hope this helps!

3 Likes

I used your code and changed it to suit the different area codes and possible inputs.

(?<name>[\w ]+) *[-]? *(?<phone>\+?61[2-4,7-8]\d{8}|0[2-4,7-8]\d{8})[\w\W]+?(?<date>\d{1,2} [A-Z][a-z]{2} \d+:\d+ [AP]M)[\w\W]+?Attendee: (?<email>[^\n]+)[\w\W]+?Location:? ?(?<location>[^\n]+)

Thank you!

2 Likes

No problem, glad I could help!

In future, please create a new thread for each question. This makes it easier for others with the same problem to search for the answer. Thank you for your cooperation!

The Make Community guidelines encourages users to try to mark helpful replies as solutions to help keep the Community organized.

This marks the topic as solved, so that:

  • others can save time when catching up with the latest activity here, and
  • allows others to quickly jump to the solution if they come across the same problem

To do this, simply click the checkbox at the bottom of the post that answers your question:
Screenshot_2023-10-04_161049