GithubHelp home page GithubHelp logo

bcombes / pywa Goto Github PK

View Code? Open in Web Editor NEW

This project forked from david-lev/pywa

0.0 0.0 0.0 1.38 MB

๐Ÿ’ฌ Python wrapper for the WhatsApp Cloud API

Home Page: https://pywa.readthedocs.io

License: MIT License

Python 100.00%

pywa's Introduction

PyWa Logo

PyWa โ€ข Python wrapper for the WhatsApp Cloud API

PyPI Downloads PyPI Version Tests Docs License CodeFactor Telegram

PyWa is a Fast, Simple, Modern and easy-to-use Python framework for building WhatsApp bots using the WhatsApp Cloud API.

๐Ÿ“„ Quick Documentation Index

>> Get Started โ€ข WhatsApp Client โ€ข Handlers โ€ข Filters โ€ข Updates โ€ข Examples


โšก Features

  • ๐Ÿš€ Fast and simple to use. No need to worry about the low-level details.
  • ๐Ÿ’ฌ Send text messages with interactive keyboards, images, videos, documents, audio, locations, contacts, etc.
  • ๐Ÿ“ฉ Receive messages, callbacks, message status updates, etc.
  • ๐Ÿ”„ Built-in support for webhooks (Flask, FastAPI, etc.)
  • ๐Ÿ”ฌ Filters for handling incoming updates
  • ๐Ÿ“„ Send and create templates
  • โœ… Fully typed, documented and tested

๐Ÿ‘จโ€๐Ÿ’ป Usage

  • Create a WhatsApp client and send a message
from pywa import WhatsApp

wa = WhatsApp(
    phone_id='100458559237541',
    token='xxxxxxxxxxxxxxx'
)

wa.send_message(
    to='9876543210',
    text='Hello from PyWa!'
)
  • Create a WhatsApp client, pass a web server app (Flask in this example) and start the webhook:
from pywa import WhatsApp
from flask import Flask
from pywa.types import Message, CallbackButton, Button
from pywa.filters import text, callback

flask_app = Flask(__name__)
wa = WhatsApp(
    phone_id='1234567890',
    token='xxxxxxxxxxxxxxx',
    server=flask_app,
    verify_token='XYZXYZ',
)

@wa.on_message(text.matches('Hello', 'Hi'))
def hello(client: WhatsApp, msg: Message):
    msg.react('๐Ÿ‘‹')
    msg.reply_text(
        text=f'Hello {msg.from_user.name}!',
        keyboard=[
            Button(
                title='Click me!',
                callback_data='id:123'
            )
        ]
    )

@wa.on_callback_button(callback.data_startswith('id'))
def click_me(client: WhatsApp, clb: CallbackButton):
    clb.reply_text('You clicked me!')

flask_app.run()  # Run the flask app to start the server

๐ŸŽ› Installation

  • Install using pip3:
pip3 install -U pywa
  • Install from source (the bleeding edge):
git clone https://github.com/david-lev/pywa.git
cd pywa && pip3 install -U .
  • If you going to use the webhook features, here is shortcut to install the required dependencies:
pip3 install -U pywa[flask]
pip3 install -U pywa[fastapi]

๐Ÿ’พ Requirements

๐Ÿ“– Setup and Usage

See the Documentation for detailed instructions

โ˜‘๏ธ TODO

  • Add tests
  • Add support for async
  • Move from threading
  • Add support for more web frameworks (Django, etc.)
  • Add support for more types of updates (account_alerts, message_template_status_updates, etc.)
  • Add more examples

Feel free to open an issue if you have any suggestions. or even better - submit a PR!

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details

๐Ÿ”ฑ Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

๐Ÿ™ Acknowledgments

pywa's People

Contributors

david-lev avatar shlomocode avatar yehuda-lev avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.