Rates each new lead in your spreadsheet against the customer profile you describe and appends the rating with its reasoning.
Uses
Google Sheets
OpenAI
Rate new leads against your ideal customer profile
leadsSheetUrl to blank.Set leadsSheetUrl to blank.leadsTabName to blank.Set leadsTabName to blank.ratingsTabName to blank.Set ratingsTabName to blank.idealCustomerProfile to blank.Set idealCustomerProfile to blank.maxRowsRead to 300.Set maxRowsRead to 300.maxLeadsPerRun to 20.Set maxLeadsPerRun to 20.ratedKeys to an empty list.Set ratedKeys to an empty list.ratedEmails to an empty list.Set ratedEmails to an empty list.ratingsTabErrorIf a step below fails, save the error as ratingsTabErrorTry
ratingsTabName in leadsSheetUrl. Save it as ratingsRead.Read column 'A' of ratingsTabName in leadsSheetUrl. Save it as ratingsRead.ratedEmails to ratingsRead.values.Change ratedEmails to ratingsRead.values.On error
loggedEmail in ratedEmails:For each loggedEmail in ratedEmails:loggedEmailErrorIf a step below fails, save the error as loggedEmailErrorTry
loggedEmail in lowercase to the end of ratedKeys and save it as ratedKeys.Add loggedEmail in lowercase to the end of ratedKeys and save it as ratedKeys.On error
leadsSheetUrl. Save it as leadsRead.Read the rows of leadsSheetUrl. Save it as leadsRead.ratedThisRun to 0.Set ratedThisRun to 0.lead in leadsRead.rows:For each lead in leadsRead.rows:ratedThisRun is greater than or equal to maxLeadsPerRunIf ratedThisRun is greater than or equal to maxLeadsPerRunYes
No
No steps
company to blank.Set company to blank.leadEmail to blank.Set leadEmail to blank.leadNotes to blank.Set leadNotes to blank.leadIsReadable to false.Set leadIsReadable to false.rowErrorIf a step below fails, save the error as rowErrorTry
lead.Company and save it as company.Trim lead.Company and save it as company.lead.Email and save it as leadEmail.Trim lead.Email and save it as leadEmail.lead.Notes and save it as leadNotes.Trim lead.Notes and save it as leadNotes.leadIsReadable to the length of company is greater than 0 and the length of leadEmail is greater than 0 and the length of leadNotes is greater than 0.Change leadIsReadable to the length of company is greater than 0 and the length of leadEmail is greater than 0 and the length of leadNotes is greater than 0.On error
leadIsReadable is noIf leadIsReadable is noYes
Skipped a lead whose Company, Email or Notes cell is empty. Fill them in and it will be rated on the next run..Show in the output: Skipped a lead whose Company, Email or Notes cell is empty. Fill them in and it will be rated on the next run..No
No steps
leadEmail is a valid email address is noIf leadEmail is a valid email address is noYes
No
No steps
leadEmail lowercase and save it as leadKey.Make leadEmail lowercase and save it as leadKey.ratedKeys contains leadKeyIf ratedKeys contains leadKeyYes
No
No steps
ratingErrorIf a step below fails, save the error as ratingErrorTry
prompt to You are helping a sales rep decide which leads to work first. You are rating how well one lead fits the customer profile below. You are not deciding anything about the company itself.Set prompt to You are helping a sales rep decide which leads to work first. You are rating how well one lead fits the customer profile below. You are not deciding anything about the company itself.
Reply in exactly this shape, and nothing else:
RATING: one of Strong fit, Possible fit, Weak fit
WHY: what in this lead's details lines up with the profile, and what does not
UNKNOWN: what the details do not say that would change the rating
Rules you must follow:
- The first line must be RATING: followed by exactly one of those three phrases and nothing else.
- Judge only what the details below actually say. Call a thing unknown rather than assuming it, and never invent facts about the company.
- Rate fit with the profile, not the worth of the business. A weak fit is a lead for somebody else, not a bad company.
The ideal customer profile:
idealCustomerProfile
The lead:
Company: company
Email: leadEmail
What we know: leadNotes.prompt. Save it as answered.Ask OpenAI: prompt. Save it as answered.answered.response_text and save it as answer.Trim answered.response_text and save it as answer.answer is emptyIf answer is emptyYes
company. It will be tried again on the next run.Show in the output: No rating came back for company. It will be tried again on the next run.No
answer by a new line and save it as answerLines.Split answer by a new line and save it as answerLines.answerLines with RATING: replaced by (ignoring case) lowercase and save it as ratingWord.Make the first item of answerLines with RATING: replaced by (ignoring case) lowercase and save it as ratingWord.rating to Unclear.Set rating to Unclear.ratingWord is strong fitIf ratingWord is strong fitYes
rating to Strong fit.Change rating to Strong fit.No
No steps
ratingWord is possible fitIf ratingWord is possible fitYes
rating to Possible fit.Change rating to Possible fit.No
No steps
ratingWord is weak fitIf ratingWord is weak fitYes
rating to Weak fit.Change rating to Weak fit.No
No steps
answerLines joined by a new line and save it as reasoning.Trim the items from index 1 onward of answerLines joined by a new line and save it as reasoning.rating is Unclear or reasoning is emptyIf rating is Unclear or reasoning is emptyYes
reasoning to answer.Change reasoning to answer.No
No steps
ratingsTabName in leadsSheetUrl.Add a row to ratingsTabName in leadsSheetUrl.ratedThisRun.Add 1 to ratedThisRun.leadKey to the end of ratedKeys and save it as ratedKeys.Add leadKey to the end of ratedKeys and save it as ratedKeys.On error
company: ratingError as text.Show in the output: Could not rate company: ratingError as text.