{"id":29856070,"url":"https://github.com/mscbuild/woocommerce-telegram","last_synced_at":"2025-07-29T23:35:43.707Z","repository":{"id":305731662,"uuid":"1023761751","full_name":"mscbuild/woocommerce-telegram","owner":"mscbuild","description":"Woocommerce telegram bot (Python) .A Telegram bot for WooCommerce allows you to connect your online store to Telegram, enabling features like order notifications, customer interaction, and even product sales directly through the messaging app.","archived":false,"fork":false,"pushed_at":"2025-07-21T17:18:56.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-21T19:28:53.570Z","etag":null,"topics":["bot","bussiness","development","ecommerece","messenger","telegram","telegrambot","woocommerce"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mscbuild.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-21T16:48:22.000Z","updated_at":"2025-07-21T17:22:46.000Z","dependencies_parsed_at":"2025-07-21T19:29:05.606Z","dependency_job_id":null,"html_url":"https://github.com/mscbuild/woocommerce-telegram","commit_stats":null,"previous_names":["mscbuild/woocommerce-telegram"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/mscbuild/woocommerce-telegram","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscbuild%2Fwoocommerce-telegram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscbuild%2Fwoocommerce-telegram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscbuild%2Fwoocommerce-telegram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscbuild%2Fwoocommerce-telegram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mscbuild","download_url":"https://codeload.github.com/mscbuild/woocommerce-telegram/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscbuild%2Fwoocommerce-telegram/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267780406,"owners_count":24143204,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","bussiness","development","ecommerece","messenger","telegram","telegrambot","woocommerce"],"created_at":"2025-07-29T23:35:38.832Z","updated_at":"2025-07-29T23:35:43.691Z","avatar_url":"https://github.com/mscbuild.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# woocommerce-telegram (Python)\n![](https://komarev.com/ghpvc/?username=mscbuild) \n ![](https://img.shields.io/github/license/mscbuild/woocommerce-telegram) \n ![](https://img.shields.io/badge/PRs-Welcome-green)\n ![](https://img.shields.io/github/languages/code-size/mscbuild/woocommerce-telegram)\n![](https://img.shields.io/badge/code%20style-python-green)\n![](https://img.shields.io/github/stars/mscbuild)\n![](https://img.shields.io/badge/Topic-Github-lighred)\n![](https://img.shields.io/website?url=https%3A%2F%2Fgithub.com%2Fmscbuild)\n\n\n# 🔧 Use Case Example\n\n- Let’s say you want to notify users via Telegram when:\n\n- A new order is placed\n\n- A product is back in stock\n\n- A customer leaves a review\n\n# 🗂️ Project Structure\n~~~bash\nwoocommerce-telegram-bot/\n│\n├── bot/\n│   ├── __init__.py\n│   ├── config.py\n│   ├── telegram_bot.py         # Bot logic + command handlers\n│   ├── woo.py                  # WooCommerce API interface\n│\n├── webhook/\n│   ├── __init__.py\n│   └── server.py               # Flask server for webhook\n│\n├── requirements.txt\n├── run.py                      # Main entry point\n└── README.md\n~~~\n\n# 🧱 Overview of What You Need\n\n## 1. Telegram Bot\n   \n- Create a Telegram bot via @BotFather\n\n- Save the bot token\n\n## 2. WooCommerce Store\n\n- WooCommerce REST API must be enabled\n\n- Get your Consumer Key and Consumer Secret\n\n## 3. Python Environment\n\nInstall required libraries:\n~~~bash\npip install python-telegram-bot woocommerce flask\n~~~\n\n# 🧪 Example Use Case: Telegram Bot for New Orders\n\n## Step 1: Basic Telegram Bot Setup (Python)\n\n~~~bash\nfrom telegram import Bot\n\nTELEGRAM_BOT_TOKEN = \"YOUR_TELEGRAM_BOT_TOKEN\"\nCHAT_ID = \"YOUR_CHAT_ID\"  # Your Telegram user ID or group ID\n\nbot = Bot(token=TELEGRAM_BOT_TOKEN)\n\ndef send_telegram_message(message):\nbot.send_message(chat_id=CHAT_ID, text=message)\n~~~\n\n## Step 2: WooCommerce API Integration\n\n~~~bash\nfrom woocommerce import API\n\nwcapi = API(\n    url=\"https://yourstore.com\",\n    consumer_key=\"ck_xxx\",\n    consumer_secret=\"cs_xxx\",\n    version=\"wc/v3\"\n)\n\ndef get_latest_orders():\n    return wcapi.get(\"orders\").json()\n~~~\n\n## Step 3: Notify on New Order (Polling or Webhook)\n\nOption A: Polling (Not real-time, simpler)\n\n~~~bah\nimport time\n\nlast_order_id = None\n\nwhile True:\n    orders = get_latest_orders()\n    if orders:\n        latest = orders[0]\n        if latest['id'] != last_order_id:\n            msg = f\"🛒 New Order!\\nCustomer: {latest['billing']['first_name']}\\nTotal: {latest['total']}\"\n            send_telegram_message(msg)\n            last_order_id = latest['id']\n    time.sleep(60)\n~~~\n\n## Option B: Webhook from WooCommerce to Flask (Real-time, better)\n\n1.Create a webhook in WooCommerce:\n\n- Topic: Order Created\n\n- Delivery URL: e.g., `https://yourdomain.com/webhook`\n\n- Secret: Use something unique\n\n- Flask app to receive webhook:\n  \n~~~bash\nfrom flask import Flask, request\n\napp = Flask(__name__)\n\n@app.route(\"/webhook\", methods=[\"POST\"])\ndef wc_webhook():\n    data = request.json\n    msg = f\"🛒 New Order!\\nCustomer: {data['billing']['first_name']}\\nTotal: {data['total']}\"\n    send_telegram_message(msg)\n    return \"OK\", 200\n\nif __name__ == \"__main__\":\n    app.run(port=5000)\n~~~\n\n# 🧩 Optional Features\n\n- Respond to Telegram commands (`/latest_orders`)\n\n- Notify on stock status changes\n\n- Add custom filters for big orders, VIP clients, etc.\n\n# 📦 Packaging It\n\n- Run Flask app on cloud (Heroku, Fly.io, etc.)\n\n- Use ngrok for testing locally with webhooks:\n\n~~~bash\nngrok http 5000\n~~~\n\n# 📁 File Contents\n\n- `requirements.txt`\n- `bot/config.py`\n- `bot/woo.py`\n- `bot/telegram_bot.py`\n- `webhook/server.py`\n- `run.py`\n\n# 🚀 How to Run Locally\n\n1.Install dependencies:\n~~~bash\npip install -r requirements.txt\n~~~\n2.Start the bot:\n~~~bash\npython run.py\n~~~\n3.Run webhook server (for real-time WooCommerce updates):\n~~~bash\npython webhook/server.py\n~~~\n4.(Optional) Use ngrok to expose webhook to WooCommerce:\n~~~bash\nngrok http 5000\n~~~\n\n- Then set this https://xxxx.ngrok.io/webhook as the webhook URL in your WooCommerce admin panel under:\n\n- WooCommerce → Settings → Advanced → Webhooks\n\n# 💬 Available Telegram Commands\n\n| Command         | Description                |\n| --------------- | -------------------------- |\n| `/start`        | Greet the user             |\n| `/latest_order` | Fetch latest order details |\n\nYou can add more like /stock_status, /customer_info, etc.\n\n№№ Next you can set up Docker or deployment (Heroku, Fly.io, etc.)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmscbuild%2Fwoocommerce-telegram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmscbuild%2Fwoocommerce-telegram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmscbuild%2Fwoocommerce-telegram/lists"}