How to handle buttons#
Attention, please! The method is temporarily not working.
Installation#
Installation:
python -m pip install whatsapp-chatbot-python
Import#
from whatsapp_chatbot_python import GreenAPIBot, Notification
Examples#
How to initialize an object#
bot = GreenAPIBot(
"1101000001", "d75b3a66374942c5b3c019c698abc2067e151558acbd412345"
)
How to handle buttons#
To be notified when a button is pressed, you must use the bot.router.buttons
object.
Link to example: buttons.py.
@bot.router.buttons()
def buttons_handler(notification: Notification) -> None:
notification.answer_buttons("Choose a color", [
{
"buttonId": 1,
"buttonText": "Red"
},
{
"buttonId": 2,
"buttonText": "Green"
},
{
"buttonId": 3,
"buttonText": "Blue"
}
])
bot.run_forever()
Running the application#
python buttons.py
List of examples#
Description | Link to example |
---|---|
How to start receiving and answering messages | base.py |
How to receive other notifications and handle the notification body | event.py |
How to filter incoming messages | filters.py |
How to handle buttons | buttons.py |
Example of a bot | full.py |
GREEN-API demo chatbot | bot.py |