Marketo ChatGPT Lead Classification

AI tools have exploded in popularity in 2023 and there is not one industry or job role that does not have the opportunity to be improved using these tools. In this blog post, I will show you how we can use ChatGPT in marketing operations use cases to classify leads created in Marketo and to identify bot formfills.

We will be using Marketo webhooks and the Zapier automation tool to query ChatGPT for the classification of new leads created in Marketo and then update these new leads with this classification.

This blog post accompanies the “Demo & Firmo Marketo Lead Scoring Model 3” section from the Marketo Lead Scoring blog post. I highly recommend checking out this blog post to see how you can develop your lead classification prompt for ChatGPT and iteratively test and fine-tune this prompt before moving on to the implementation steps below.

Marketo ChatGPT Lead Classification Video

Making ChatGPT Requests Using Zapier

Filtering Leads Sent to Zapier

As we will see in the next section, we will be using the “New Lead” trigger within the Marketo app in Zapier. If you want to classify every lead created in your Marketo instance then you do not need to do anything within Marketo.

However, if you want to selectively classify leads in Marketo then you will need to set up a smart campaign to add these leads to a static list and then select this list in Zapier (see next section) so that only leads added to this list will be sent to Zapier for classification.

For example, you might not want to send freemails to Zapier for classification since ChatGPT will likely not be able to find much about these people. Additionally, you can also use constraints on the “Person is Created” trigger to only classify people created from certain forms or lists or who are created with a certain “Person Source”.

Screenshot of the smart list criteria used to determine whether to add someone to the static list
Smart list criteria to determine who gets added to the list
Adding people to a static list in Marketo
Adding people to the static list

Classifying Leads using Zapier & ChatGPT

Zapier workflow for lead classification
Zapier workflow for lead classification

The “New Lead” event is used in the Marketo app in Zapier to trigger our classification workflow. As shown in the image below this zap will only trigger for leads added to the “Score with GPT” list in Marketo. We also have the opportunity here to specify any additional fields that we want to be available for the lead that triggers the zap. By default, only the lead’s email, first name, and last name will be pulled in for this trigger.

Configuring the Zap to only trigger when people are added to a list
Configuration to only trigger when people are added to a list

All the information we requested about the lead is then included in our prompt sent to ChatGPT. If you have not connected your ChatGPT account to Zapier yet then you will need to get an API key from your account to complete setup.

Including lead information from Marketo in a ChatGPT prompt
Including lead information from Marketo in a ChatGPT prompt

Don’t be intimidated that there is a Python step in this Zap! As shown in this GPT chat we can actually use ChatGPT to generate the Python code to extract the classification and reason and then all we have to do is copy this code into the Code by Zapier action.

Finally, once we have extracted the fit and reason we can use the “Create/Update” lead action to update the lead by populating their lead quality fields with the GPT classification and reason.

Updating the lead in Marketo with the GPT classification
Updating the lead in Marketo with the GPT classification

Making ChatGPT Requests Using Marketo Webhooks

As shown in the Marketo Webhook Guide with Examples blog post we can also use webhooks in Marketo to make API requests and that means we can make requests to ChatGPT via API from within Marketo.

N.B. If you are unfamiliar with APIs then you should check out the Demystify the API Crash Course to get up to speed quickly with what APIs are and make your first API requests. Even better, if you are a Marketo user then you should check out the Marketo API Crash Course to not only get an introduction to making your first Marketo API requests but also how you can use these to streamline and automate your workflows in Marketo.

Marketo Webhook to make ChatGPT API Requests

As specified in the ChatGPT API docs we will make a POST request to the “completions” endpoint containing the model we want to use and the message content.

https://api.openai.com/v1/chat/completions

{
  "model": "gpt-3.5-turbo",
  "messages": [{"role": "user", "content": "Hello!"}]
}

As shown in the image below we can use lead tokens within the payload template to send information about a Marketo person to ChatGPT for evaluation. Contrary to making ChatGPT requests in Zapier, as shown in the section above, we do not have an easy way in Marketo of parsing the response returned from ChatGPT so we have to tell ChatGPT to give us very specific answers that we can map directly to Marketo fields.

Webhook configuration in Marketo to make an API request to ChatGPT
Webhook configuration in Marketo to make an API request to ChatGPT

Next, we need to specify custom headers for the webhook. You can get your API key from your ChatGPT account here.

Authorization: Bearer xxx
Content-Type: application/json
Configuring custom headers for the ChatGPT API request
Configuring custom headers for the ChatGPT API request

The final part of the webhook configuration is to map the response from ChatGPT to a field in Marketo so that the value can be stored. Looking at the response structure from the ChatGPT request we can see that in order to reference the message content we need to access the first index (index 0 since counting starts at 0 instead of 1) of the choices array parameter, then the message parameter, and finally the content parameter.

{
  "id": "chatcmpl-123",
  "object": "chat.completion",
  "created": 1677652288,
  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "content": "\n\nHello there, how may I assist you today?",
    },
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 9,
    "completion_tokens": 12,
    "total_tokens": 21
  }
}
Storing the response from ChatGPT in a Marketo field
Storing the response from ChatGPT in a Marketo field

Using the Marketo ChatGPT Webhook

Now that you have the webhook configured to make API requests to ChatGPT you can start using this webhook within your smart campaigns in Marketo.

When you go to the activity log of a lead you will be able to click into the “Call Webhook” action to see the detail of the API request sent from Marketo to ChatGPT as well as the response returned from ChatGPT. Similarly, you can click into the “Change Data Value” activity to see that the reason the person’s field value was updated was because of the ChatGPT webhook.

Activity log showing the webhook and change data value actions
Activity log showing the webhook and change data value actions
Details of the ChatGPT API request sent from Marketo
Details of the ChatGPT API request sent from Marketo
Lead classification field updated with value from ChatGPT
Lead classification field updated with value from ChatGPT

Identifying Bot Formfills in Marketo Using ChatGPT

Check out the video below to see how to use Marketo webhooks to send form-fill information to ChatGPT to determine whether the form-fill was made by a bot.

Here is a link to the Google Sheet that I use for iteratively testing prompts and below is the prompt I found most effective at identifying bot form fills.

{
  "model": "gpt-4",
  "messages": [{"role": "user","content": "Given this information submitted to the Telnyx contact sales form please classify this form submission as either “[Genuine]” where it looks like the form was submitted by a human or “[Bot]” where it looks like it was submitted by a robot and the fields contain strings of consecutive random characters. Give a reason for your choice. Please format your answer like so: [[Classification]|[[Reason]]. Please note that the form information has been URL encoded so you will need to decode the content before making your assessment.Full Name: {{lead.Full Name}}, Email: {{lead.Email Address}}, Company Name: {{company.Company Name}}, Phone: {{lead.Form - Phone}}, Website: {{company.Website}}, Additional Information: {{lead.Form - Additional Information}}"}]
}

What’s After Marketo ChatGPT Classification?

Using ChatGPT is only one of the ways for you to score your leads in Marketo. Check out the Marketo Lead Scoring blog post to see 2 other scoring models that you can use for your leads and then see how you can use these scoring models to build a marketing qualification/sales handoff mechanism.

Also if you want to become completely comfortable testing out any API or the Marketo API in particular then you should check out the Demystify the API Crash Course or the Marketo API Crash Course.

Leave a Reply

Your email address will not be published. Required fields are marked *