All apps · 0 apps
telegram-amazon-orders-returns
Docker app from BigWebstas Telegram Amazon Bot's Repository
Overview
Readme
View on GitHubTelegram Amazon Orders & Returns
A personal Telegram bot that polls your own Amazon account for order and
transaction activity, using the unofficial amazon-orders
library (Amazon has no official buyer-facing API). Returns tracking and QR
code delivery are implemented, reverse-engineered from a real walkthrough
— some parts are confirmed, some are still best-effort guesses, see
Returns QR status.
Setup
- Copy
.env.exampleto.envand fill in your Amazon credentials, your Telegram bot token (from @BotFather), and your Telegram chat id (from @userinfobot). - Build the image:
docker compose build - Log in once, interactively, to solve 2FA/CAPTCHA and persist a session:
docker compose run --rm bot python -m amazon_telegram_bot.login_cli - Start the bot:
docker compose up -d
The session cookies and the sqlite tracking DB live under ./data, which is
gitignored and persisted across restarts. If the session ever expires, the
bot will send you a Telegram message telling you to re-run step 3.
Commands
/orders— orders from the last 30 days currently in "Arriving" status. Reads from the local cache the poller keeps updated, so it's as fresh as the last poll cycle (up toPOLL_INTERVAL_MINUTES) rather than a live Amazon lookup - it doesn't call Amazon at all, except automatically once before the very first poll has ever run./orders <year>— all orders for that year, unfiltered. Always live, since a specific year is outside the poller's 30-day cache window./delivered— orders delivered in the last 3 days. Only counts deliveries the bot itself observed while polling (a status transition to "Delivered"), not ones that already happened before it started./transactions— recent account transactions./status— actively checks the Amazon login (not just a cached flag), reports last successful poll time, and sendsbot.logas a file./returns— lists in-progress returns and sends any available QR code. See Returns QR status for what's confirmed vs. still a best-effort guess.
The bot also polls in the background (every POLL_INTERVAL_MINUTES,
default 30) and pushes a message the moment it sees:
- 🆕 a new order placed
- ✅ an order becoming delivered
- 📦 any other shipment status change
- 💳 a new transaction
- 🔄 a return starting, and the QR code the moment one's available
On the very first poll after install, existing orders/transactions are recorded silently instead of all being reported as "new" - only changes from that point on get pushed.
Returns QR status
Implemented, based on two real walkthroughs (2026-09-21) since
amazon-orders doesn't cover returns at all. Confirmed and working:
- Listing in-progress returns from
https://www.amazon.com/your-returns, parsed per return card (<div class="item-return-history-card">), a real, confirmed boundary - not page-wide guessing - Distinguishing a return's own ID (
rmaId) from its order number - one order can have more than one return - Item description, pulled from each card's own product link
(
<a class="a-size-base a-link-normal" href="*/dp/*">), confirmed against multiple real cards - Fetching the QR image, which turned out to be a plain presigned S3 URL, no browser/Playwright needed for this part
- Detecting a completed return via its status text - two confirmed declarative phrasings ("we have issued your refund", "your refund was issued"), checked first and always wins even if the page also still shows "Return in transit" or a QR image, both of which can outlive completion. A shorter "refund issued" phrase was tried and reverted - it's also the label a step timeline uses for an upcoming, not-yet- reached step, which was wrongly excluding genuinely active returns.
- "Return in transit" and "Return by [date]" confirmed as active (non-terminal) status labels
Still a guess, not yet observed directly:
- "Drop off by [date]" as the pre-shipment status text
See amazon_telegram_bot/returns_qr.py's docstring for the full breakdown.
If /returns or a return notification looks off, it's likely one of
these two remaining guesses - report back what you actually see.
Home Assistant (MQTT)
Optional - set MQTT_HOST in .env (or the Unraid template's advanced
settings) to publish three counts to an existing MQTT broker, using Home
Assistant's MQTT Discovery so they appear automatically as sensors under
one device, no configuration.yaml editing needed:
- Active Orders - orders currently "Arriving"
- Returns In Progress - returns not yet completed
- Deliveries (Last 3 Days) - same window
/delivereduses - Delivered Today - deliveries observed since UTC midnight
- Will Be Delivered Today - active orders whose status is exactly "Arriving today"
Published every poll cycle, reusing the orders/returns data already
fetched that cycle rather than issuing extra Amazon requests. Retained
by default (MQTT_RETAIN=true) so HA has a value immediately on
restart instead of waiting for the next poll - set it to false to
publish non-retained instead. Discovery configs and the availability
topic (<MQTT_TOPIC_PREFIX>/status, via MQTT's Last Will, so HA marks
the sensors unavailable if the bot goes down) are always retained
regardless of that setting. Leave MQTT_HOST blank and none of this
runs - no connection attempt, no behavior change.
Unraid (Community Applications)
The published image is ghcr.io/bigwebstas/telegram-amazon-orders-returns:latest,
built automatically by .github/workflows/docker-publish.yml
on every push to main — push this repo to GitHub with that workflow enabled
before installing on Unraid, since nothing is published until it runs once.
- In Unraid, go to Apps → gear icon → Template Repositories and add:
https://github.com/bigwebstas/Telegram-Amazon-Orders-ReturnsThe app then shows up under Apps usingtemplates/telegram-amazon-orders-returns.xml. (Alternatively: Docker → Add Container, and paste the template'sRepositoryvalue and eachConfigvariable in by hand.) - Fill in Amazon email/password, Telegram bot token, and Telegram chat id. Leave Data pointed at its default appdata path — that's where the session cookies and sqlite DB persist.
- Start the container.
- Open the container's Console (click its icon → Console) and run:
to solve 2FA/CAPTCHA interactively, the same as thepython -m amazon_telegram_bot.login_clidocker compose runstep above. - Restart the container from the Docker tab. This step matters: the
main process loads session cookies from disk once at startup, so it won't
pick up the session
login_clijust wrote until it restarts.
Note: both the template and ca_profile.xml (the
repository-level maintainer profile Community Apps requires for official
listing) ship with an empty Icon field — add one (host it in this repo
and update both <Icon> URLs) before publishing this anywhere wider than
your own Unraid box or submitting to the official CA listing at
ca.unraid.net/submit, or it'll show as a
broken image in Apps.
Notes
- Only the
TELEGRAM_CHAT_IDyou configure is served; the bot ignores messages from any other chat. amazon-ordersscrapes Amazon's website — there's no official API for this, so expect it to occasionally need re-login if Amazon changes its challenge flow or the session cookie expires.
Install telegram-amazon-orders-returns on Unraid in a few clicks.
Find telegram-amazon-orders-returns in Community Apps on your Unraid server, review the template, and click Install. Unraid handles the Docker app or plugin setup from the published template.
Categories
Related apps
Explore more like this
Explore allDetails
ghcr.io/bigwebstas/telegram-amazon-orders-returns:latestRuntime arguments
- Network
bridge- Shell
sh- Privileged
- false
Template configuration
Persistent Amazon session cookies and the sqlite tracking DB. Do not delete between restarts - the session is stored here.
- Target
- /data
- Default
- /mnt/user/appdata/telegram-amazon-orders-returns
- Value
- /mnt/user/appdata/telegram-amazon-orders-returns
Amazon account email address to poll.
- Target
- AMAZON_EMAIL
Amazon account password.
- Target
- AMAZON_PASSWORD
Bot token from @BotFather on Telegram.
- Target
- TELEGRAM_BOT_TOKEN
Your personal Telegram chat id (from @userinfobot). Only this chat is served.
- Target
- TELEGRAM_CHAT_ID
How often to poll Amazon for new orders/transactions, in minutes.
- Target
- POLL_INTERVAL_MINUTES
- Default
- 30
- Value
- 30
Optional: MQTT broker hostname/IP, to publish order/return/delivery counts to Home Assistant. Leave blank to disable.
- Target
- MQTT_HOST
MQTT broker port.
- Target
- MQTT_PORT
- Default
- 1883
- Value
- 1883
MQTT broker username, if required.
- Target
- MQTT_USERNAME
MQTT broker password, if required.
- Target
- MQTT_PASSWORD
Topic prefix for published sensor values.
- Target
- MQTT_TOPIC_PREFIX
- Default
- amazon_orders_returns
- Value
- amazon_orders_returns
Retain published sensor values so Home Assistant has them immediately on restart. Discovery configs are always retained regardless.
- Target
- MQTT_RETAIN
- Default
- true
- Value
- true