A python script for Zapier to work with incoming emails (gmail service) to created airtable records. It takes a plain text input (e.g. an email body) and outputs matched text and a boolean for flow control.
It takes plain text as 'body' for input. In the case of an email, be sure to select 'Body Plain' not 'Body HTML.'
All text is matched after a trigger phrase (trigger_phrase) up to a terminating character (term_char). These are hard-coded but could be set as inputs in zapier with a little tweaking (watch out for python regex syntax).
trigger_phrase
default is THIS IS A TEST.
Replace only this text to
customize the phrase. Leave the r, quotes, and parentheses so that the python
search still works. Not case sensitive.
term_char
defaults to a period. Replace only the period to customize it.
The test zap had the following structure:
- Gmail: New Email (a dedicated account or some kind of search based filter. doesn't matter.)
- Run Python (Copy the contents of parse_text.py here.*)
- Filter: Only continue if (2: Run Python: Matched)
- Airtable: Create Record. Connect the text of the record to 2: Run Python: Insert Text (I also put the full text of the email in a note and the date from the email in a 'created' field. You can pass the date directly from the email but if you try to do the time as well you can get timezone issues).
* It is important to only copy from below # COPY THIS CODE INTO ZAPIER
or
the input may be overridden which defeats the whole point.