🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

wacpy

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wacpy

WhatsApp Cloud API Wrapper

0.3.0
Maintainers
1

wacpy

Unofficial WhatsApp Cloud API Wrapper
(WIP)

Downloads Supported Versions License Version

📚 About

wacpy aims to be a complete python wrapper for the WhatsApp Cloud API.

⚙ Usage

Currently, wacpy is only providing WhatsApp Cloud API objects.

The 2 main objects are:

📃 Message: (wacpy.types.message.Message)

The Message object is used to craft messages.

🔔 Notification: (wacpy.types.notification.Notification)

The Notification object is the object that gets sent to your webhook.

Images taken from Official WhatsApp Cloud API Refrence

All other sub-objects exist under this 2 types.

🖥 Examples

  • A simple message:
from wacpy.types.message import Message, message # You can also import `message` from `wacpy.types`

Message(
    to='{{WHATSAPP_PHONE_NUMBER}}',
    text=message.Text(
        body="This is a simple message!"
    )
)

image

  • An Image:
from wacpy.types import Message, message # You can also import `message` from `wacpy.types`

Message(
    to='{{WHATSAPP_PHONE_NUMBER}}',
    type='image',
    image=message.Media(
        link='https://i.imgur.com/Zf5eagv.png',
        caption='Some cute cats'
    )
)

image

  • Interactive Button List
from wacpy.types import Message, message # You can also import `message` from `wacpy.types`

Message(
    to='{{WHATSAPP_PHONE_NUMBER}}',
    type='interactive',
    interactive=message.Interactive(
        type='list',
        action=message.interactive.Action(
            button='List',
            sections=[
                message.interactive.action.Section(
                    title='First Section',
                    rows=[
                        message.interactive.action.section.Row(
                            id='first_row',
                            title='First Row',
                            description='This is the first row description',
                        ),
                        message.interactive.action.section.Row(
                            id='second_row',
                            title='Second Row',
                            description='This is the second row description',
                        )
                    ]
                ),
                message.interactive.action.Section(
                    title='Second Section',
                    rows=[
                        message.interactive.action.section.Row(
                            id='first_row',
                            title='First Row',
                            description='This is the first row description',
                        ),
                        message.interactive.action.section.Row(
                            id='second_row',
                            title='Second Row',
                            description='This is the second row description',
                        )
                    ]
                )
            ]
        ),
        body=message.interactive.Body('This is the body text')
    )
)

image

Click here to see more examples (Soon!)

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts