Codymaster cm-google-form
Google App Script form-to-sheet integration with auto-retry, toast notifications, and Zalo/contact fallback. Reusable across any static website.
install
source · Clone the upstream repo
git clone https://github.com/tody-agent/codymaster
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/tody-agent/codymaster "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/cm-google-form" ~/.claude/skills/tody-agent-codymaster-cm-google-form && rm -rf "$T"
manifest:
skills/cm-google-form/SKILL.mdsource content
Google Forms → Sheet Integration Skill
Connect HTML forms → Google Sheets via Google Apps Script. Auto-retry, toast UI, contact fallback on errors. Zero dependencies, works on any static site.
🎯 When to Use
| Trigger | Action |
|---|---|
| User says "create form", "connect Google Sheet" | Activate this skill |
| User says "form broken", "submit not working" | Debug using Phase 4-5 |
| User says "add new form to page" | Start from Phase 2 |
| User says "form for another website" | Start from Phase 1 |
📋 5-Phase Workflow
Phase 1: DISCOVER → Scan forms, identify fields, determine sheet structure Phase 2: PLAN → Design sheet columns, map form fields, create deployment plan Phase 3: BUILD → Generate Apps Script + Frontend JS + Toast CSS Phase 4: INTEGRATE → Wire forms to JS, add CSS, deploy Apps Script Phase 5: VERIFY → Test submit, test retry, test error fallback
🔴 Rule: NEVER skip Phase 1. Always read existing forms first.
Phase 1: DISCOVER (Scan & Analyze)
Goal: Understand what forms exist and what fields they have.
Actions:
-
Search for forms in the project:
grep -r "data-form-type\|onsubmit\|<form" --include="*.html" . -
For each form found, extract:
| Info | How to Find |
|---|---|
| Form type | attribute |
| Fields | , |
| Submit handler | attribute |
| Page URL | File path |
- Ask user (Socratic Gate):
- How many separate Google Sheets? (1 shared sheet or separate?)
- What columns does each sheet need?
- Is there a fallback contact channel? (WhatsApp, Messenger, Hotline?)
- Fallback contact URL (e.g.,
)https://wa.me/15551234567
Output: Form Inventory Table
| # | Form Type | Pages | Fields | Target Sheet | |---|-----------|-------|--------|-------------| | 1 | massage | 7 | name, phone, branch, problem, time, package | Sheet Massage | | 2 | course | 1 | name, phone, goal | Course Sheet |
Phase 2: PLAN (Design & Map)
Goal: Map form fields → Sheet columns → Apps Script params.
Sheet Column Design
For each sheet, define columns in order:
| Column | Source | Always Include |
|---|---|---|
| Timestamp | — auto | ✅ Yes |
| (form fields) | | From inventory |
| Page Source | | ✅ Yes |
Naming Convention
| Element | Convention |
|---|---|
| Sheet tab name | |
| Form attribute | |
| Hidden URL field | |
| JS global function | |
Deliverables Checklist
- Apps Script code per sheet
- Frontend JS with retry + toast
- Toast CSS component
- HTML form markup template
- Deploy instructions
- Verification test plan
Phase 3: BUILD (Generate Code)
3A. Google Apps Script Template
See
for the full template.templates/apps-script.js
Key rules:
- Always use
— NOTdoPost(e)doGet - Always wrap in
try/catch - Always return JSON with
or{status: "success"}{status: "error", message: "..."} - Column order MUST match
ordersheet.appendRow([...]) - Tab name MUST match
constantSHEET_NAME
3B. Frontend JavaScript
See
for the full template.templates/form-submit.js
Key features:
| Feature | Detail |
|---|---|
| Auto-retry | 3 attempts, exponential backoff (1s → 2s → 4s) |
| Toast UI | Success (green), Error (red), Retrying (amber) |
| Phone validation | Vietnamese format: |
| Button states | "Submitting..." → "Retrying (X/3)..." → reset |
| CORS handling | Handles opaque responses from Apps Script |
| Fallback | Zalo button in error toast |
| Auto-dismiss | Success: 6s, Error: 15s, Retrying: 10s |
3C. Toast CSS
See
for the full template.templates/toast.css
3 variants:
--success, --error, --retrying
3D. HTML Form Markup
See
for examples.templates/form-markup.html
Required attributes:
<form data-form-type="TYPE" onsubmit="window.submitToGoogleSheet(event)"> <input type="hidden" name="url" value=""> <!-- form fields with name="..." --> <button type="submit">Submit Text</button> </form>
Phase 4: INTEGRATE (Wire Everything)
Step-by-step:
- Add Toast CSS → Append to main CSS file (e.g.,
)design-system.css - Add Form JS → Add to shared JS file or create
js/form-handler.js - Update HTML forms:
- Add
attributedata-form-type="..." - Add
onsubmit="window.submitToGoogleSheet(event)" - Add
<input type="hidden" name="url" value=""> - Ensure all inputs have
matching Apps Script paramsname="..."
- Add
- Configure URLs:
- Replace placeholder URLs in JS with deployed Apps Script URLs
- Configure fallback contact:
- Replace Zalo URL in JS toast with project's contact URL
Customization Points
| Setting | Location | Default |
|---|---|---|
| Apps Script URLs | JS object | placeholder |
| Fallback contact | Toast Zalo link | |
| Max retries | arg | 3 |
| Phone regex | Validation block | |
| Toast auto-dismiss | timeouts | 6s/15s/10s |
| Success message | block | Customizable |
| Error message | block | Customizable |
Phase 5: VERIFY (Test & Report)
Test Checklist
| # | Test Case | Expected | Status |
|---|---|---|---|
| 1 | Submit valid form | Toast success (green) + Zalo opens | |
| 2 | Submit invalid phone | Toast error "Invalid phone number" | |
| 3 | Network offline | 3 retries → Toast error with Zalo button | |
| 4 | Check Google Sheet | New row appears with correct data | |
| 5 | Button states | Disabled during submit, resets after | |
| 6 | Toast close button | Toast disappears on click | |
| 7 | Mobile responsive | Toast visible above sticky CTA | |
| 8 | Multiple forms same page | Each form submits independently |
How to Test Retry
- Open DevTools → Network tab
- Block domain
script.google.com - Submit form → Should see 3 retry attempts
- Unblock → Submit again → Should succeed
Report Template
## Form Integration Test Report **Date:** YYYY-MM-DD **Pages tested:** X/Y | Page | Form Type | Submit | Retry | Fallback | Sheet | |------|-----------|--------|-------|----------|-------| | index.html | massage | ✅ | ✅ | ✅ | ✅ | | khoa-hoc.html | course | ✅ | ✅ | ✅ | ✅ | **Issues found:** None / [list issues] **Resolution:** [fixes applied]
❌ Anti-Patterns
| ❌ Don't | ✅ Do |
|---|---|
Use for feedback | Use toast notifications |
| No retry on failure | Auto-retry 3x with backoff |
| Silently fail | Show error + contact fallback |
| Hardcode form URLs | Use config object () |
| Skip phone validation | Validate before submit |
Forget attribute | Every input MUST have |
Use for form submit | Use only |
| Multiple submit handlers | One shared |
📑 Templates
| File | Purpose |
|---|---|
| Google Apps Script doPost handler |
| Frontend JS with retry + toast |
| Toast notification CSS component |
| HTML form examples |
🔗 Related Skills
| Need | Skill |
|---|---|
| Form UI/UX design | |
| SEO for forms | |
| Form security | |
| Deployment | |