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
Every hour, your leads sheet is read and each new lead is rated against the ideal customer profile you describe, so a rep works the promising ones first. Each rating is a band, 'Strong fit', 'Possible fit' or 'Weak fit', and never arrives alone: alongside it goes the reasoning, what lines up with your profile, what does not, and what the sheet leaves unsaid.
You end up with a ratings tab you can argue with rather than take on trust. The AI is told to judge only what the row says, to call a thing unknown rather than assume it, and to rate fit rather than the worth of the business. Your leads sheet is only ever read. Each rated address is read back at the start of every run, so a lead is never rated twice, and a row missing a company, address or notes is reported and skipped.
Before the first run you need a leads tab with 'Company', 'Email' and 'Notes' columns, a ratings tab headed 'Email', 'Company', 'Rating', 'Why' and 'Rated at', and a description of your ideal customer.
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 ratingsTabErrorratingsTabName 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.loggedEmail in ratedEmails:For each loggedEmail in ratedEmails:loggedEmailErrorIf a step below fails, save the error as loggedEmailErrorloggedEmail 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.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 maxLeadsPerRuncompany 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 rowErrorlead.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.leadIsReadable is noIf leadIsReadable is noSkipped 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..leadEmail is a valid email address is noIf leadEmail is a valid email address is noleadEmail lowercase and save it as leadKey.Make leadEmail lowercase and save it as leadKey.ratedKeys contains leadKeyIf ratedKeys contains leadKeyratingErrorIf a step below fails, save the error as ratingErrorprompt 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 emptycompany. 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.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 fitrating to Strong fit.Change rating to Strong fit.ratingWord is possible fitIf ratingWord is possible fitrating to Possible fit.Change rating to Possible fit.ratingWord is weak fitIf ratingWord is weak fitrating to Weak fit.Change rating to Weak fit.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 emptyreasoning to answer.Change reasoning to answer.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.company: ratingError as text.Show in the output: Could not rate company: ratingError as text.