Email rules: Extracting data
Extracting data is the second block in the rules for processing emails, which you must fill out when creating a rule.
You can extract data from different parts of the email:
- Email subject+Body
- Email subject
- Body
- Body(original email) - Only use this option if you control the email-sending process, have the original text before sending it, and are testing regular expressions or other data extraction methods.
Data is extracted into infoblocks. These infoblocks have intuitive names, making it easier to work with them later in the process when populating task, contact, or data tag fields. In addition to a name, each infoblock contains instructions for extracting the part of the email that should go into it:
Data extraction formats
When extracting data, there are two ways for Planfix to analyze an email:
- Text — this usually corresponds to what you can see in your browser when you read the email. This is the most popular option.
- HTML — all email contents will be analyzed, including markup. This option allows you to use fragments containing HTML tags to more accurately capture the desired content.
- HTML-Table — Used for extracting data from tables in emails.
- JSON — used for parsing if the message text is in JSON. Read more about this in our JSONPath help section.
- XML — Used for storing and transferring data and is often used when exchanging data via the Planfix API.
Data extraction methods
You can use one of the available options:
- From label to end of line - the infoblock will contain the fragment of the email starting immediately after the label you specify and ending with a newline character or the end of the email. Leading spaces (if any) and the newline character will not be included in the infoblock.
- From label to label - the infoblock will contain the fragment of the email starting immediately after the start label you specify and ending with the final symbol before the end label. Leading and trailing spaces will be ignored.
- From label to end of line - the info block contains the email fragment that starts on the new line after the label you specified. Leading and trailing spaces will be ignored.
- Regular expression - the infoblock will contain a fragment of the email according to a regular expression you input.
- All contents - the infoblock will contain the entire content of the email .
Examples
Let's say an email is sent to Planfix with the following body:
The configuration for the infoblock for extracting the customer's phone number from this email would be as follows:
Once this has been processed, an infoblock will be created called Phone, containing +16888933044.
To extract multiple lines from the order that are listed in the email, use the following setup:
Once this has been processed, three infoblocks are created with the following contents:
- Product name: Toyo r888
- Product price: 500
- Amount: 2
Important
- Later in the mail parsing rule, the main operation and additional operations will use these infoblocks to select tasks, contacts, and data tags and populate their fields with data. (For examples, see the corresponding help section articles.)
- Data from incoming emails in Planfix can be further processed before use.