Skip to main content

A stateful WhatsApp API Wrapper for Python with built-in conversation flow management.

Project description

wasup-py

A stateful WhatsApp API Wrapper for Python with built-in conversation flow management. Currently supports abstraction for Azure Communication Services.

Example

import os

from wasup import Bot
from wasup.bindings.azure import AzureBindingClient
from wasup.messages import TextMessage
from wasup.messages.dialogs import Dialog, DialogTurnResult, DialogTurnStatus, DialogContext

# initialize dialog with name and main flag
@Dialog.set(name="GreetingDialog", main=True)
class GreetingDialog(Dialog):
    """A simple greeting dialog that asks for the user's name."""

    @Dialog.step()
    @Dialog.store("user_name")
    async def ask_name(self, dc: DialogContext):
        """Ask the user for their name."""
        message = TextMessage(ctx=dc.ctx, message="Hello! 👋 What's your name?")
        await dc.message.send(message)
        return DialogTurnResult(DialogTurnStatus.Waiting)

    @Dialog.step()
    async def greet_user(self, dc: DialogContext):
        """Greet the user by name."""
        name = dc.get_value("user_name")
        message = TextMessage(ctx=dc.ctx, message=f"Nice to meet you, {name}! 😊")
        await dc.message.send(message)
        return DialogTurnResult(DialogTurnStatus.Complete)

# create bot instance
bot = Bot()

# load all dialogs
bot.load_dialog(GreetingDialog)

# initialize azure client
acs_client = NotificationMessagesClient.from_connection_string(os.getenv("AZURE_COMMUNICATION_ENDPOINT"))
azure_binding = AzureBindingClient(
    ctx=bot,
    client=acs_client,
    route="/api/whatsapp/events",
)

# run the bot with azure binding
bot.run(azure_binding)

Installation

Basic Installation

pip install wasup-py

With Provider Support

Azure Communication Services:

pip install wasup-py[azure]

Development:

pip install wasup-py[dev]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wasup_py-0.3.2.tar.gz (118.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wasup_py-0.3.2-py3-none-any.whl (36.3 kB view details)

Uploaded Python 3

File details

Details for the file wasup_py-0.3.2.tar.gz.

File metadata

  • Download URL: wasup_py-0.3.2.tar.gz
  • Upload date:
  • Size: 118.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for wasup_py-0.3.2.tar.gz
Algorithm Hash digest
SHA256 ae37dba55e47be83a5e587eb788530aec2bb68942163afb687e43c04f4a971c3
MD5 e5a9b2a1adc7ef892dc3b4cd80ec4eb1
BLAKE2b-256 b58df76593a21108850f492fa822bf115b269b5fa8972bf5a82213d977d26a47

See more details on using hashes here.

File details

Details for the file wasup_py-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: wasup_py-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 36.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for wasup_py-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 29fc3a4a9cfb24cd7ec76dcd81138f365eee661aa0db8258d803fd88a7facf08
MD5 3340feba6d7f5bea9fc3388665bab19c
BLAKE2b-256 6a921deeb4be34cd31d4ab9301ecd13ecf1ac45a7a2c242e8049a1b27fb354d6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page