Loading
Loading
  • Home

  • Automation with Zapier

  • Zapier tutorials

Zapier tutorials

9 min read

How to enrich lead info from sales forms with OpenAI

By Krystina Martinez · May 3, 2023

You want to provide a good buying experience for your leads, but researching and gathering context for each prospect becomes tougher as you scale. Plus, you don't want to overload your potential leads with too many questions and risk turning them off.  

With Zapier and OpenAI (makers of ChatGPT), you can gather additional information about each lead without the extra effort and keep your sales pipeline moving. Our automated workflows called Zaps let you connect your critical apps to AI and thousands of other tools. In this tutorial, you'll learn how to connect OpenAI to your lead management tools, so you provide a personalized buying experience at scale.

Looking for GPT-4 or OpenAI's other latest models? 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. Discover popular ways to use the ChatGPT Zapier integration.

Before you begin

In this tutorial, you'll create a Zap that will use OpenAI's GPT-3 to gather more information about your new lead and attach it to a contact record in your customer relationship management (CRM) tool. 

You'll need the following:

  • An OpenAI account and API key: You'll need this to 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. 

  • A lead source with at least one submission: Your lead source should ask for information that will help GPT-3 gather more context about your lead. For example, this could be the company's name, website, or the lead's social media handle. I'm using Typeform for this tutorial. 

  • A CRM tool that tracks leads and sales activity: I'm using HubSpot, which requires that a user has administrator permissions to connect to Zapier. You can search for your app within our App Directory or Help Center to see what permissions you'll need.

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 use OpenAI to enrich lead information

This tutorial will help you practice using some handy Zapier tricks. You can create your own Zap from scratch with our point-and-click editor, but we also have quick templates to get you started. If you don't have a Zapier account yet, it's free to get started

Enrich new Typeform entries with OpenAI and add a note in HubSpot

Enrich new Typeform entries with OpenAI and add a note in HubSpot
  • Typeform logo
  • OpenAI (GPT-4, DALL-E, Whisper) logo
  • HubSpot logo
Typeform + OpenAI (GPT-4, DALL-E, Whisper) + HubSpot

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.

How to create this Zap from scratch: 

  1. Connect your lead source and form to trigger your Zap

  2. Add an OpenAI action and customize your prompt

  3. Add an action to search for existing CRM records

  4. Add an action to attach a note to your lead

Connect your lead source and form to trigger your Zap

We'll start by creating the trigger—the event that starts a Zap. Select your lead source app and the event you want to use, which will usually be something like New Entry or New Submission

If you're following along, select Typeform as the app and New Entry as the event, and click Continue.  

Select Typeform and the New Entry event that will trigger the Zap.

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.

Then, select the form you want to use for this Zap, click Continue, and test your trigger. Zapier will look for an existing submission, which we'll use to set up the rest of this Zap. 

Test the trigger in the Zap editor and review the app data returned.

Once you see a success message, click Continue

Add an OpenAI step and customize your prompt

Next, create your action, which is the event your Zap performs once it's triggered. In this step, GPT-3 will use the new submission from your lead to generate more information.

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

Select OpenAI and the Send Prompt event for the action.

Connect your OpenAI account to Zapier if you haven't before. You'll need to provide an API key you created and saved earlier. Click Continue once you've connected your account. 

Now you need to provide OpenAI with instructions—or a prompt—for the information you need it to collect. We'll use the gpt-3.5-turbo-instruct model, already pre-selected in the editor. 

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.

The prompt will consist of two parts: 

  1. The specific instructions for GPT-3: In the example below, I want GPT-3 to use the information in the Typeform submission to describe the problem my lead wants to solve and use their company website to generate potential talking points for the sales team. I limited GPT-3 to three sentences so it will be easy to scan. 

  2. Information about our lead that will help GPT-3 find additional context. For this prompt, I included the lead's name, email, company, and website. Since I also want OpenAI to generate sales talking points, I included the lead's request as well. 

The prompt should include text instructions and form data from the trigger.

I generally like to include headings in my prompts to differentiate between the prompt and app data I want the AI to use. Plus, it helps structure the prompt so you're not using more tokens than necessary.

GPT-3 is trained on data from the internet up to 2021. That means it can provide additional context when your prompt includes things that are searchable on the internet, such as websites or social media handles. Note that the information may be less accurate for anything after 2021. You can check here to see which model is using the most recent training data

Beneath the response heading, map values from your Zap's trigger. This is how you'll provide the lead data OpenAI needs for information gathering. Click inside the Prompt field and select the dynamic values from your trigger to use. 

Map trigger data to use in the prompt field.

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.

Once you've completed your prompt, there are additional options you can customize to get the outcome you want: 

  • Temperature: You can lower the Temperature value for more predictable responses from GPT-3 or increase it for more creative responses. My example calls for more creativity, so I kept the default value.

  • Maximum Length: By default, OpenAI sets this to 256 tokens. I don't need to increase this for my example, but you can adjust the limit if you think your prompt and completion will exceed this.

  • Stop Sequences: This tells OpenAI when to stop generating tokens. For example, if you don't want it to cut off in the middle of a sentence because it hit the max token length, you can set a period as a stop sequence. My example is pretty short, so I didn't need one here, but check out this help doc from OpenAI if you want to learn more about using stop sequences.

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

Tokens help OpenAI's GPT-3 (Generative Pre-trained Transformer 3) language models assign meaning and predict the next likely text. Tokens are about four characters long, on average. You can use OpenAI's Tokenizer tool to see how many tokens your prompt uses.

Once you're done, click Continue and test your action.  

If it's successful, look closely at the results to ensure OpenAI provided the additional lead information you wanted. 

Test the OpenAi action step and review the results.

If you think OpenAI's intel-gathering needs more work, you can go back to the previous step, tweak your prompt, and retest until you're satisfied with the results. Once it looks right, click Continue

Add an action to search for existing CRM records

Before you attach the AI-provided information to your lead, you need to add a search step to check for an existing contact record in your CRM. This helps prevent duplicate CRM records and ensures this new information is associated with a contact and company so it's easy to find. 

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.

Select your CRM app and the search action you want to use. Search actions for CRM apps will usually be something like Find Contact.

If you're following along, select the HubSpot app and Find Contact as the event, then click Continue.  

Select HubSpot and the Find Contact event for this Zap step.

Select your app account, or connect it to Zapier if you haven't before, and click Continue

Next, you need to set the specific search criteria Zapier will use to check your CRM records. 

No matter which CRM tool you use, you'll need to specify the contact property you want Zapier to check and the value to look for. 

Click on the First search property name field and select the contact property you want to search. In this example, I want to search by the contact's email address. 

Select the HubSpot property to search.

Since you want to use the information your new lead provided to search your CRM records, click on First search property value field and field map a dynamic value from your trigger.

For this example, I selected the email address my lead provided in my Typeform trigger.

Map trigger data to use for the search value.

Your CRM may allow you to set a backup property and value to search in case it can't find anything. If you'd like to set this up, go ahead and do so. 

Below, I've set up this step to search the company and website properties as a backup if it can't find the specified email address in HubSpot. 

Add up to three backup searches.

If your CRM lets you search for existing records and create new ones in the same step, you'll see a checkbox asking if you want to create a new record if it doesn't exist. Click the checkbox since we want this new lead in our CRM. 

Click the checkbox to create a contact in the same step, if one can't be found.

If your app doesn't have this option, don't worry. Be sure to set Should this step be considered a success if nothing was found? to Yes.  Finish creating and testing your search step. You can add a path step—available on Professional plans and up—to create one path that creates records if none exist. Learn more about using paths and search steps.

If you click the checkbox, the Zap editor will prompt you to customize what should go in your new contact record. 

Customize the new HubSpot contact the Zap step will create.

Map the fields from your lead source to the appropriate contact properties. Don't worry about mapping anything from OpenAI—we'll do that in the next step. 

Quick tip: Since CRMs have dozens of properties, you can use Command+F (Mac) or Ctrl+F (Windows) in the Zap editor to jump to the specific fields you want to fill out. This will save you some scrolling! 

Once you've configured everything, click Continue. Next, test the search step and review the results. When you test this step, Zapier will search for an existing record. If it doesn't exist and you've set it up to do so, it will also create a new record.

Note: If you searched and created a new item in the same step, _Zap_data_was_found will still be false since the contact didn't exist before the current Zap run. This helps Zapier better differentiate between existing information and new data.

Test the search step and review the results.

If your test created a contact record, go to your CRM and check that it was created correctly. 

Check HubSpot to review the contact created.

If you see a failure message in the Zap editor instead and you know the contact record exists, go back to the previous step, adjust your search criteria, and retest. 

Once you've verified that your search step works, click Continue

Add an action to attach a note to your lead

Finally, you'll create the final step of this Zap, which will create and attach a note to your lead with the information OpenAI generated. 

Depending on your CRM app, you may have an action that lets you create notes or you may need to use a webhook to do so. 

If you're following along, select the HubSpot app and the Create Engagement event, then click Continue

Select HubSpot and the Create Engagement event for the Zap step.

Need to use a webhook to create a note in your CRM? Learn how to add a webhook to your CRM in this tutorial

HubSpot will ask if you want to prevent this task from proceeding if it can't associate this note with the specified records. By default, this will be False, which is what we want. 

Select False to allow the Zap to proceed.

Then, click on the dropdown under Engagement Type and select Note

Select Note for the Engagement Type.

If you want a specific person to see the note, you can use custom values to dynamically assign the lead's contact owner to the note. 

If your search step found an existing contact record, click on the Assigned to field, select your CRM search step, and map the Contact Owner value. 

Select the Contact Owner from the previous Zap step.

Since I created this contact record in the previous search step, I don't have an owner assigned to this lead yet. HubSpot and many CRM apps won't return empty fields, which can pose a problem if you need to use a particular field in a Zap. 

Fortunately, we can solve this issue using a command to generate a placeholder value. That way, you can assign this note to a contact owner every time this Zap runs. 

Here's how: 

  1. Click on your search step in the Zap editor. 

  2. Then, copy the step ID from your browser's address bar. The step ID will be the set of characters after https://zapier.com/editor/{ZAP ID}/draft/ starting with _GEN_ or a number.

  3. Return to your Create Engagement step and click the Assigned To field. 

  4. Click on the Custom tab and enter the following command: {{your-step-id__name of your contact owner field}}

The Zap editor will automatically generate a placeholder value from the previous step, indicated by the app icon and step number. 

Use a command to map missing fields from previous Zap steps.

Whew. Now for creating the actual note. You can add a mix of static text and dynamic values mapped from previous Zap steps. This is where we'll add our AI-generated lead info. 

Click on the Note Body field, select the previous OpenAI action, and click on the Choices Text value to map to the note. 

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

Map the result from the GPT-3 prompt to the note body.

In this example, I also included one of the responses from my lead form. If you're a HubSpot user, you can format notes with rich text with simple HTML in the Note Body field.

Use a mix of text, dynamic values, and HTML tags to format the note.

You can also connect related CRM records to your note, such as emails, contacts, deals, and more. 

In the example below, I want to associate the note to my lead, so I've mapped their email address from the previous search step. 

Map the contact email value.

I also want to attach this note to their contact record. Click on the Id's of the contact objects that should be associated with engagement, click on the Custom tab, then select the contact's ID from the previous search step. 

Map the contact ID value.

You can associate products, deals, and other types of records to your note if you'd like. Once you're done, click Continue.

Finally, test this step. Zapier will create a new note and attach it to the specified records. If everything works, you'll see a success message. 

Test the Zap step and review the results of the created note.

Be sure to check your CRM record to see how your note looks.

The action will create a HubSpot note and attach it to a contact.

If everything looks okay, your Zap is ready to use!

AI and automation: The dynamic duo for enriching leads

AI and automation can research your leads and provide additional context for your sales and marketing teams, so you can focus on delivering a better buyer experience. Zapier lets you connect OpenAI to business-critical processes so you can work more efficiently.

Get productivity tips delivered straight to your inbox

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

tags
mentioned apps

Related articles

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

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