[go: up one dir, main page]

Skip to content

How to receive other notifications and handle the notification body#

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 receive other notifications and handle the notification body#

You can receive not only incoming messages but also outgoing messages. You can also get the status of the sent message.

  • To receive outgoing messages, you need to use the bot.router.outgoing_message object;
  • To receive outgoing API messages, you need to use the bot.router.outgoing_api_message object;
  • To receive the status of sent messages, you need to use the bot.router.outgoing_message_status object.

The body of the notification is in notification.event. In this example, we get the message type from the notification body.

Link to example: event.py.

@bot.router.message()
def message_handler(notification: Notification) -> None:
    print(notification.event)


bot.run_forever()

Running the application#

python event.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