# n8n workflow test report: TTC Online enrollment to GoHighLevel

**Workflow:** `ttc-online-enrollment-ghl.n8n.json` (19 nodes)
**Tested on:** self-hosted n8n 1.123, 18 Nov 2026
**Input:** the same fields as the live TTC Online sign-up form (tobiastutorialcenterlms.com): child's full name, grade, parent/guardian name, parent email, parent mobile, an optional message to the center, and the terms checkbox. The workflow adds the UTM from the ad and an idempotency key.
**API used in the test:** a local mock of the GoHighLevel API v2. It enforces the `Version: 2021-07-28` header, a Bearer token, `locationId` on contact upsert, `tags` on Add Tags, and the required opportunity fields. Like GHL, its upsert matches an existing contact by email, then by phone. It can be switched into a 503 outage.

## What it does

A parent signs up for the TTC Online 3-day free trial. The workflow then:

1. Validates the sign-up with the live form's rules: the child's first and last name, a grade that is open for TTC Online (Preschool to Grade 6 now), the parent/guardian name, a valid email, a valid PH mobile number, and the accepted terms.
2. Normalizes the data: names are capitalized, the email is lowercased, the mobile becomes `+63` format, and the optional message is read for needs (exam review, reading help, SSES class).
3. Dedupes the sign-up:
   - A replayed webhook (same idempotency key) is ignored.
   - **One free trial per child**, as on the live site: the same child with the same parent email **or** mobile is stopped, and nothing in GHL is touched.
   - A different child of the same parent is a **sibling**: it gets its own trial under the same parent contact.
4. Scores the family and tags it by grade band, needs and source.
5. Upserts the parent contact in GHL, with the child, grade, needs and the parent's message as custom fields. Tags are added with the Add Tags endpoint, so a sibling's tags never replace the first child's.
6. Creates one trial opportunity per child.
7. Starts the GHL trial follow-up workflow.
8. Alerts the teacher on duty with the parent's message when the family needs exam review, reading help or the SSES curriculum, or came from a referral.
9. On any GHL failure, retries 3 times, then saves the sign-up to a dead-letter queue, alerts ops, and replies 202 to the parent.

## Results (7 cases, all as designed)

| # | Case | Response | Result |
|---|------|----------|--------|
| 1 | New parent from the Facebook reel: Miguel Reyes, Grade 4, message "He has a long test in Math next week." | `200 {newParent: true, newChild: true}` | Upsert, tags (`need:exam`), opportunity, follow-up and teacher alert all ran. Mobile `0917 555 0142` became `+639175550142` |
| 2 | Same webhook delivered twice | `200 {duplicate: true}` | No GHL calls |
| 3 | Sibling: same parent, Ana Reyes, Grade 1, message "She is still learning to read." | `200 {newParent: false, newChild: true}` | Same contact. `need:reading` and Grade 1 tags added to the existing tags. Second opportunity, follow-up and alert |
| 4 | Miguel Reyes again, with a different email but the same mobile | `200 {ok: false, alreadyTrial: true}` | Stopped: one free trial per child. No GHL calls, so the parent's email on file was not changed |
| 5 | Child's last name missing, Grade 8 (closed), broken email, terms not ticked | `400` with all four errors | Rejected before any API call |
| 6 | CRM outage (503): referral family, Bea Dela Paz, Grade 6, SSES class | `202 {queued: true}` | 3 attempts, then dead-letter queue and ops alert. The parent still got a friendly reply |
| 7 | Same request retried after recovery | `200 {newParent: true}` | The idempotency key and child keys were released on failure, so the retry went through cleanly. Teacher alert: "set up the SSES curriculum" |

Screenshots of executions #63 (new), #64 (replay), #65 (sibling), #66 (trial already used) and #68 (outage) are in `screenshots/`.

## Every API call, in order

| Time (UTC) | Call | Version |
|---|---|---|
| 03:00:07 | `POST /contacts/upsert` | 2021-07-28 |
| 03:00:07 | `POST /contacts/ct1/tags` | 2021-07-28 |
| 03:00:07 | `POST /opportunities/` | 2021-07-28 |
| 03:00:07 | `POST /contacts/ct1/workflow/REPLACE_WITH_TRIAL_FOLLOWUP_WORKFLOW_ID` | 2021-07-28 |
| 03:00:07 | `POST /alert` | - |
| 03:00:08 | `POST /contacts/upsert` | 2021-07-28 |
| 03:00:08 | `POST /contacts/ct1/tags` | 2021-07-28 |
| 03:00:08 | `POST /opportunities/` | 2021-07-28 |
| 03:00:08 | `POST /contacts/ct1/workflow/REPLACE_WITH_TRIAL_FOLLOWUP_WORKFLOW_ID` | 2021-07-28 |
| 03:00:08 | `POST /alert` | - |
| 03:00:08 | `POST /contacts/upsert` | 2021-07-28 |
| 03:00:10 | `POST /contacts/upsert` | 2021-07-28 |
| 03:00:12 | `POST /contacts/upsert` | 2021-07-28 |
| 03:00:12 | `POST /alert` | - |
| 03:00:12 | `POST /contacts/upsert` | 2021-07-28 |
| 03:00:12 | `POST /contacts/ct4/tags` | 2021-07-28 |
| 03:00:12 | `POST /opportunities/` | 2021-07-28 |
| 03:00:12 | `POST /contacts/ct4/workflow/REPLACE_WITH_TRIAL_FOLLOWUP_WORKFLOW_ID` | 2021-07-28 |
| 03:00:12 | `POST /alert` | - |

## Before going live

1. Fill in the **Config** node with a Private Integration token (scopes `contacts.write`, `opportunities.write`), the location ID, the pipeline ID, the "Trial started" stage ID, the trial follow-up workflow ID and the alert webhook.
2. Create these contact custom fields in GHL: `child_name`, `grade_level`, `needs`, `parent_message`, `lead_score`, `first_touch_source`, `first_touch_campaign`, `terms_accepted`.
3. Keep the open grades in the Validate node in step with the grades the admin accepts in the LMS.
4. Set `GENERIC_TIMEZONE=Asia/Manila` on the n8n instance. In GHL, set quiet hours (9pm to 8am) on the SMS steps, and add a goal event "Payment confirmed" that ends the follow-up.
5. Keep SMS wording carrier-safe: never use the words "username", "password", "PIN" or "code" (send sign-in details as `u:` and `p:`).
6. Activate the workflow and point the sign-up form at `/webhook/trial`.
