1616
1717<p align =" center " >
1818 <a href =" https://pypi.org/project/pywa/ " ><img src =" https://img.shields.io/pypi/v/pywa.svg " /></a >
19- <a href =" https://pypi.org/project/pywa/ " ><img src =" https://img.shields.io/pypi/dm /pywa " /></a >
19+ <a href =" https://pypi.org/project/pywa/ " ><img src =" https://static.pepy.tech/badge /pywa " /></a >
2020 <a href =" https://github.com/david-lev/pywa/actions/workflows/tests.yml " ><img src =" https://img.shields.io/github/actions/workflow/status/david-lev/pywa/tests.yml?label=Tests " /></a >
2121 <a href =" https://codecov.io/gh/david-lev/pywa " ><img src =" https://img.shields.io/codecov/c/github/david-lev/pywa " /></a >
2222 <a href =" https://pywa.readthedocs.io " ><img src =" https://readthedocs.org/projects/pywa/badge/?version=latest& " /></a >
2525 <a href =" https://t.me/py_wa " ><img src =" https://badges.aleen42.com/src/telegram.svg " /></a >
2626</p >
2727
28- > β οΈ ** Pywa v3 Release Candidate Available!**
29- > Pywa ` v3.0.0 ` is now available for testing!
30- >
31- > π ** Whatβs New in v3:**
32-
33- > β’ Complete ** template system redesign** β easier structure, validation, and sending
34- > β’ Full support for ** calls** (incoming and outgoing)
35- > β’ Improved ** security** , ** typing** , and ** input validation**
36-
37- > π [ v3 Documentation Β»] ( https://pywa.readthedocs.io/en/v3/ )
38- > π§ [ Migration Guide (2.x β 3.x) Β»] ( https://github.com/david-lev/pywa/blob/v3/MIGRATION.md )
39- > π [ Full Changelog Β»] ( https://github.com/david-lev/pywa/blob/v3/CHANGELOG.md )
40- >
41- > π¦ ** Install for testing:**
42- > ``` bash
43- > pip install pywa==3.0.0-rc.3
44- > ` ` `
45- >
46- > π¬ Feedback and issue reports are encouraged to help us prepare for the stable release.
47-
4828---
4929
5030** π« PyWa is an all-in-one Python framework for the WhatsApp Cloud API.**
@@ -58,30 +38,29 @@ Fully **typed**, **documented**, and **production-ready** β build powerful bot
5838--------------------------------
5939
6040> [ Get Started] ( https://pywa.readthedocs.io/en/latest/content/getting-started.html )
61- β’ [WhatsApp Client](https://pywa.readthedocs.io/en/latest/content/client/overview.html)
41+ β’ [ Client] ( https://pywa.readthedocs.io/en/latest/content/client/overview.html )
6242β’ [ Handlers] ( https://pywa.readthedocs.io/en/latest/content/handlers/overview.html )
6343β’ [ Listeners] ( https://pywa.readthedocs.io/en/latest/content/listeners/overview.html )
64- β’ [Filters](https://pywa.readthedocs.io/en/latest/content/filters/overview.html)
6544β’ [ Updates] ( https://pywa.readthedocs.io/en/latest/content/updates/overview.html )
66- β’ [Templates](https://pywa.readthedocs.io/en/v3/content/templates/overview.html)
45+ β’ [ Filters] ( https://pywa.readthedocs.io/en/latest/content/filters/overview.html )
46+ β’ [ Templates] ( https://pywa.readthedocs.io/en/latest/content/templates/overview.html )
6747β’ [ Flows] ( https://pywa.readthedocs.io/en/latest/content/flows/overview.html )
68- β’ [Calls](https://pywa.readthedocs.io/en/v3/content/calls/overview.html)
69- β’ [Examples](https://pywa.readthedocs.io/en/latest/content/examples/overview.html)
70-
48+ β’ [ Calls] ( https://pywa.readthedocs.io/en/latest/content/calls/overview.html )
7149
7250------------------------
7351
7452β‘ ** Why PyWa?**
7553---------------
76- - ** π Fast and Simple** : Focus on building your bot without worrying about low-level details.
77- - ** π¬ Rich Messaging** : Send text, images, videos, documents, audio, locations, contacts, and interactive keyboards.
78- - ** π© Real-Time Updates** : Receive messages, callbacks, and message status updates effortlessly.
79- - ** π Listeners** : Use powerful listeners to wait for specific user events.
80- - ** β»οΈ Flows Support** : Create, send, and listen to Flows seamlessly.
81- - ** π Webhook Integration** : Built-in support for popular frameworks like Flask and FastAPI.
82- - ** π¬ Advanced Filters** : Handle incoming updates with powerful filtering options.
83- - ** π Template Messaging** : Easily create and send template messages.
84- - ** β
Production-Ready** : Fully typed, documented, and rigorously tested for reliability.
54+ - ** π Fast & Simple** β Focus on building, not boilerplate.
55+ - ** π¬ Rich Messaging** β Text, images, files, audio, locations, contacts, buttons & more.
56+ - ** π© Real-Time Updates** β Messages, callbacks, delivery/read receipts, account updates, and more.
57+ - ** π Listeners** β Wait for user replies, clicks, or reactions with ease.
58+ - ** π Templates** β Create and send powerful WhatsApp templates.
59+ - ** β»οΈ Flows** β Build interactive WhatsApp flows effortlessly.
60+ - ** π Calls Support** β Receive and handle call events.
61+ - ** π Webhook-Ready** β Native support for Flask, FastAPI, and more.
62+ - ** π¬ Filters** β Advanced filtering for incoming updates.
63+ - ** β
Production-Ready** β Typed, documented, and fully tested.
8564
8665------------------------
8766
@@ -165,7 +144,7 @@ def click_me(client: WhatsApp, clb: types.CallbackButton):
165144- To run the server, use [ fastapi-cli] ( https://fastapi.tiangolo.com/#run-it ) (` pip install "fastapi[standard]" ` ):
166145
167146``` bash
168- fastapi dev wa.py # see uvicorn docs for more options (port, host, reload, etc.)
147+ fastapi dev wa.py # see uvicorn docs for more options (port, host, etc.)
169148```
170149
171150- ** Async Usage**
@@ -186,7 +165,55 @@ async def main():
186165@wa.on_message
187166async def hello (_ : WhatsApp, msg : types.Message): # async callback
188167 await msg.react(" π" )
189- await msg.reply(... )
168+ await msg.reply(" Hello from PyWa Async!" )
169+ ```
170+
171+ - ** Create and send template messages**
172+ > See [ Templates] ( https://pywa.readthedocs.io/en/latest/content/templates/overview.html ) for more details and examples.
173+
174+ ``` python
175+ from pywa import WhatsApp
176+ from pywa.types.templates import *
177+
178+ wa = WhatsApp(... , business_account_id = 123456 )
179+
180+ # Create a template
181+ wa.create_template(
182+ template = Template(
183+ name = " buy_new_iphone_x" ,
184+ category = TemplateCategory.MARKETING ,
185+ language = TemplateLanguage.ENGLISH_US ,
186+ parameter_format = ParamFormat.NAMED ,
187+ components = [
188+ ht := HeaderText(" The New iPhone {{ iphone_num}} is here!" , iphone_num = 15 ),
189+ bt := BodyText(" Buy now and use the code {{ code}} to get {{ per}} % o ff!" , code = " WA_IPHONE_15" , per = 15 ),
190+ FooterText(text = " Powered by PyWa" ),
191+ Buttons(
192+ buttons = [
193+ url := URLButton(text = " Buy Now" , url = " https://example.com/shop/{{ 1}} " , example = " iphone15" ),
194+ PhoneNumberButton(text = " Call Us" , phone_number = " 1234567890" ),
195+ qrb1 := QuickReplyButton(text = " Unsubscribe from marketing messages" ),
196+ qrb2 := QuickReplyButton(text = " Unsubscribe from all messages" ),
197+ ]
198+ ),
199+
200+ ]
201+ ),
202+ )
203+
204+ # Send the template message
205+ wa.send_template(
206+ to = " 9876543210" ,
207+ name = " buy_new_iphone_x" ,
208+ language = TemplateLanguage.ENGLISH_US ,
209+ params = [
210+ ht.params(iphone_num = 30 ),
211+ bt.params(code = " WA_IPHONE_30" , per = 30 ),
212+ url.params(url_variable = " iphone30" , index = 0 ),
213+ qrb1.params(callback_data = " unsubscribe_from_marketing_messages" , index = 1 ),
214+ qrb2.params(callback_data = " unsubscribe_from_all_messages" , index = 2 ),
215+ ]
216+ )
190217```
191218
192219- ** Create and send flows**
@@ -263,53 +290,6 @@ def handle_flow_response(_: WhatsApp, flow: types.FlowCompletion):
263290 )
264291```
265292
266- - ** Create and send template messages**
267-
268- ``` python
269- from pywa import WhatsApp, types
270-
271- # Create a WhatsApp client
272- wa = WhatsApp(... , business_account_id = 123456 )
273-
274- # Create a template
275- created = wa.create_template(
276- template = types.NewTemplate(
277- name = " buy_new_iphone_x" ,
278- category = types.NewTemplate.Category.MARKETING ,
279- language = types.NewTemplate.Language.ENGLISH_US ,
280- header = types.NewTemplate.Text(text = " The New iPhone {15} is here!" ),
281- body = types.NewTemplate.Body(text = " Buy now and use the code {WA_IPHONE_15} to get {15%} off!" ),
282- footer = types.NewTemplate.Footer(text = " Powered by PyWa" ),
283- buttons = [
284- types.NewTemplate.UrlButton(title = " Buy Now" , url = " https://example.com/shop/{iphone15} " ),
285- types.NewTemplate.PhoneNumberButton(title = " Call Us" , phone_number = ' 1234567890' ),
286- types.NewTemplate.QuickReplyButton(text = " Unsubscribe from marketing messages" ),
287- types.NewTemplate.QuickReplyButton(text = " Unsubscribe from all messages" ),
288- ],
289- ),
290- )
291-
292- # Send the template message
293- wa.send_template(
294- to = " 9876543210" ,
295- template = types.Template(
296- name = " buy_new_iphone_x" ,
297- language = types.Template.Language.ENGLISH_US ,
298- header = types.Template.TextValue(value = " 15" ),
299- body = [
300- types.Template.TextValue(value = " John Doe" ),
301- types.Template.TextValue(value = " WA_IPHONE_15" ),
302- types.Template.TextValue(value = " 15%" ),
303- ],
304- buttons = [
305- types.Template.UrlButtonValue(value = " iphone15" ),
306- types.Template.QuickReplyButtonData(data = " unsubscribe_from_marketing_messages" ),
307- types.Template.QuickReplyButtonData(data = " unsubscribe_from_all_messages" ),
308- ],
309- ),
310- )
311- ```
312-
313293π ** Installation**
314294--------------------
315295
@@ -348,16 +328,6 @@ pip3 install -U "pywa[cryptography]"
348328
349329See the [ Documentation] ( https://pywa.readthedocs.io/ ) for detailed instructions
350330
351- βοΈ ** TODO**
352- ------------
353-
354- - ~~ Add support for async~~
355- - ~~ Add support for more web frameworks (Django, aiohttp, etc.)~~
356- - ~~ Add support for flows~~
357- - Add support for more types of updates (`` account_alerts `` , `` phone_number_quality_updates `` , `` template_category_updates `` , etc.)
358- - Add more examples and guides
359-
360- Feel free to open an issue if you have any suggestions. or even better - submit a PR!
361331
362332βοΈ ** License**
363333---------------
@@ -370,3 +340,8 @@ This project is licensed under the MIT License - see the
370340--------------------
371341
372342Contributions are welcome! Please see the [ Contributing Guide] ( https://github.com/david-lev/pywa/blob/master/CONTRIBUTING.md ) for more information.
343+
344+ π£ ** Community**
345+ --------------------
346+
347+ Join the [ Telegram Group] ( https://t.me/pywachat ) to discuss, ask questions, and share your projects built with PyWa!
0 commit comments