askmywa

For developers

Server mode and webhooks

On your computer, askmywa archives your messages for your assistant. On a server, it can instead work for one trusted app of yours: for example a personal assistant app that drafts replies and lets you send them on one click. Three options, each off by default, make it a second linked device that keeps nothing and only does what that app needs.

your app ── one text, with a secret ──>  askmywa  ──>  WhatsApp
your app <── each new message, signed ──  askmywa  <──  WhatsApp
            (private network only)       (keeps no message)

Nothing leaves by accident. The door sends one text to one person and nothing else, under per-minute and per-day caps, and never sends twice under the same key. The preview and your approval stay in your app: it shows you the recipient and the exact text, and calls askmywa only after your click.

Send-only: it keeps no message

--send-only (or ASKMYWA_SEND_ONLY=1) stores no live message, no history sync and no copy of what is sent. Only the WhatsApp session and contact names are kept (and group names). It refuses --legacy-store, since there is no history to import into.

The HTTP door

--http-addr ADDR (or ASKMYWA_HTTP_ADDR) serves three operations over plain HTTP. The secret is read from ASKMYWA_HTTP_TOKEN only: at least 32 characters, never a command-line flag, so it never shows in ps. Every request needs Authorization: Bearer <secret>.

RequestAnswer
GET /v1/status{"connected": true, "logged_in": true, "send_only": true}
GET /v1/contact?phone=%2B33600000001The name you gave that number in your address book, or null. A push or business name is chosen by the other person, so it never vouches for a number.
POST /v1/sendOne text to one person: {"to", "text", "idempotency_key"} and nothing else. No group, no file. The text leaves exactly as given, up to 4,000 characters. Answers {"message_id", "timestamp"}.
export ASKMYWA_HTTP_TOKEN=…   # the same secret your app holds

curl -s http://askmywa.internal:8080/v1/status \
  -H "Authorization: Bearer $ASKMYWA_HTTP_TOKEN"

curl -s -G http://askmywa.internal:8080/v1/contact \
  --data-urlencode 'phone=+33600000001' \
  -H "Authorization: Bearer $ASKMYWA_HTTP_TOKEN"

curl -s http://askmywa.internal:8080/v1/send \
  -H "Authorization: Bearer $ASKMYWA_HTTP_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"to":"+33600000001","text":"I will be there at 7.","idempotency_key":"draft-0001"}'

Encode the + in the query (%2B, or curl -G --data-urlencode): a bare + reads as a space and the number is refused.

  • No preview at the door. POST /v1/send sends at once. Your app shows the preview and asks for your approval before it calls the door.
  • The same key is never sent twice, even after a failed or cut-off send: WhatsApp may have taken it, so the outcome is unknown and the door answers 409 instead of retrying. Keys and counters live in memory for 24 hours; a restart forgets them.
  • Caps. At most ASKMYWA_HTTP_SENDS_PER_MINUTE (default 5) and ASKMYWA_HTTP_SENDS_PER_DAY (default 40) sends. Past them the door answers 429 and sends nothing. Not connected: 503, nothing sent. WhatsApp did not confirm: 502, and the key is spent.

Webhooks

--webhook-url URL (or ASKMYWA_WEBHOOK_URL) posts each live message to your app, as JSON. The history sync is not posted. Messages you send from your phone are posted too, with from_me set. It works with send-only: the message reaches your app and askmywa keeps nothing.

  • What is sent: type ("message"), id, timestamp, from_me, chat (jid, name, is_group), sender (phone, lid, name, name_source), text and, for an attachment, its media type, file name and MIME type. Never the attachment itself.
  • Signed: the secret comes from ASKMYWA_WEBHOOK_SECRET only (32+ characters). Each request carries X-Askmywa-Event-Id, X-Askmywa-Timestamp (Unix seconds) and X-Askmywa-Signature: sha256= followed by the hex HMAC-SHA256 of timestamp + "." + body. The URL must be http(s), without credentials in it.
  • In order, retried: one event at a time, retried with backoff (1 second, doubling up to about 4 minutes) until your app answers 2xx. A 4xx other than 408 or 429 drops the event. The queue lives in memory, up to 2,000 events with the oldest dropped past that: a restart loses what was not delivered yet.

Verify the signature over the raw body, refuse a timestamp older than five minutes, then ignore an event id you already have:

import hashlib, hmac, time

def verify(secret: str, headers: dict, body: bytes) -> bool:
    ts = headers.get("X-Askmywa-Timestamp", "")
    sig = headers.get("X-Askmywa-Signature", "")
    if not ts.isdigit() or abs(time.time() - int(ts)) > 300:
        return False  # older than five minutes: refuse
    mac = hmac.new(secret.encode(), ts.encode() + b"." + body, hashlib.sha256)
    return hmac.compare_digest(sig, "sha256=" + mac.hexdigest())

Run it with Docker

whatsapp-go/Dockerfile builds the send-only server: data on the /data volume, door on [::]:8080, and an entrypoint that gives the volume to an unprivileged askmywa user, then drops root. Set ASKMYWA_HTTP_TOKEN on the service (and the webhook variables if you want them). Pair it once from a shell in the container, then type the code in WhatsApp › Linked devices › Link a device › Link with phone number instead:

askmywa link --phone <your number>

Security, in short

  • Private network only. The door has no TLS and does not choose who can reach it. Give the service no public domain and reach it from your app over a private network.
  • Secrets in the environment. ASKMYWA_HTTP_TOKEN and ASKMYWA_WEBHOOK_SECRET are read from the environment only, never from a flag, and must hold at least 32 characters.
  • Send-only keeps no message. The volume holds the session and contact and group names, nothing else.
  • Capped sends. 5 a minute and 40 a day unless you change them; one text to one person; never twice for the same key.
  • Signed webhooks. Your app can prove each event came from askmywa and refuse a replay.
  • Quiet logs. A failed send is logged without the recipient or the text.

Read this before you deploy.

  • Ban risk. A linked device on a datacenter address is not what WhatsApp expects, and WhatsApp's terms do not allow unofficial clients. WhatsApp could restrict or ban the account.
  • Keep the volume low. Keep the caps tight and send only what you approved yourself.
  • You can cut it off. Unlinking the device from your phone (WhatsApp › Linked devices) stops it at once.

Full reference: the README on GitHub.