• Home

  • Automation with Zapier

  • Zapier tutorials

Zapier tutorials

8 min read

How to write sales emails with OpenAI and Zapier

By Krystina Martinez · May 10, 2023
A hero image of the OpenAI app logo connected to the Gmail app logo on a light blue background.

We've all received those cold emails that instantly go in the trash: the sender used an email template, so it's apparent they know nothing about you or your business.

You may not have the time to put together an attention-grabbing pitch for each prospect, but if your cold email templates aren't converting, automation with Zapier can help.

With Zapier's OpenAI integration, you can automatically draft sales emails tailored to each prospect. In this tutorial, you'll learn how to use a Zap—our automated workflows—to connect your essential apps to AI so you can create sales email drafts that are more likely to convert—and less likely to end up in the spam folder.

Looking for GPT-4 or GPT-4o? You can access those via our ChatGPT integration now—allowing you to add ChatGPT-powered conversations into apps like Slack. You need $5 or more of credit in your OpenAI account to access GPT-4 or GPT-4o. Discover popular ways to use the ChatGPT Zapier integration.

Before you begin

By the end of this tutorial, you'll have Zap that will use OpenAI's GPT-3 to automatically draft personalized sales emails based on contact record information from your customer relationship management (CRM) tool.  

You'll need the following:

  • A CRM tool or another app you use to track leads and sales activity. For this tutorial, I'm using Salesforce, a premium app that requires a paid Zapier plan to use. Search for your app within our App Directory or Help Center to see what permissions you'll need.

  • An OpenAI account and an API key. This lets you connect GPT-3 to Zapier. If you don't have an OpenAI account, it's free to create one. Then, create your API key and save it in a password manager because you can't retrieve it again.

  • An email app or other tool that lets you draft emails. I'm using Microsoft Outlook for this tutorial. You can use another email client or check to see if your CRM's Zapier integration lets you send emails. For example, HubSpot users can use the Create Engagement action to send an email to a contact.

This workflow requires a multi-step Zap, available on a paid Zapier plan or during a free trial. Learn more about multi-step Zaps.

How to draft cold sales emails with Zapier and OpenAI

Depending on the apps you choose to use, this Zap can be anywhere from three to five steps. I'm demonstrating a four-step Zap, which looks like the example below:

The Zap contains four steps. It triggers from an updated field on Salesforce records. Then it will search for an existing Salesforce record, send a prompt to OpenAI, and then draft an email in Microsoft Outlook.

If this is your first time building multi-step Zaps, don't worry. This workflow will be a helpful introduction to concepts that will let you build next-level automated processes for your sales tools.

You can create your own Zap from scratch with our point-and-click editor, but we also have quick templates to get you started.

To get started with a Zap template—what we call our pre-made workflows—just click on the button. It only takes a few minutes to set up. You can read more about setting up Zaps here.

Draft Microsoft Outlook emails from Salesforce and OpenAI

Draft Microsoft Outlook emails from Salesforce and OpenAI
  • Salesforce logo
  • OpenAI (GPT-4, DALL-E, Whisper) logo
  • Microsoft Outlook logo
Salesforce + OpenAI (GPT-4, DALL-E, Whisper) + Microsoft Outlook

Set up the CRM trigger

First, let's create the trigger—the event that starts any Zap.

Select the CRM or database app you want to use along with the event. If you're using a CRM, your event should be something like Updated Record, New Deal in Stage, or whatever activity your team uses to determine when to send sales emails.

If you're following along, select Salesforce as the app and Updated Field on Record as the event, then click Continue.  

Select the Salesforce app and Updated Field on Record event for the Zap's trigger.

Select your app account (or connect it to Zapier if you haven't before), then click Continue.

For each app you connect, Zapier will ask for a general set of permissions which allows you to be flexible with your Zaps. The only actions Zapier takes on your app accounts are those a given Zap needs to accomplish what you've set up.

Next, customize the trigger. Select the CRM object and property you want Zapier to monitor for updates. For example, if you want your Zap to trigger when new deals enter a particular stage, you'll likely select the pipeline and stage to monitor.

Below, I've set up the trigger to monitor the Status field in any Salesforce Lead objects.

Click on the dropdown menus to select the Salesforce object and Field that will trigger the Zap.

If you use Salesforce, add the specific field update that will trigger the Zap in the Field Updated to field. For example, I only want this Zap to trigger for new leads with the status Open - Not Contacted.

Click on the dropdown menu and select the field update that will trigger the Zap.

Once you've customized your trigger, click Continue and test this step. You'll see a success message if your test works.

Test the Zap trigger and review the results.

When you test a trigger step, Zapier will try to find the most recent items—such as a new form submission—according to how you've set up the trigger. When a test is successful, you can use the test data from your trigger in subsequent Zap steps.

Check the test data to make sure your trigger is working correctly. If you only want your Zap to trigger on a specific change, click on the dropdown menu and check any other records Zapier found. You want to ensure you only see the records you want in your test.

Click on the dropdown to review other test data.

If something looks off or you get an error message, go back to the previous step and adjust your settings. Or create a new record and retest until you receive a success message.

What if your trigger can't watch for specific record changes? You can also add a filter stepavailable on our paid plans—if you only want your Zap to run under certain conditions. Check out our feature guide for more ways you can use filters.

Optional: Search for associated notes

Before you set up your AI-created sales email, you'll want to provide extra context about your contact so GPT-3 can better personalize the message. (After all, you want emails that stand out.)

If your team regularly attaches notes to contact records, you can use a search action to include note information in your GPT-3 prompt.

A search action—or a search step—can look for existing information in your apps that you can reference in a later Zap step. Search steps are often paired with another action, allowing Zaps to update existing data, check for duplicates, or create new records when needed. Check out our guide to using search steps in Zaps.

Add an action step to your Zap. Select your CRM app and the search action you want to use. Search actions for CRM apps will usually have Find in the title.

If you're following along, select the Salesforce app and the Find Record eventthen click Continue.  

Select Salesforce and the Find Record event.

Check to make sure your CRM account is already connected, then click Continue.

Now, set the search criteria for your action. Click on Salesforce Object and select a Note object to use. For this tutorial, I've selected the one with the ContentNote ID.

Select the Note Salesforce object from the dropdown menu.

Salesforce categorizes notes as different objects, depending on how they were created. Not confusing at all. Check the Salesforce documentation to find the Note object best suited for your needs.

Next, click in Field to Search By to select the field within the note you want to search. This should be something that specifies a connection to your contact, like the contact ID or the ID of the contact owner. For this Zap, I selected the Owner ID field.

Click on the dropdown menu and select the owner ID for the field to search by.

Next, choose the value Zapier should search for within your note. If you enter static text in the Search Value field, Zapier will search for the same thing each time your Zap runs—which is not ideal.

Instead, field map contact record data from your trigger so this step searches for notes connected to your contact. Click in the Search Value field and select the dynamic value from your trigger to use.

Since I want this Zap to search by the Owner ID field, I've selected the Owner ID value from my trigger.

Select owner ID for the search value.

A dynamic value is any data from a previous Zap step that you've mapped to a field in the Zap editor. When you map a dynamic value—such as a contact name—what you see in the editor is a placeholder. Field mapping dynamic values are how you pass data from one app to another. Once your Zap is turned on, Zapier will send the information that the field contains every time your Zap runs.

The Zap editor will ask if you want this step to proceed if your search is unsuccessful. Since I only want this Zap to proceed for contact records with notes, I've set this to No. If you're unsure what option to choose, check out our feature guide on search steps for more information.

Click on the dropdown and choose No.

Once you've set up your search criteria, click Continue and test it.

You'll see a success message if Zapier found a record or if you set up your Zap to proceed regardless of the search outcome. If you receive an error message, adjust your search criteria and retest.

Be sure to check the search status in your test data, which will either be true or false.

Review the results of the search action and check the Zap search status.

Once you've verified your search step functions correctly, click Continue.

Create the OpenAI action

Next, add your OpenAI action. This step will use the contact record and note from your CRM to write a personalized sales email.

Select the OpenAI (GPT-3 & DALL·E) app and the Send Prompt event, then click Continue.

Select OpenAI and the Send Prompt event for this step's action.

Select your OpenAI account or connect it if you haven't used it with Zapier before. You'll need to provide an API key, which you saved earlier. After you've connected your account, click Continue.

Use the gpt-3.5-turbo-instruct model, selected by default.

Use the text-davinci-003 model for this prompt.

Models are algorithms that use large amounts of data to identify patterns and make predictions for completing specific tasks, such as generating text or images. OpenAI models have different capabilities, so choose the appropriate model for your request. Learn more about the models available, and use this tool to try out different settings.

Now it's time to give OpenAI instructions—also known as a prompt—for how to write a sales email.

For the best results, your prompt should contain the following:

  1. The specific instruction for writing the sales email: Beyond telling GPT-3 to write an email, provide guidance on the structure and areas to focus on.  

  2. The tone or style GPT-3 should use: Since I wanted this email to be in the voice of the CEO, I provided a brief biography for GPT-3 to emulate. You could also provide your brand voice guidelines here.

  3. The specific thing to pitch: You can incorporate products listed in your CRM or use static text.

  4. The call to action: What do you want the prospect to do next? This can be filling out a form, replying to the email, or whatever else you'd like.

  5. The information about your contact: This should be information that will help OpenAI personalize the result, such as names, titles, or company websites.

In the prompt below, I used headings to help the AI understand each part of my prompt, such as the products to reference and the contact information to use.

The prompt should include the instructions and the CRM contact information to use for personalization.

To get the best results from ChatGPT, write a clear prompt with sufficient context. Need help refining your text query? Here are tips to help you write an effective GPT prompt

Under the Contact Details heading, map values from your contact record and attached note by clicking inside the Prompt field and selecting the values you want to use.

Map the contact's note to the prompt.

You can tweak additional settings for your prompt as well:

  • Temperature controls how creative or predictable GPT-3 should be. The higher the value, the more creative the result. The default value is 0.7, but I increased this for a more attention-grabbing email.

  • Maximum Length determines the max number of tokens to use. Think of it like character limits for AI. Tokens are roughly four characters long, and OpenAI counts the tokens in both the prompt and the result. Zapier will try to auto-calculate the number of tokens. Otherwise, it will default to 256 tokens. You can use this tool to calculate how many tokens your prompt uses.

  • Stop Sequences tells OpenAI when to stop generating tokens, so your result doesn't cut off due to hitting the max token length. Stop sequences aren't included in the result. Learn more about using stop sequences.  

Adjust the temperature, maximum length, and add stop sequences to customize your prompt.

You can also control how much GPT-3 repeats itself by adjusting the Frequency Penalty or adjusting the Presence Penalty lower to prevent it from going off the rails.

Adjust the frequency and present penalty for the prompt.

Once you've tweaked your prompt, click Continue and test your action.

You'll see a success message if it works. Check the test data to see if you need to adjust the prompt or related settings.

Test the Zap step and review the prompt outcome.

Once you're happy with the result, click Continue.

Create the email action

Finally, set up the last step of this workflow, which will use OpenAI's sales email to create a draft email.

Search for and select the email app you want to use and the event to create a draft email.

If you're following along, select the Microsoft Outlook app and the Create Draft Email event, then click Continue.

Select the email app and draft email event for this step's action.

Connect your app account to Zapier, if you haven't already, then click Continue.

Next, customize your email draft. Click on To Email(s) and map the recipient's email address from your trigger.

Map the contact's email to the sender field.

If you asked OpenAI to generate a subject line for you, you can map that in the Subject field. You can also combine static text and values from previous Zap steps.

For this Zap, I added my own text and mapped the contact's name from my trigger.

Use a mix of static text and dynamic values for a personalized subject line.

Depending on the app you're using, you can choose the format for your email body. If you want to use formatting, such as bolded text or hyperlinks, choose HTML. Since I don't need any special formatting, I selected Text for the body format.

Select either plain text or HTML format for the email body.

Then, click in the Body field and map the result from GPT-3.

Map the output of the OpenAI prompt to the email body.

Note: Choices Text has now changed to Response in the dropdown menu.

After customizing your email, click Continue, and test your action.

You'll see a success message if your action is set up correctly.

Test the email action and review the result.

Go to your email app and check the Drafts folder to see how your email looks.

The Zap creates an email draft in your inbox.

If you're happy with everything, your Zap is now ready to use!

Create better sales emails with automation and AI

With Zapier and OpenAI, you can quickly add personalization to your cold outreach efforts and improve your chances of converting leads into customers.

Draft Microsoft Outlook emails from Salesforce and OpenAI

Draft Microsoft Outlook emails from Salesforce and OpenAI
  • Salesforce logo
  • OpenAI (GPT-4, DALL-E, Whisper) logo
  • Microsoft Outlook logo
Salesforce + OpenAI (GPT-4, DALL-E, Whisper) + Microsoft Outlook

Related reading:

  • How to use AI and Zapier to write autoresponders

  • Enrich lead info from sales forms with OpenAI and Zapier

  • Streamline sales with AI and automation

  • How to create an AI digital assistant

  • The best AI sales assistants

  • How to automatically write cold emails for Woodpecker prospects with OpenAI

Get productivity tips delivered straight to your inbox

We’ll email you 1-3 times per week—and never share your information.

tags

Related articles

Improve your productivity automatically. Use Zapier to get your apps working together.

Sign up
See how Zapier works
A Zap with the trigger 'When I get a new lead from Facebook,' and the action 'Notify my team in Slack'