← back to Dw Signup Fulfillment

send-kelly-reply.js

39 lines

#!/usr/bin/env node
'use strict';
// One-shot: send Kelly's TK-10830 reply via George (info@ / steve-office) to the live thread.
// RUN AFTER: (1) her Shopify customer exists (kcyounge@gmail.com) and (2) /claim has sent the
// verify letter — so the "we've just sent a confirmation link" line below is TRUE at send time.
// Usage (Steve, via `!`):  cd ~/Projects/dw-signup-fulfillment && DRY_RUN=0 node send-kelly-reply.js
// DRY_RUN defaults ON; pass DRY_RUN=0 to actually send. Creds resolve from secrets-manager/.env
// (GEORGE_AUTH) + george-gmail/.env (GEORGE_EXTERNAL_SEND_TOKEN) via lib/config.js.
const email = require('./lib/email');
const fs = require('fs');
const path = require('path');

// One-shot guard: this reply already SENT (twice) on 2026-09-02. Refuse further sends
// so an accidental re-run can't spam Kelly. Delete the sentinel below to deliberately resend.
const SENT_FLAG = path.join(__dirname, '.kelly-reply-tk10830.sent');
if (fs.existsSync(SENT_FLAG) && process.env.FORCE_RESEND !== '1') {
  console.error('ABORT: Kelly reply already sent (sentinel .kelly-reply-tk10830.sent). Set FORCE_RESEND=1 to override.');
  process.exit(1);
}

const to = 'kyounge@umich.edu';
const subject = 'Re: Your Designer Wallcoverings samples — your 3 free swatches';
const html = [
  '<p>Hi Kelly,</p>',
  '<p>Thank you for your patience — and apologies the sign-up email didn\'t reach you. You\'re all set now.</p>',
  '<p>Your <b>3 free retail samples are on us</b>. At checkout just use code <b>3FREE</b> — it covers three sample swatches (a $4.25 value each), and <b>sample shipping is on us too</b>, so you\'ll pay nothing. Add the swatches to your cart, apply <b>3FREE</b>, and see them in your space before you commit.</p>',
  '<p style="color:#555">(That $25 you saw earlier was a shipping estimate — it won\'t apply to these complimentary samples.)</p>',
  '<p>Anything else I can help you find? We carry over 200 of the finest design houses in one place, and I\'m happy to point you toward pieces like the Majilite Finesse you were viewing.</p>',
  '<p>Warmly,<br>The Designer Wallcoverings Team<br>DesignerWallcoverings.com · (888) 373-4564</p>',
].join('\n');

(async () => {
  const r = await email.sendEmail({ to, subject, html, source: 'kelly-reply-tk10830' });
  console.log('send result:', JSON.stringify(r));
  if (r && r.ok === false) { console.error('SEND FAILED — not sent.'); process.exit(1); }
  if (r && !r.dryRun) { try { fs.writeFileSync(SENT_FLAG, new Date().toISOString() + '\n'); } catch (_) {} }
  console.log(r && r.dryRun ? 'DRY_RUN — nothing sent (re-run with DRY_RUN=0 to send).' : 'SENT to ' + to);
})().catch(e => { console.error('error:', e.message); process.exit(1); });