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.1.tar.gz (141.2 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.1-py3-none-any.whl (34.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: wasup_py-0.3.1.tar.gz
  • Upload date:
  • Size: 141.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","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.1.tar.gz
Algorithm Hash digest
SHA256 727ef8f0a8fe1a0ebda00b4f8ebbdc5521794ff9a344155a53a9b905c8327d96
MD5 d46d527260c8edaf65d8fcf45c7bd3be
BLAKE2b-256 ce03890d484e475b0544f480e2e1bd71629eab38e52fe0c978516b48ec2370ee

See more details on using hashes here.

File details

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

File metadata

  • Download URL: wasup_py-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 34.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 769e4d85c52f8aaf57c2a7b0ca203a40aad3c76852a8386d623db4d272a08591
MD5 6822027d331324646b881e5f89685eb5
BLAKE2b-256 3904601af693d30e134bad89e1fcbbd84deb521f9781456f63d0f7e6b7d41c2f

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