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.3.tar.gz (119.0 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.3-py3-none-any.whl (36.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: wasup_py-0.3.3.tar.gz
  • Upload date:
  • Size: 119.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","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.3.tar.gz
Algorithm Hash digest
SHA256 253f1b3e59777ffe10fe8f3e08e81bd2ebc679b3a969d783e2fd773a4ed2c789
MD5 716ef58e29ffe66443e46aa0e20bc448
BLAKE2b-256 6a04485773764912aa5ea6bfe32b7212650956fbe9dc586a60ce76e883fe346b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: wasup_py-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 36.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e41aa97490082e7c8b01f2e779d08252f802d3e2bf97269b71a3cbe2771de98d
MD5 cac9d12c04a19ca7a586d1467b74ef65
BLAKE2b-256 258c7bc334b5e08fc76285a3daeda50943b19a22b33a651d382bf0230992d554

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