n8n workflow: Qualify new leads in Google Sheets via OpenAI's GPT-4

Nodes:
name: Merge
type: n8n-nodes-base.merge
parameters: mode: combine
combinationMode: mergeByPosition
name: Sticky Note
type: n8n-nodes-base.stickyNote
parameters: width: 442
height: 360.6357827476038
content: ### 1. Create a Google Sheet document
* This template uses Google Sheet document connected to Google Forms, but a standalone Sheet document will work too
* Adapt initial trigger to your needs: check for new entries periodically or add a manual trigger

[Link to the Google Sheet template](https://docs.google.com/spreadsheets/d/1jk8ZbfOMObvHGGImc0sBJTZB_hracO4jRqfbryMgzEs)
name: Sticky Note1
type: n8n-nodes-base.stickyNote
parameters: width: 471
height: 322
content: ### 2. Provide lead qualification instructions
* Create a __system message__ with overall instructions
* Add a __user message__ with the JSON variables
* Set node parses the resulting JSON object, but you can also request a plain string response in the system message
name: Sticky Note2
type: n8n-nodes-base.stickyNote
parameters: width: 355
height: 269.81214057507987
content: ### 3. Combine the initial data with GPT response
* This Merge node puts together original records from the google sheet and responses from the OpenAI
name: Sticky Note3
type: n8n-nodes-base.stickyNote
parameters: width: 398
height: 265
content: ### 4. Update the Google Sheet document
* Provide __Column to Match On__ (usually a timestamp in case of Google Forms)
* Enter the result from GPT into a separate column
name: Update lead status
type: n8n-nodes-base.googleSheets
parameters: columns: value: Rating: ={{ $json.reply.rating }}
Timestamp: ={{ $json.Timestamp }}
schema: type: string
display: yes
removed: no
required: no
displayName: Timestamp
defaultMatch: no
canBeUsedToMatch: yes
type: string
display: yes
removed: yes
required: no
displayName: Email Address
defaultMatch: no
canBeUsedToMatch: yes
type: string
display: yes
removed: yes
required: no
displayName: Your name
defaultMatch: no
canBeUsedToMatch: yes
type: string
display: yes
removed: yes
required: no
displayName: Your business area
defaultMatch: no
canBeUsedToMatch: yes
type: string
display: yes
removed: yes
required: no
displayName: Your team size
defaultMatch: no
canBeUsedToMatch: yes
type: string
display: yes
required: no
displayName: Rating
defaultMatch: no
canBeUsedToMatch: yes
type: string
display: yes
removed: yes
readOnly: yes
required: no
displayName: row_number
defaultMatch: no
canBeUsedToMatch: yes
mappingMode: defineBelow
matchingColumns: Timestamp
operation: update
sheetName: __rl: yes
mode: list
value: 72739218
cachedResultUrl: https://docs.google.com/spreadsheets/d/1jk8ZbfOMObvHGGImc0sBJTZB_hracO4jRqfbryMgzEs/edit#gid=72739218
cachedResultName: Form Responses 1
documentId: __rl: yes
mode: list
value: 1jk8ZbfOMObvHGGImc0sBJTZB_hracO4jRqfbryMgzEs
cachedResultUrl: https://docs.google.com/spreadsheets/d/1jk8ZbfOMObvHGGImc0sBJTZB_hracO4jRqfbryMgzEs/edit?usp=drivesdk
cachedResultName: Join Community (Responses)
name: Extract JSON reply
type: n8n-nodes-base.set
parameters: fields: values: name: reply
type: objectValue
objectValue: ={{ JSON.parse($json.message.content) }}
include: selected
name: Qualify leads with GPT
type: n8n-nodes-base.openAi
parameters: prompt: messages: system: Your task is to qualify incoming leads. Leads are form submissions to a closed community group. Use the following criteria for a quality lead:

1. We are looking for decision makers who run companies or who have some teams. The bigger the team - the better. Basically, everyone with some level of responsibility should be accepted. This is the main criterion.
2. Email from a non-standard domain. Ideally this should be a corporate domain, but this is a secondary criterion.

Please thing step by step whether a lead is quality or not?

If at least one of the criteria satisfy, reply with "qualified" in response. Otherwise reply "not qualified". Reply with a JSON of the following structure: {"rating":"string","explanation":"string"}. Reply only with with the JSON and nothing more!
content: =Here's a lead info:
Name: {{ $json['Your name'] }}
Email: {{ $json['Email Address'] }}
Business area: {{ $json['Your business area'] }}
Size of the team: {{ $json['Your team size'] }}
options: temperature: 0.3
resource: chat
chatModel: gpt-4-turbo-preview
name: Check for new entries
type: n8n-nodes-base.googleSheetsTrigger
parameters: event: rowAdded
pollTimes: item: everyMinute
sheetName: __rl: yes
mode: list
value: 72739218
cachedResultUrl: https://docs.google.com/spreadsheets/d/1jk8ZbfOMObvHGGImc0sBJTZB_hracO4jRqfbryMgzEs/edit#gid=72739218
cachedResultName: Form Responses 1
documentId: __rl: yes
mode: list
value: 1jk8ZbfOMObvHGGImc0sBJTZB_hracO4jRqfbryMgzEs
cachedResultUrl: https://docs.google.com/spreadsheets/d/1jk8ZbfOMObvHGGImc0sBJTZB_hracO4jRqfbryMgzEs/edit?usp=drivesdk
cachedResultName: Join Community (Responses)

Connections:
Merge: main: node: Update lead status
type: main
Extract JSON reply: main: node: Merge
type: main
Check for new entries: main: node: Merge
type: main
node: Qualify leads with GPT
type: main
Qualify leads with GPT: main: node: Extract JSON reply
type: main