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.0.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.0-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: wasup_py-0.3.0.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.0.tar.gz
Algorithm Hash digest
SHA256 2ad858d240501a8c7e9b362d518d53215c51d6f8ad75ca92e51118dd3865fd1a
MD5 4f72027e4ce92e95ebb27927143c2270
BLAKE2b-256 ff23565986bb7b1bd5136c03649187ea960cefe9c26062871ee0ab8adaa5b3de

See more details on using hashes here.

File details

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

File metadata

  • Download URL: wasup_py-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 2.9 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7ce87dad942b0a48afc2146ca468b9223431e0aad8236beeb6a2544dec75fb79
MD5 997ef3b2a34d4fff969414305ce703c1
BLAKE2b-256 bab1f97fa4313cd2be5df78196e93abba2573c9905da2562d3b34d4a086c2fcf

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