WhatsApp in eleven lines
18 July 2025
A gateway process turns WhatsApp into HTTP in both directions, and the entire app-side library fits on a page:
method text($to, $text) => $this->request('text', to: $to, text: $text)
method voice($to, file $file) => $this->request('voice', to: $to, audio: $file->src)
method poll($to, $name, array $options, bool $multi = false) => $this->request('poll', to: $to, name: $name, options: $options, multi: $multi)
Text, image, location, document, voice, polls, reactions, read receipts and typing indicators: one line each, all going through a single request() that adds the shared secret and posts to the gateway.
Starting an instance is one line too, naming the number, the port, the secret and the webhook URL that inbound messages should reach. Incoming messages arrive as a normal route, so answering a WhatsApp message uses the same tools as answering a web request: the same models, the same views, the same session.
What keeps it small is the split. The gateway knows WhatsApp and nothing else, so all the awkwardness of the platform, media decryption, session persistence, connection state, stays in the process built for it. The app never imports a WhatsApp library and never learns its object model.
That boundary is also the insurance. The underlying client library is somebody else's project moving at its own pace, and when it changes the gateway absorbs it.