Skip to content

Quiz Email Worklog

1. Why Cloud Run → Google Sheet stalled

  • The original plan routed quiz submissions through growth-quiz-writer on Cloud Run and then captured each lead in a Google Sheet so the team could inspect scores and tiers. A curl POST to https://growth-quiz-writer-825297113896.asia-southeast1.run.app kept returning HTTP 403 (Forbidden), and neither Netlify nor Cloud Run logged the invocation because the service never received a valid request.
  • Running gcloud run services add-iam-policy-binding growth-quiz-writer --member="allUsers" --role="roles/run.invoker" --region="asia-southeast1" --project=growth-archetype-quiz failed with PERMISSION_DENIED on locations/asia-southeast1. The command was authenticated as the org owner, but an organization policy disallows the binding, so Cloud Run stayed locked down and nothing reached the Google Sheet.
  • Because the Cloud Run service never recorded any quiz attempts, we stopped pursuing that route and built the recording logic inside this repo (netlify/functions/record-quiz.js) so we can iterate locally and observe Netlify logs.

2. Netlify function + MailerSend relay

  • Netlify now receives every quiz submission and calls email-quiz-lead.js, which talks to MailerSend. Early attempts to test the new endpoint produced {"message":"Invalid JSON"} because the JSON payload included stray newlines. The reliable pattern is to dump the payload into a temporary file via printf and let curl -d @/tmp/quiz-payload.json send it.
  • MailerSend trial accounts introduced their own guardrails. After switching to the new flow we saw {"message":"Trial accounts can only send emails to the administrator's email. #MS42225","errors":{"to":["Trial accounts can only send emails to the administrator's email. #MS42225"],"from.email":["The from.email domain must be verified in your account to send emails. #MS42207"]}}. The fix was to:
    1. Set the to address equal to the MailerSend administrator email (the same as GROWTHQUIZ_EMAIL_TO during development).
    2. Verify the sender domain inside MailerSend so that from.email is allowed.
  • Once those toggles were in place, the same curl command returned {"message":"Email sent"} and Netlify logs recorded record-quiz invoking the relay for the submitted email.

3. Testing checklist

  1. Run the docs preview (npm run docs:preview) and visit /en/quizzes/revenue-ops/.
  2. Enter a work email, answer the seven questions, and confirm the final tier screen appears with a status message like Sending your Revenue Ops diagnostic....
  3. Inspect the Netlify record-quiz logs; they should show Triggering email relay for <email> and Email relay succeeded for <email>.
  4. To reproduce the quiz payload manually, use this safe shell snippet:
bash
printf '%s' '{"email":"moses@growthflowengineering.xyz","answers":[5,3,1,5,3,1,5],"score":27,"tier":{"label":"Functional but Unstable Revenue Ops","description":"Growth is unpredictable and valuation multiples are suppressed.","action":"Align rituals, reporting, and incentives across GTM pods."}}' >/tmp/quiz-payload.json
curl -X POST https://websitegfe.netlify.app/.netlify/functions/email-quiz-lead \
  -H "Content-Type: application/json" \
  -H "x-growth-quiz-secret: GFEgfe@123#" \
  -d @/tmp/quiz-payload.json
  1. MailerSend trial mode still requires that the verified administrator address matches the to field and that the sender domain is verified before any mail can go out.

4. Result & next steps

  • The Revenue Ops quiz now mirrors the Growth Archetype flow: email capture first, sequential question hub, tier summary, and MailerSend relay. The frontend sums the numeric responses, chooses a tier, displays the copy, and sends { email, answers, score, tier } to record-quiz.
  • When you build future quizzes, copy docs/en/quizzes/quiz-template.md, update the question values, and keep reusing the record-quiz + MailerSend helper. If you eventually need to write to Sheets or another datastore again, extend record-quiz before the email call so no single path blocks the email relay.