A Telegram Book Store Bot that is able to connect to any WordPress site (in this case our Book shop) using WooCommerce REST API and fetch all of its existing products in order to show it in the bot to our customers.
Users will be able to see the price of products, add them to their cart, and get redirected to the payment page.
This was actually the final project of my bachelor's course at the University of Guilan.
- Python 3.8 (or higher)
- install this package with
pip install pyTelegramBotApi
in your cmd(you can check this link for documents) - install this package with
pip install WooCommerce
in your cmd(you can check this link for documents) - get a token for your bot from https://t.me/BotFather and write it in core.py
- for checking
database.db
file after it's been created, use : https://sqliteonline.com
To create or manage keys for a specific WordPress user, go to WooCommerce > Settings > Advanced > REST API.
Click the "Add Key" button. In the next screen, add a description and select the WordPress user you would like to generate the key for. Use of the REST API with the generated keys will conform to that user's WordPress roles and capabilities.
Choose the level of access for this REST API key, which can be Read access, Write access or Read/Write access. Then click the "Generate API Key" button and WooCommerce will generate REST API keys for the selected user.
Now that keys have been generated, you should see two new keys, a QRCode, and a Revoke API Key button. These two keys are your Consumer Key and Consumer Secret.
And the final step! just put these keys in database.py at woocommerce function and we're ready to go :D