Logging Guitar Practice over WhatsApp with Twilio
How a one-line WhatsApp reply became a logged practice session, and the Twilio webhook lessons that made it reliable.
Guitar Practice Tracker is live at guitarpracticeapp.co.uk. WhatsApp logging went live in production on 24 November 2026.
1. The problem
I run Guitar Practice Tracker, an app for guitarists who want to practise consistently. The whole product depends on one habit: logging the session. If you don’t log, your weekly streak breaks, your goal progress is wrong, and the app stops being useful.
The app already sent email reminders on a schedule each user sets. The trouble is what happens next. A reminder lands, you pick up the guitar, you play for 30 minutes, and then you have to open the app, find the quick log, pick a type and type a number. Plenty of sessions never got logged because that last step felt like admin. I wanted logging to cost one message: the reminder arrives on WhatsApp, you reply 30 scales, and the app answers with your week’s total and your streak.

App -> Hi Steve, it's time for your guitar practice. Reply with minutes and what you worked on, for example "30 scales".
Me -> 30 scales
App -> Logged 30 min of scales. 195 of 210 min this week. Streak: 31 weeks. Send UNDO to remove it.
I kept the scope deliberately small: no LLM parsing, no editing by reply, no SMS. One webhook, a strict parser, four commands (LINK, HELP, STOP, UNDO), and reminders on email, WhatsApp or both.
2. Prerequisites
To build something similar, you’ll need:
- A Twilio account on a paid plan. The WhatsApp sandbox isn’t in the new Console (more on that below), so testing runs on a registered sender.
- A WhatsApp Business Account linked to a Meta Business Portfolio. You create it during Twilio’s WhatsApp sender self sign-up.
- A Twilio phone number registered as a WhatsApp sender. It can’t already be in use on WhatsApp or the WhatsApp Business app.
- An approved WhatsApp message template for messages outside the 24-hour window, sent by its Content SID.
- A public HTTPS URL for the webhooks. Locally, that means a tunnel such as ngrok.
- Your Twilio Account SID and Auth Token, and the Twilio helper library for your language (this post uses
twilio/sdkfor PHP).
3. Architecture
The app is Laravel with an Inertia and React frontend. Reminders were already a scheduled, queued pipeline sending email, so WhatsApp plugs into that job as a second channel. Replies come in through one signed webhook that logs through the same action the web app uses.


4. How it works
Linking a number with one message
When a user turns on WhatsApp in settings, the page shows a six-digit code and a wa.me link pre-filled with LINK 834291. Sending it proves they own the number, records their opt-in, and opens WhatsApp’s 24-hour service window, all in one step. There’s no phone number form and no separate verification service. The app stores only a hash of the code, which expires after 15 minutes.


Replying with TwiML, in the same request
Every inbound message hits POST /webhooks/twilio/whatsapp. The route sits outside Laravel’s web middleware group (no sessions, CSRF or Inertia) and runs Twilio’s signature check before anything else. The handler parses the message, logs the session, and answers in the webhook response itself:
$twiml = new MessagingResponse;
$twiml->message($body);
return response((string) $twiml, 200, ['Content-Type' => 'text/xml']);
There’s no second REST call and no queue hop, and the reply is inside the service window by definition, because the user just wrote in. The parser is strict on purpose: 30 scales, 1h30 songs wonderwall intro and 45 (reusing your last practice type) all log, and anything else gets a hint rather than a guessed session. A wrong log is worse than no log.
Twilio can deliver the same message more than once, so the transaction’s first statement inserts the MessageSid into a uniquely indexed table. A violation means “already handled”: empty TwiML, nothing logged twice. Rows keep an outcome and reason code, never the text, and are pruned after 30 days.
Commands
HELP (or ?) lists the formats. UNDO removes the last session logged by reply, within 15 minutes. STOP turns off WhatsApp reminders, and they fall back to email.

Reminders through the REST API
Outbound reminders go from the existing queued job through Twilio’s REST API. If the user has written in within the last 23 hours, the reminder is a free-form message. Outside that, WhatsApp requires an approved template, so the job sends one by Content SID:
$this->client->messages->create('whatsapp:'.$to, [
'from' => $this->from,
'contentSid' => $contentSid,
'contentVariables' => json_encode(['1' => $firstName]),
]);
If WhatsApp isn’t usable (not linked, opted out, or the send throws), a user who chose WhatsApp only still gets the reminder by email.
5. What I had to get right
There’s no WhatsApp sandbox in the new Console
My plan was to build and demo on the Twilio WhatsApp sandbox and keep my registered sender for production. But the WhatsApp sandbox wasn’t migrated to the new Twilio Console, so every end-to-end test had to run on an approved account with a registered sender. That meant getting the reminder template approved early, and pointing a live sender’s webhooks at my laptop through a tunnel (ngrok with a static domain).
Validate the signature against the request exactly as sent
Twilio signs the full public URL and the POST parameters. Two things changed what my app saw before the check ran. Laravel’s global TrimStrings middleware trims input even on routes outside the web group, so any reply with a trailing space or newline from a phone keyboard failed the HMAC. The fix was to exempt the webhook:
$isWebhook = fn (Request $request): bool => $request->is('webhooks/*');
$middleware->trimStrings(except: [$isWebhook]);
$middleware->convertEmptyStringsToNull(except: [$isWebhook]);
And the tunnel terminates TLS, so without trusted proxies configured locally $request->url() began http:// while Twilio had signed https://. Setting TRUSTED_PROXIES=127.0.0.1 locally fixed it (production already trusted its proxy).
A WhatsApp sender has two inbound webhooks
During testing, a few messages (HELP, ?, one UNDO) got no reply. Twilio’s log showed them as received with no error, but my app had no record of them. The per-message page for the lost UNDO gave it away: “TwiML Fetched” after 1.42 seconds. Twilio had fetched TwiML, just not from me.

The sender’s webhook pointed at my app, but the phone number’s own messaging URL (SmsUrl) still had Twilio’s default demo URL, and inbound WhatsApp messages were routed through one or the other. Once both pointed at the app, the next batch of five messages had five matching rows in my database, each with the right reply. Setting both is now part of the switch-on checklist.
The routing had one more trap at switch-on. I moved both webhooks from my tunnel to production, and both read back with the new URL. The first message got a reply. The second didn’t: Twilio still sent some messages through the sender’s old webhook, to my closed tunnel, and logged them as received with error 11200. Twilio doesn’t retry those, so two of my first four production messages were lost. It settled within about 20 minutes, and every message since has been answered within two seconds.
The lesson: one test message proves nothing, because it may take the route you already fixed. Keep the old endpoint up until traffic stops arriving there, and keep sending until several in a row reach you.
”PII off” doesn’t mean “request body off”
Every Twilio webhook carries the user’s message text and phone number, so I was careful about where they could end up. The app reports errors to Sentry with send_default_pii off, and I assumed that kept both out. The SDK source said otherwise: that flag covers IPs, cookies and headers, but the parsed POST body goes with every event, which here means Body, From and WaId. A route middleware now strips request data from webhook events, and a test fails without it.
6. Results
- Every flow works in production: linking, logging,
HELP,UNDO,STOP, and both reminder paths (free-form inside the window, the template outside it). - The reminder template was approved as Utility on the first submission, within minutes. One tip: Twilio uses the sample value if a variable can’t be rendered, so my sample for
{{1}}isthere(“Hi there, …”) rather than a real name that could reach a stranger. - Privacy held: the app never stores message bodies, and tests prove the phone number stays out of logs and error reports.
- Switching on was configuration only: the Twilio variables and two webhook URLs. The only trouble was the routing delay above.
7. The reusable pattern
Let the user’s first message do the work. One inbound LINK message proves number ownership, records consent and opens the 24-hour window, so the app can reply free-form straight away and the user never fills in a form.
And one integration habit worth borrowing: keep one row per MessageSid. It’s your de-duplication, and it doubles as monitoring. A message Twilio shows as received with no matching row in your app means something else answered it.
8. Wrapping up
The goal was to make logging cost one message, and now it does: the reminder arrives on WhatsApp, you reply 30 scales, and the app logs it and answers with your week’s total and streak. Twilio carries both directions, the REST API for reminders and one signed webhook for replies. Most of the effort went into making that webhook trustworthy: validating the signature against the request as sent, de-duplicating by MessageSid, keeping message text out of logs, and pointing both inbound webhooks at the app.
WhatsApp logging is live now. If you play guitar, sign up at guitarpracticeapp.co.uk, turn on WhatsApp in Settings, and log your next session with one reply.