{"id":15306696,"url":"https://github.com/t0mer/whatsapp-bridge","last_synced_at":"2025-04-15T00:54:13.329Z","repository":{"id":101737749,"uuid":"562782378","full_name":"t0mer/whatsapp-bridge","owner":"t0mer","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-26T22:33:20.000Z","size":32,"stargazers_count":13,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-15T00:54:07.927Z","etag":null,"topics":["fastapi","home-assistant","home-automation","mqtt","python","whatsapp"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/t0mer.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}},"created_at":"2022-11-07T08:48:05.000Z","updated_at":"2025-04-03T14:31:16.000Z","dependencies_parsed_at":"2025-01-26T23:31:34.978Z","dependency_job_id":null,"html_url":"https://github.com/t0mer/whatsapp-bridge","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t0mer%2Fwhatsapp-bridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t0mer%2Fwhatsapp-bridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t0mer%2Fwhatsapp-bridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t0mer%2Fwhatsapp-bridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/t0mer","download_url":"https://codeload.github.com/t0mer/whatsapp-bridge/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248986279,"owners_count":21194025,"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","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":["fastapi","home-assistant","home-automation","mqtt","python","whatsapp"],"created_at":"2024-10-01T08:06:56.333Z","updated_at":"2025-04-15T00:54:13.308Z","avatar_url":"https://github.com/t0mer.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Whatsapp-bridge\nWhatsapp-bridge is a lightweight application written in python and FastAPI-MQTT. \nI created WhatsApp-bridge to have the ability to send WhatsApp notifications easily from any application or IoT platform using MQTT topics or HTTP calls and without needing to write an extension for every application or device in the network.\nTo maintain the ability to combine MQTT and Web server, I’m using the [FastAPI-MQTT](https://sabuhish.github.io/fastapi-mqtt/).\n\n## Features\n- Send text message.\n- Send template message.\n- Send messages using REST API call or MQTT topic publising.\n- Receive message from whatsapp and forward it om MQTT.\n\n## Components and Frameworks used in Voicy\n* [Loguru](https://pypi.org/project/loguru/)\n* [configparser](https://pypi.org/project/configparser/)\n* [FastAPI-MQTT](https://sabuhish.github.io/fastapi-mqtt/).\n* [na-mish](https://pypi.org/project/ma-nish/) - Unofficial python wrapper to [WhatsApp Cloud API](https://developers.facebook.com/docs/whatsapp/cloud-api)\n\n\n## Limitations\n* 1000 free messages per month (Free tier)\n* It is only possible to send messages other than templates after the target phone responds to an initial message (Unless you use Template messages)\n* You can't send message to a group\n\n\n\n## Getting started\n\n### Set Up Meta App\n\nFirst you’ll need to follow the (instructions on this page)[https://developers.facebook.com/docs/whatsapp/cloud-api/get-started] to:\n\n* Register as a Meta Developer\n* Enable two-factor authentication for your account\n* Create a Meta App – you need to create a Business App for WhatsApp\n\nOnce you’ve done that, go to your app and set up the WhatsApp product.\n\n[![New app](https://techblog.co.il/wp-content/uploads/2022/12/new-app.png \"New App\")](https://techblog.co.il/wp-content/uploads/2022/12/new-app.png \"New App\")\n\nYou’ll be given a temporary access token and a Phone Number ID, note these down as you’ll need them later. Set up your own phone number as a recipient and you can have a go at sending yourself a test message:\n\n[![Getting started](https://techblog.co.il/wp-content/uploads/2022/12/test-number.png \"Getting started\")](https://techblog.co.il/wp-content/uploads/2022/12/test-number.png \"Getting started\")\n\n### Set Up Message Template\n\nIn the test message above, you used the **hello_world** template. You’ll need to set up your own template for your own purposes. If you go to [“Message Templates”](https://business.facebook.com/wa/manage/message-templates/) in the WhatsApp manager you can build your own templates.\n\nIn the following example, i created a template for my smat home. The template header if fixed and so is the footer. in the body i added variable for dynamic text:\n\n[![Smart Home Template](https://techblog.co.il/wp-content/uploads/2022/12/my-template.png \"Smart Home Template\")](https://techblog.co.il/wp-content/uploads/2022/12/my-template.png \"Smart Home Template\")\n\n\nOnce you're done with the above ,you're ready to start send messages using this docker.\n\n### Running the container\nBefore running the docker you should create the config file with the following parameters:\n\n```ini\n[Whatsapp]\napi.token=\napi.phone_id=\napi.template_name=\napi.template_language=\nwebhook.token=\nwebhook.base_url=\n\n\n[MQTT]\nmqtt.host=\nmqtt.port=\nmqtt.username=\nmqtt.password=\nmqtt.topic=\n\n```\n\nAll fields are mandatory except webhook.token and webhook.base_url that are only needed for webhook validation and incoming messages (from WA to MQTT).\n\nAfter config file is set, create the docker using the following dokcer-compose file:\n\n```yaml\nversion: \"3.6\"\nservices:\n  whatsapp-bridge:\n    image: techblog/whatsapp-bridge\n    container_name: whatsapp-bridge\n    restart: always\n    ports:\n      - 8081:8081\n    environment:\n      - LOG_LEVEL=DEBUG\n    volumes:\n      - ./wa-bridge:/app/config\n```\n\n\n## Sending Messages\n\n### Sending from Home Assistant\nYou can send Whatsapp messages using rest notification by adding the following code to the configuration file.\n```yaml\nnotify:\n  - name: WhatsApp\n    platform: rest\n    resource: http://[whatsapp-bridge-ip:port]/send\n    data:\n      phone:  #enter your phone number here\n```\nIn the example above the message will be sent using the default template configured in the config file. if you want to send the notification using deferent template add the template name and language to the configuration section:\n\n```yaml\nnotify:\n  - name: WhatsApp\n    platform: rest\n    resource: http://[whatsapp-bridge-ip:port]/send\n    data:\n      phone:  #enter your phone number here\n      template: #enter the temlate name here\n      language: #enter the template's language here\n```\n\n\n\nNow you can test the notification using services under developer tools\n[![HA-Developer-tools-for-WA](https://techblog.co.il/wp-content/uploads/2023/01/HA-Developer-tools-for-WA.png \"HA-Developer-tools-for-WA\")](https://techblog.co.il/wp-content/uploads/2023/01/HA-Developer-tools-for-WA.png \"HA-Developer-tools-for-WA\")\n\n### Sending message usin MQTT\nWith whatsapp-bridge you can also send messages by publishing data to the topic ***whatsapp/send*** with the payload:\n```json\n{\n\"message\":\"Whatsapp message\",\n\"recipient\":\"1234567890\"\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft0mer%2Fwhatsapp-bridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ft0mer%2Fwhatsapp-bridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft0mer%2Fwhatsapp-bridge/lists"}