Emails each customer about their purchase in your tone, reads their feedback first, and adds a coupon when the feedback is negative.

UsesClaudeGmailGoogle Sheets

Thank happy customers and win back unhappy ones with a coupon

Once a day, your sheet of purchases and feedback is read, AI works out whether each customer's feedback is positive, neutral or negative, and each one gets a personalised email from your own Gmail account in the tone you choose. Negative feedback earns an apology and a coupon code; everyone else gets a thank you that answers what they said.

Your sheet is never changed; a separate 'Emails sent' tab records one line per email: address, product, how the feedback was read, whether a coupon went out and the subject. That tab is checked before every send, so nobody is emailed twice about the same purchase, and if it cannot be written after a send the run stops at once. Rows with no feedback yet wait until it arrives, rows with a bad address are reported and skipped, and no coupon is ever offered on the thank you path. Each run sends a capped number of emails.

Your sheet needs 'Name', 'Email', 'Product' and 'Feedback' columns, plus a coupon code and what it is worth.

ScheduleRun every day.Run every day.
ValuesSet sheetUrl to blank.Set sheetUrl to blank.
ValuesSet sheetTabName to blank.Set sheetTabName to blank.
ValuesSet businessName to blank.Set businessName to blank.
ValuesSet senderName to blank.Set senderName to blank.
ValuesSet emailTone to warm and friendly.Set emailTone to warm and friendly.
ValuesSet couponCode to blank.Set couponCode to blank.
ValuesSet couponDetails to blank.Set couponDetails to blank.
ValuesSet optOutLine to blank.Set optOutLine to blank.
ValuesSet sentLogTabName to Emails sent.Set sentLogTabName to Emails sent.
ValuesSet maxEmailsPerRun to 1.Set maxEmailsPerRun to 1.
ValuesSet sentLogIsNew to true.Set sentLogIsNew to true.
Decisions & LoopsIf a step below fails, save the error as createLogTabErrorIf a step below fails, save the error as createLogTabError
Try
Google SheetsGoogle SheetsCreate the tab sentLogTabName in sheetUrl.Create the tab sentLogTabName in sheetUrl.
On error
ValuesChange sentLogIsNew to false.Change sentLogIsNew to false.
Decisions & LoopsIf sentLogIsNew is yesIf sentLogIsNew is yes
Yes
Google SheetsGoogle SheetsAdd a row to sentLogTabName in sheetUrl.Add a row to sentLogTabName in sheetUrl.
No
No steps
ValuesSet alreadyEmailed to an empty list.Set alreadyEmailed to an empty list.
ValuesSet sentLogKeys to an empty list.Set sentLogKeys to an empty list.
Decisions & LoopsIf a step below fails, save the error as sentLogReadErrorIf a step below fails, save the error as sentLogReadError
Try
Google SheetsGoogle SheetsRead column 'A' of sentLogTabName in sheetUrl. Save it as sentLog.Read column 'A' of sentLogTabName in sheetUrl. Save it as sentLog.
ValuesChange sentLogKeys to sentLog.values.Change sentLogKeys to sentLog.values.
On error
Decisions & LoopsStop and report a problem: Could not read the '@sentLogTabName' tab, so there is no way to tell which customers have already been emailed. Nothing was sent. Check the spreadsheet, then run it again.Stop and report a problem: Could not read the '@sentLogTabName' tab, so there is no way to tell which customers have already been emailed. Nothing was sent. Check the spreadsheet, then run it again.
Decisions & LoopsFor each loggedKey in sentLogKeys:For each loggedKey in sentLogKeys:
Decisions & LoopsIf a step below fails, save the error as loggedKeyErrorIf a step below fails, save the error as loggedKeyError
Try
ListsAdd loggedKey in lowercase to the end of alreadyEmailed and save it as alreadyEmailed.Add loggedKey in lowercase to the end of alreadyEmailed and save it as alreadyEmailed.
On error
ValuesShow in the output: Ignored a cell in the '@sentLogTabName' tab that is not text.Show in the output: Ignored a cell in the '@sentLogTabName' tab that is not text.
ValuesSet sentThisRun to 0.Set sentThisRun to 0.
ValuesSet couponsSent to 0.Set couponsSent to 0.
ValuesSet alreadyEmailedRows to 0.Set alreadyEmailedRows to 0.
ValuesSet waitingForFeedbackRows to 0.Set waitingForFeedbackRows to 0.
ValuesSet skippedRows to 0.Set skippedRows to 0.
ValuesSet sendFailures to 0.Set sendFailures to 0.
Google SheetsGoogle SheetsRead the rows of sheetUrl. Save it as customerSheet.Read the rows of sheetUrl. Save it as customerSheet.
Decisions & LoopsIf customerSheet.count is 0If customerSheet.count is 0
Yes
ValuesShow in the output: No rows were found in the '@sheetTabName' tab. Check the tab name, and that the sheet has a header row with Name, Email, Product and Feedback columns followed by at least one purchase.Show in the output: No rows were found in the '@sheetTabName' tab. Check the tab name, and that the sheet has a header row with Name, Email, Product and Feedback columns followed by at least one purchase.
No
No steps
Decisions & LoopsFor each row in customerSheet.rows:For each row in customerSheet.rows:
Decisions & LoopsIf sentThisRun is greater than or equal to maxEmailsPerRunIf sentThisRun is greater than or equal to maxEmailsPerRun
Yes
Decisions & LoopsStop repeating.Stop repeating.
No
No steps
ValuesSet rowLabel to row row.row_number as text.Set rowLabel to row row.row_number as text.
ValuesSet customerName to blank.Set customerName to blank.
ValuesSet customerEmail to blank.Set customerEmail to blank.
ValuesSet product to blank.Set product to blank.
ValuesSet feedback to blank.Set feedback to blank.
ValuesSet rowIsReadable to true.Set rowIsReadable to true.
Decisions & LoopsIf a step below fails, save the error as rowErrorIf a step below fails, save the error as rowError
Try
TextTrim row.Name and save it as customerName.Trim row.Name and save it as customerName.
TextTrim row.Email and save it as customerEmail.Trim row.Email and save it as customerEmail.
TextTrim row.Product and save it as product.Trim row.Product and save it as product.
TextTrim row.Feedback and save it as feedback.Trim row.Feedback and save it as feedback.
On error
ValuesChange rowIsReadable to false.Change rowIsReadable to false.
Decisions & LoopsIf rowIsReadable is noIf rowIsReadable is no
Yes
ValuesShow in the output: Skipped rowLabel: the sheet needs Name, Email, Product and Feedback columns, spelled exactly like that, and one of them is missing.Show in the output: Skipped rowLabel: the sheet needs Name, Email, Product and Feedback columns, spelled exactly like that, and one of them is missing.
ValuesAdd 1 to skippedRows.Add 1 to skippedRows.
Decisions & LoopsSkip to the next item.Skip to the next item.
No
No steps
Decisions & LoopsIf not customerEmail is a valid email addressIf not customerEmail is a valid email address
Yes
ValuesShow in the output: Skipped rowLabel: the Email cell is empty or does not hold an email address.Show in the output: Skipped rowLabel: the Email cell is empty or does not hold an email address.
ValuesAdd 1 to skippedRows.Add 1 to skippedRows.
Decisions & LoopsSkip to the next item.Skip to the next item.
No
No steps
Decisions & LoopsIf feedback is emptyIf feedback is empty
Yes
ValuesAdd 1 to waitingForFeedbackRows.Add 1 to waitingForFeedbackRows.
Decisions & LoopsSkip to the next item.Skip to the next item.
No
No steps
ValuesSet sendKey to customerEmail in lowercase | product in lowercase.Set sendKey to customerEmail in lowercase | product in lowercase.
Decisions & LoopsIf alreadyEmailed contains sendKeyIf alreadyEmailed contains sendKey
Yes
ValuesAdd 1 to alreadyEmailedRows.Add 1 to alreadyEmailedRows.
Decisions & LoopsSkip to the next item.Skip to the next item.
No
No steps
TextShorten feedback to 1500 characters and save it as feedbackForPrompt.Shorten feedback to 1500 characters and save it as feedbackForPrompt.
ValuesSet sentimentPrompt to You are reading feedback a customer left after buying a product. Decide the overall sentiment of the feedback.Set sentimentPrompt to You are reading feedback a customer left after buying a product. Decide the overall sentiment of the feedback. positive - they are pleased with the product or the experience neutral - mixed, matter-of-fact, or too little to tell either way negative - they are disappointed or frustrated, or something went wrong Reply with EXACTLY one of these words and nothing else: positive, neutral, negative. Product: product Feedback: feedbackForPrompt.
ClaudeClaudeAsk Claude: sentimentPrompt. Save it as sentimentAnswer.Ask Claude: sentimentPrompt. Save it as sentimentAnswer. Maximum response length: 16
ValuesSet sentiment to unclear.Set sentiment to unclear.
Decisions & LoopsIf a step below fails, save the error as sentimentErrorIf a step below fails, save the error as sentimentError
Try
TextMake sentimentAnswer.response_text with . replaced by lowercase and save it as sentiment.Make sentimentAnswer.response_text with . replaced by lowercase and save it as sentiment.
On error
ValuesChange sentiment to unclear.Change sentiment to unclear.
Decisions & LoopsIf sentiment is not positive and sentiment is not neutral and sentiment is…If sentiment is not positive and sentiment is not neutral and sentiment is…
Yes
ValuesShow in the output: Skipped rowLabel (customerEmail): could not tell whether the feedback is positive, neutral or negative. It will be tried again on the next run.Show in the output: Skipped rowLabel (customerEmail): could not tell whether the feedback is positive, neutral or negative. It will be tried again on the next run.
ValuesAdd 1 to skippedRows.Add 1 to skippedRows.
Decisions & LoopsSkip to the next item.Skip to the next item.
No
No steps
ValuesSet customerNameForPrompt to customerName.Set customerNameForPrompt to customerName.
Decisions & LoopsIf customerNameForPrompt is emptyIf customerNameForPrompt is empty
Yes
ValuesChange customerNameForPrompt to not known.Change customerNameForPrompt to not known.
No
No steps
ValuesSet productForPrompt to product.Set productForPrompt to product.
Decisions & LoopsIf productForPrompt is emptyIf productForPrompt is empty
Yes
ValuesChange productForPrompt to not recorded - refer to it as their recent purchase.Change productForPrompt to not recorded - refer to it as their recent purchase.
No
No steps
ValuesSet customerContext to Business: businessNameSet customerContext to Business: businessName Customer's name: customerNameForPrompt What they bought: productForPrompt What they said in their feedback: feedbackForPrompt Tone to write in: emailTone Sign off as: senderName.
ValuesSet subject to blank.Set subject to blank.
ValuesSet body to blank.Set body to blank.
ValuesSet couponFlag to no.Set couponFlag to no.
Decisions & LoopsIf sentiment is negativeIf sentiment is negative
Yes
ValuesSet couponLine to Coupon code couponCode - couponDetails.Set couponLine to Coupon code couponCode - couponDetails.
ValuesSet couponSubjectPrompt to Write the subject line for a short email from businessName to a customer whose feedback about their purchase was negative.Set couponSubjectPrompt to Write the subject line for a short email from businessName to a customer whose feedback about their purchase was negative. customerContext The email apologises for what went wrong, shows that their feedback was read, and offers a coupon to make it right. Do not put the coupon code in the subject line. Rules: under 60 characters, no quotation marks, no emoji, no placeholders such as [Name]. Write in the tone given above. Reply with the subject line only.
ClaudeClaudeAsk Claude: couponSubjectPrompt. Save it as couponSubjectAnswer.Ask Claude: couponSubjectPrompt. Save it as couponSubjectAnswer. Maximum response length: 60
Decisions & LoopsIf a step below fails, save the error as couponSubjectErrorIf a step below fails, save the error as couponSubjectError
Try
TextTrim couponSubjectAnswer.response_text and save it as subject.Trim couponSubjectAnswer.response_text and save it as subject.
On error
ValuesChange subject to blank.Change subject to blank.
ValuesSet couponBodyPrompt to Write the body of a short email (under 170 words) from businessName to a customer whose feedback about their purchase was negative.Set couponBodyPrompt to Write the body of a short email (under 170 words) from businessName to a customer whose feedback about their purchase was negative. customerContext Apologise sincerely and specifically for what they described, without being defensive or making excuses, and thank them for telling you. Then offer them this coupon as an apology, quoting the code exactly as written: couponLine. Rules: plain text only - no subject line, no markdown, no bullet points and no placeholders such as [Name]. Write in the tone given above. If the customer's name is not known, open with a plain greeting rather than inventing one. Do not invent facts about the product or the order. Do not promise a refund, a replacement or anything beyond the coupon. Sign off as senderName. Reply with the email body only.
ClaudeClaudeAsk Claude: couponBodyPrompt. Save it as couponBodyAnswer.Ask Claude: couponBodyPrompt. Save it as couponBodyAnswer. Maximum response length: 700
Decisions & LoopsIf a step below fails, save the error as couponBodyErrorIf a step below fails, save the error as couponBodyError
Try
TextTrim couponBodyAnswer.response_text and save it as body.Trim couponBodyAnswer.response_text and save it as body.
On error
ValuesChange body to blank.Change body to blank.
Decisions & LoopsIf body isn't empty and body doesn't contain couponCode (ignoring case)If body isn't empty and body doesn't contain couponCode (ignoring case)
Yes
ValuesChange body to bodyChange body to body couponLine.
No
No steps
ValuesChange couponFlag to yes.Change couponFlag to yes.
No
ValuesSet thanksSubjectPrompt to Write the subject line for a short follow-up email from businessName to a customer, thanking them for a recent purchase.Set thanksSubjectPrompt to Write the subject line for a short follow-up email from businessName to a customer, thanking them for a recent purchase. customerContext The email thanks them, shows that their feedback was read, and invites them to shop with businessName again. Rules: under 60 characters, no quotation marks, no emoji, no placeholders such as [Name]. Write in the tone given above. Reply with the subject line only.
ClaudeClaudeAsk Claude: thanksSubjectPrompt. Save it as thanksSubjectAnswer.Ask Claude: thanksSubjectPrompt. Save it as thanksSubjectAnswer. Maximum response length: 60
Decisions & LoopsIf a step below fails, save the error as thanksSubjectErrorIf a step below fails, save the error as thanksSubjectError
Try
TextTrim thanksSubjectAnswer.response_text and save it as subject.Trim thanksSubjectAnswer.response_text and save it as subject.
On error
ValuesChange subject to blank.Change subject to blank.
ValuesSet thanksBodyPrompt to Write the body of a short follow-up email (under 150 words) from businessName to a customer, thanking them for a recent purchase.Set thanksBodyPrompt to Write the body of a short follow-up email (under 150 words) from businessName to a customer, thanking them for a recent purchase. customerContext Thank them for their purchase, respond in a sentence or two to what they said in their feedback, and warmly invite them to shop with businessName again. Rules: plain text only - no subject line, no markdown, no bullet points and no placeholders such as [Name]. Write in the tone given above. If the customer's name is not known, open with a plain greeting rather than inventing one. Do not invent facts about the product or the order. Do not offer a discount, a coupon or a refund. Sign off as senderName. Reply with the email body only.
ClaudeClaudeAsk Claude: thanksBodyPrompt. Save it as thanksBodyAnswer.Ask Claude: thanksBodyPrompt. Save it as thanksBodyAnswer. Maximum response length: 700
Decisions & LoopsIf a step below fails, save the error as thanksBodyErrorIf a step below fails, save the error as thanksBodyError
Try
TextTrim thanksBodyAnswer.response_text and save it as body.Trim thanksBodyAnswer.response_text and save it as body.
On error
ValuesChange body to blank.Change body to blank.
TextTrim subject with replaced by " and save it as subject.Trim subject with replaced by " and save it as subject.
TextTrim body with ** replaced by and save it as body.Trim body with ** replaced by and save it as body.
Decisions & LoopsIf subject is empty or body is emptyIf subject is empty or body is empty
Yes
ValuesShow in the output: Skipped rowLabel (customerEmail): no usable subject line or email body came back. It will be tried again on the next run.Show in the output: Skipped rowLabel (customerEmail): no usable subject line or email body came back. It will be tried again on the next run.
ValuesAdd 1 to skippedRows.Add 1 to skippedRows.
Decisions & LoopsSkip to the next item.Skip to the next item.
No
No steps
Decisions & LoopsIf optOutLine isn't blankIf optOutLine isn't blank
Yes
ValuesChange body to bodyChange body to body optOutLine.
No
No steps
ValuesSet emailSent to true.Set emailSent to true.
Decisions & LoopsIf a step below fails, save the error as sendErrorIf a step below fails, save the error as sendError
Try
GmailGmailSend an email to customerEmail.Send an email to customerEmail. Subject: subjectbody
On error
ValuesChange emailSent to false.Change emailSent to false.
ValuesShow in the output: Could not send to customerEmail (rowLabel): sendError as text.Show in the output: Could not send to customerEmail (rowLabel): sendError as text.
Decisions & LoopsIf emailSent is noIf emailSent is no
Yes
ValuesAdd 1 to sendFailures.Add 1 to sendFailures.
Decisions & LoopsSkip to the next item.Skip to the next item.
No
No steps
Decisions & LoopsIf a step below fails, save the error as logWriteErrorIf a step below fails, save the error as logWriteError
Try
Google SheetsGoogle SheetsAdd a row to sentLogTabName in sheetUrl.Add a row to sentLogTabName in sheetUrl.
On error
Decisions & LoopsStop and report a problem: Sent the email to customerEmail but could not add it to the '@sentLogTabName' tab. The run stopped here so that nobody is emailed twice on the next run - fix the spreadsheet, then run it again.Stop and report a problem: Sent the email to customerEmail but could not add it to the '@sentLogTabName' tab. The run stopped here so that nobody is emailed twice on the next run - fix the spreadsheet, then run it again.
ListsAdd sendKey to the end of alreadyEmailed and save it as alreadyEmailed.Add sendKey to the end of alreadyEmailed and save it as alreadyEmailed.
ValuesAdd 1 to sentThisRun.Add 1 to sentThisRun.
Decisions & LoopsIf couponFlag is yesIf couponFlag is yes
Yes
ValuesAdd 1 to couponsSent.Add 1 to couponsSent.
No
No steps
ValuesShow in the output: Sent sentThisRun as text email(s) this run, couponsSent as text with a coupon. alreadyEmailedRows as text row(s) had already been emailed, waitingForFeedbackRows as text row(s) have no feedback yet, skippedRows as text row(s) were skipped and sendFailures as text send(s) failed. Raise 'maxEmailsPerRun' to send more in one run.Show in the output: Sent sentThisRun as text email(s) this run, couponsSent as text with a coupon. alreadyEmailedRows as text row(s) had already been emailed, waitingForFeedbackRows as text row(s) have no feedback yet, skippedRows as text row(s) were skipped and sendFailures as text send(s) failed. Raise 'maxEmailsPerRun' to send more in one run.