Skip to content

Commit

Permalink
SAW-4360 Added incoming calls support
Browse files Browse the repository at this point in the history
  • Loading branch information
prostraction committed Dec 15, 2024
1 parent bf7d3b9 commit e0a07e4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 12 additions & 0 deletions examples/call.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from whatsapp_chatbot_python import GreenAPIBot, Notification

bot = GreenAPIBot(
"1101000001", "d75b3a66374942c5b3c019c698abc2067e151558acbd412345"
)


@bot.router.incoming_call()
def message_handler(notification: Notification) -> None:
print("Call from:", notification.event["from"], "with status", notification.event["status"])

bot.run_forever()
4 changes: 3 additions & 1 deletion whatsapp_chatbot_python/manager/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def __init__(self, api: "GreenAPI", logger: logging.Logger):
self.outgoing_message: AbstractObserver = Observer(self)
self.outgoing_api_message: AbstractObserver = Observer(self)
self.outgoing_message_status: AbstractObserver = Observer(self)
self.incoming_call: AbstractObserver = Observer(self)

self.buttons: AbstractObserver = ButtonObserver(self)

Expand All @@ -33,7 +34,8 @@ def __init__(self, api: "GreenAPI", logger: logging.Logger):
"incomingMessageReceived": self.message,
"outgoingMessageReceived": self.outgoing_message,
"outgoingAPIMessageReceived": self.outgoing_api_message,
"outgoingMessageStatus": self.outgoing_message_status
"outgoingMessageStatus": self.outgoing_message_status,
"incomingCall": self.incoming_call
}

def route_event(self, event: dict) -> None:
Expand Down

0 comments on commit e0a07e4

Please sign in to comment.