Chapter 5

Capstone: Automate Workshop Co.

Contact form → chat webhook + sheet — full API flow.

Capstone objectives

  • Document HTTP flow from form submit to two outbound API calls
  • List headers, payloads, and failure handling
  • Keep secrets off the client

The brief

Workshop Co. contact pipeline

Trigger
Visitor submits contact form on workshopco.ca
Action 1
POST to Rocket.Chat incoming webhook — team sees message
Action 2
Append row to Google Sheet via API — owner audit trail
Non-goals
No LLM yet (that is Book 9 capstone)

Part 1 — sequence diagram (written)

Number steps: browser → Nginx → PHP handler → RC webhook → Sheets API → JSON response to browser.

Model flow
  1. Browser POST application/x-www-form-urlencoded to /contact-submit
  2. PHP validates honeypot + timing; sanitizes fields
  3. PHP POST JSON to Rocket.Chat webhook (server-side cURL)
  4. PHP POST to Google Sheets API with service account JWT
  5. Return {"ok":true} or error without leaking internals

Part 2 — sample webhook payload

Rocket.Chat example
POST $ROCKETCHAT_WEBHOOK_URL
Content-Type: application/json

{
  "text": "**Workshop Co. contact**\nName: Jane Doe\nEmail: jane@example.com\nMessage: March class availability?"
}

Book 8 complete

You speak HTTP — keys, webhooks, automation. Ready for Book 9: LLMs & AI (tokens, context, prompts).

Start Book 9