# Your bot spots it. *You approve it.* From anywhere.

> Trading bot WhatsApp alerts in one POST: crypto price signals, plus approve a trade from your phone with execute/skip buttons. Not financial advice.

Recipe · Trading bots

A trading bot that acts alone at 3 a.m. is a liability; a bot that **proposes** and waits for a human tap is a tool. Two recipes: a market alert that buzzes your phone the moment a threshold breaks (`POST /v1/notify`), and an approve-a-trade loop where the signal arrives with **execute / skip** buttons and nothing happens until you answer (`POST /v1/ask`). The human holds the trigger: that's the whole safety model.

Not financial advice. pingwa relays messages: your bot and your broker do the trading.

Not a bot, just alerts you already set up in TradingView? They need no code: see [TradingView alerts → WhatsApp](/tradingview).

§ 1

## Market alert: the threshold ping

A cron job or the loop your bot already runs checks a price; when it crosses your line, one POST puts it on your phone. The `Idempotency-Key` matters here: a price flapping around 250 would otherwise re-fire every tick. Keyed by threshold and day, the crossing costs you exactly one message per day, however often it wobbles.

price_watch.py: cron or bot loop

```
import datetime, httpx, os

price = get_price("AAPL")  # your data feed: broker API, yfinance, ccxt...
if price >= 250:
    day = datetime.date.today().isoformat()
    httpx.post("https://pingwa.dev/v1/notify",
               headers={"Authorization": f"Bearer {os.environ['PINGWA_KEY']}",
                        "Idempotency-Key": f"aapl-250-{day}"},
               json={"text": f"AAPL crossed 250 — now {price:.2f}"},
               timeout=5)
```

Same shape for a crypto pair: swap the feed for your exchange's ticker endpoint and the key for `eth-3200-…`. pingwa holds each key for 24 hours: an identical retry replays the original result, and a changed body under the same key (the price moved) gets a 409 and sends nothing. Either way a flapping threshold costs you at most one message per key per day.

§ 2

## Approve a trade before it happens

The upgrade from "alert" to "decision": the bot sends its signal as a question with buttons and **long-polls**. The code genuinely stops on that line until you tap or 90 seconds pass (the server maximum). `button_id` is positional: `b0` is the first button you passed, `b1` the second. Only an explicit `b0` places the order.

signal_gate.py: ask before acting

```
import httpx, os

r = httpx.post("https://pingwa.dev/v1/ask",
               headers={"Authorization": f"Bearer {os.environ['PINGWA_KEY']}"},
               json={"text": "Signal: buy 10 ETH @ 3,120 — execute?",
                     "buttons": ["execute", "skip"], "timeout": 90},
               timeout=95)
if r.status_code == 200 and r.json()["reply"]["button_id"] == "b0":
    place_order()   # your broker API — pingwa never touches your money
```

If you don't answer within the 90 seconds, `/v1/ask` returns **HTTP 408**, and the snippet above simply doesn't trade. That's the fail-safe reading: no answer means **skip**, silence never buys anything. The question was still delivered to your phone, and a late tap is retrievable afterwards via `GET /v1/messages/<id>/reply` if your bot runs a slower loop (see the FAQ).

If the ask lands outside your 24h reply window (likely, for signals that arrive out of the blue), the buttons arrive as a numbered list instead of tap buttons. Replying **1** (or the button's text, **execute**) works the same and still maps to `b0`.

§ 3

## Why the human holds the trigger

## The bot proposes. You dispose.

Human-in-the-loop isn't a compromise on automation. For real-money automation it *is* the design. The bot does what bots are good at (watching, computing, never sleeping); the order only exists after a human tap. Every non-answer, timeout and error resolves to the same default: **don't trade**.

Keep the risk checks in the **bot**: position-size limits, max daily loss, sanity bounds on price. Enforce them in your code before the question is ever sent. pingwa relays messages; it is not a risk engine, and a WhatsApp tap should be the *last* gate, not the only one. Not financial advice: your bot decides what to propose, your broker executes, pingwa just carries the question and the tap.

§ 4

## FAQ

### How do I get a trading bot WhatsApp alert?

Snippet § 1: one `httpx.post` to `/v1/notify` from the loop your bot already runs. Text **join** to pingwa to get an API key, set it as `PINGWA_KEY` in the bot's environment, and the next threshold crossing buzzes your phone. Pass an `Idempotency-Key` like `aapl-250-2026-07-16` so a flapping price costs one message, not fifty.

### Can I approve a trade from my phone?

Yes, that's § 2: `POST /v1/ask` with `["execute", "skip"]` buttons holds your bot until you tap, up to 90 seconds. For decisions that can wait hours (a daily rebalance, a swing signal), use the slower loop instead: send the signal with `/v1/ask`, treat the 408 as "pending" rather than skip, store the `message_id`, and poll `GET /v1/messages/<id>/reply` on the bot's next pass. The trade executes whenever you get around to answering, and never before. One rule for late approvals: **re-check the price before placing**. A stale yes shouldn't fill at any price.

### Is there a crypto price alert WhatsApp API?

This is one: your script polls the exchange (ccxt, or the exchange's own ticker endpoint) and POSTs `/v1/notify` when BTC or ETH crosses your line. Same § 1 snippet, different feed. No Twilio, no WABA, no Meta credentials: pingwa carries the message over its own official Meta Cloud API number, and you get the key by sending **join** once.

### What if I don't answer in 90 seconds?

The ask returns HTTP 408 and your bot should treat it as **skip**: fail-safe means silence never places an order. The question stays on your phone; if you tap later, the reply is waiting at `GET /v1/messages/<id>/reply`, so a slower strategy can pick it up on its next cycle instead of discarding it.

[Send “join” on WhatsApp →](https://wa.me/48797882513?text=join%20trading) [More recipes](/use-cases) [Read the API](/docs)

![QR code to join pingwa on WhatsApp](/join.svg?tag=trading&n=48797882513)

Scan the code and get instant access. It opens WhatsApp with “join” ready to send, and your API key comes straight back.

Not financial advice. pingwa relays messages; your bot and your broker do the trading. Signals and approvals are exactly the messages you want rare and deliberate. The free plan's 30 paid messages a month cover a disciplined strategy, and your button-tap replies inside the 24h window are free.
