Disclaimer: The term 'Etsy' is a trademark of Etsy, Inc. This application uses the Etsy API but is not endorsed or certified by Etsy, Inc.
You have an Etsy shop, and you do not want to miss when a listing goes out of stock? This Telegram bot will notify you when the product is sold out.
Start a conversation with @lowstockbot on Telegram. You will immediately get a response with the introduction and invitation to login to Etsy.
Follow the link.
Etsy will ask you if it is ok to read your listings.
Once you have approved the requested access, you will get a pin.
Copy the pin.
Post the pin back to the chat.
Bot expects this format:
/pin {one time pin}
The bot will validate your pin, and if everything is fine, you will get a confirmation that from now on, a message will be sent to notify you if listing in your shop is out of stock.
For help use /help
command.
Lowstok listens to all Etsy Listing updates by polling live feeds endpoint.
There are two options when it comes to consuming listings updates:
- Push
- Poll
Push makes things simple as you only handle incoming HTTP requests and act accordingly based on the updated type. I did not manage to find a way to subscribe to feeds reliably, so I have decided to consume primary listings feed by regularly polling endpoint.
Lowstock mostly reads data from storage and only stores data when a new user joins. For simplicity, Lowstock uses local file-based embedded database BoltDB.
Application stores IDs of registered users. Once bot encounters an update that has known user ID - it will send a notification to a corresponding chat.
Notifications are simple text payloads with SKU info and shop name.
The current implementation uses Telegram for notifications. It should be easy to plug any other messenger that has API.
You can find a Systemd service unit configuration in this repository. It is also ok to run this bot in Docker, but you will need to write a Dockerfile yourself.
Lowstock needs access to Etsy Feeds, Etsy Open API, and Telegram Bot API to work. Once you provision API credentials, you will need to provide them to the bot via environment variables.
Name | Description |
---|---|
DATABASE_FILE |
BoltDB database file |
TELEGRAM_TOKEN |
Telegram Bot token |
ETSY_CONSUMER_KEY |
Etsy key is used to perform calls to Etsy Open API |
ETSY_SHARED_SECRET |
Etsy secret is used in combination with the key to do OAuth v1 |
With the current number of listing updates per minute, you do not need more than one worker. You may want to have more for redundancy, this is not done, and I do not think it is is necessary now. With the current implementation, you need to make sure that it is restarted if failed. System or Docker works for that.