[GUIDE] How to use ChatGPT as an Email Parser

  • 26 March 2023
  • 2 replies

Userlevel 7
Badge +14

[GUIDE] How to use ChatGPT for Email Parsing


Contribution by Troy Tessalone

Certified Zapier Expert at Automation Ace



Email parsing using an email parser is an alternative to automating workflows when app APIs and webhook events are not an available option for sending data.

Now with AI (artificial intelligence), ChatGPT can be used as an email parser to do email parsing.

This guide will show you how!


NOTE: You will need a paid OpenAI / ChatGPT account in order to use the app in a Zap.
(ChatGPT requests cost fractions of a penny to run.)


Email Parsing

(Definition provided by ChatGPT)

Email parsing refers to the process of analyzing an email message's contents and structure to extract specific pieces of information or data automatically. This involves breaking down the message into its component parts, such as the sender's name and email address, the recipient's name and email address, the subject line, and the body of the message, and then organizing and categorizing this information. The parsed data can be used for a variety of purposes, such as automated response handling, lead generation, data analysis, and more.


Email Parser

(Definition provided by ChatGPT)

An email parser is a software tool that automates the process of extracting and organizing data from email messages. It uses algorithms and rules to analyze the content and structure of an email, identify specific pieces of information, and extract them into a structured format that can be used for further processing. Email parsers are commonly used in business contexts to extract data such as customer inquiries, purchase orders, and support tickets from incoming emails and feed them into other systems for processing.


ChatGPT by OpenAI

ChatGPT: https://chat.openai.com

OpenAI: https://openai.com



(Definition provided by ChatGPT)

ChatGPT is a large language model created by OpenAI, based on the GPT-3.5 architecture, designed to converse with humans in natural language and answer a wide range of questions on various topics.



(Definition provided by ChatGPT)

OpenAI is an artificial intelligence research laboratory consisting of a team of scientists, engineers, and researchers who are dedicated to developing advanced AI technologies in a safe and beneficial way for humanity. The organization was founded in 2015 by a group of tech luminaries, and is focused on creating cutting-edge AI models and technologies that can be used for a wide range of applications.



This can replace apps like:


Zap Steps



  1. Trigger: Gmail - New Email Matching
    1. You can use a different email app trigger. (e.g. Microsoft Outlook, Microsoft Office 365, etc.)
  2. Action: ChatGPT - Extract Structured Data
    1. Make sure to read the description for each field.
  3. Action: ???
    1. Up to you



  1. Trigger: Gmail - New Email Matching Search
    1. You can use a different email app trigger. (e.g. Microsoft Outlook, Microsoft Office 365, etc.)
  2. Action: ChatGPT - Conversation
    1. See section below about using Named Variables
  3. Action: Code - Run JavaScript
  4. Action: ???
    1. Up to you!


Action: ChatGPT - Conversation

Prompt ChatGPT to parse the email and returned the data as structured JSON to then be used in the following JavaScript Code step.

  • You only need to configure the field: User Message
  • Adjust the prompt instructions. (first line)
  • Define your JSON template. (fields you want returned from the parsed data)
  • Map the variable that contains the data to be parsed. (e.g. Email Body)
  • Other fields can be left with their default values.






Parse the contact details from the lead.

Return as fully structured JSON object like this:
"NameFirst": "",
"NameLast": "",
"Email": "",
"PhoneNumber": "",
"Company": "",
"Website": "",
"Comments": ""

Content: {{CONTENT}}




Action: Code - Run JavaScript

This Zap step will take the returned JSON from ChatGPT, and convert the JSON into individual data point variables that can be mapped to following Zap steps.


Map the Assistant Response Message variable from the ChatGPT step.







let Lead = inputData.Lead;

Lead = JSON.parse(Lead);

output = [{Lead}];







Named Variables

Another approach would be to use Named Variables, which would then not require the Code step.







And there you have it!

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

2 replies

Userlevel 1

Hey Troy, this is amazing stuff! One addition here, which could save you the Code Step in many situations, is formatting the output to support the Named Variables format instead of JSON:




We have another community post here that discusses Named Variables here.


Userlevel 7
Badge +14

Hi @Kirk 

Good point.

Often forget about the named variables hack!