Skip to main content

Official Python SDK for WAPILOT.io - WhatsApp Business API Integration

Project description

WAPILOT Python SDK

Official Python SDK for WAPILOT.io - WhatsApp Business API Integration Platform

Overview

WAPILOT SDK provides a simple and intuitive way to integrate WhatsApp Business API functionality into your Python applications. This SDK handles all the complexity of API communication, authentication, and data formatting, allowing you to focus on building your application logic.

Features

  • 📱 Contact Management - Create, update, and manage WhatsApp contacts
  • 👥 Contact Groups - Organize contacts into groups for better management
  • 💬 Message Sending - Send text, media, and interactive messages
  • 📝 Templates - Manage and send template messages
  • 🤖 Automated Replies - Set up and manage automated responses
  • Modern Architecture - Built with modern Python, supports async/await
  • 🔒 Secure - Built-in token-based authentication and HTTPS
  • 🚀 Simple API - Intuitive methods for all operations

Installation

pip install wapilot-sdk

Quick Start

from wapilot import WapilotSDK

# Initialize the SDK
wapilot = WapilotSDK(token='your-api-token')  # Get this from your WAPILOT dashboard

# Send a message
try:
    result = wapilot.send_message({
        'phone': '+1234567890',
        'message': 'Hello from Python!'
    })
    print(result)
except Exception as e:
    print(f'Error: {e}')

Configuration Options

Option Type Required Default Description
token str Yes - Your WAPILOT API token
base_url str No https://app.wapilot.io API base URL

API Reference

Contact Management

Get All Contacts

contacts = wapilot.get_contacts()

Create Contact

new_contact = wapilot.create_contact({
    'name': 'John Doe',
    'phone': '+1234567890',  # International format with country code
    # Optional fields
    'email': 'john@example.com',
    'notes': 'VIP Customer'
})

Update Contact

updated_contact = wapilot.update_contact('contact-uuid', {
    'name': 'John Smith',
    # Include only fields you want to update
})

Delete Contact

wapilot.delete_contact('contact-uuid')

Message Sending

Send Text Message with Interactive Buttons

wapilot.send_message({
    'phone': '+1234567890',
    'message': 'Hello! How can we help you today?',
    'header': 'Welcome Message',  # Optional
    'footer': 'Reply with a button',  # Optional
    'buttons': [
        {
            'id': 'support',
            'title': 'Get Support'
        },
        {
            'id': 'sales',
            'title': 'Sales Inquiry'
        }
    ]
})

Send Media Message

wapilot.send_media_message({
    'phone': '+1234567890',
    'media_type': 'image',  # 'image', 'video', 'document', 'audio'
    'media_url': 'https://example.com/image.jpg',
    'caption': 'Check out our new product!',  # Optional
    'file_name': 'product.jpg'  # Required for documents
})

Send Template Message

wapilot.send_template_message({
    'phone': '+1234567890',
    'template': {
        'name': 'appointment_reminder',
        'language': {
            'code': 'en'  # Language code
        },
        'components': [
            {
                'type': 'header',
                'parameters': [
                    {
                        'type': 'image',
                        'image': {
                            'link': 'https://example.com/appointment.jpg'
                        }
                    }
                ]
            },
            {
                'type': 'body',
                'parameters': [
                    {
                        'type': 'text',
                        'text': 'John Doe'  # Dynamic parameter
                    },
                    {
                        'type': 'text',
                        'text': '3:00 PM'  # Dynamic parameter
                    }
                ]
            }
        ]
    }
})

Contact Groups

Get All Groups

groups = wapilot.get_contact_groups()

Create Group

new_group = wapilot.create_contact_group({
    'name': 'VIP Customers',
    'description': 'Our premium customers'  # Optional
})

Update Group

updated_group = wapilot.update_contact_group('group-uuid', {
    'name': 'Premium Customers'
})

Delete Group

wapilot.delete_contact_group('group-uuid')

Automated Replies

Get All Automated Replies

replies = wapilot.get_canned_replies()

Create Automated Reply

new_reply = wapilot.create_canned_reply({
    'name': 'Welcome Message',
    'message': 'Thank you for contacting us! Our team will respond shortly.',
    'keywords': ['hi', 'hello', 'hey']  # Optional trigger keywords
})

Update Automated Reply

updated_reply = wapilot.update_canned_reply('reply-uuid', {
    'message': 'Thank you for reaching out! We will get back to you soon.'
})

Delete Automated Reply

wapilot.delete_canned_reply('reply-uuid')

Templates

Get All Templates

templates = wapilot.get_templates()

Error Handling

The SDK uses Python's built-in exception handling:

try:
    contacts = wapilot.get_contacts()
except requests.exceptions.RequestException as e:
    if e.response is not None:
        # API Error (4xx or 5xx response)
        print(f'API Error: {e.response.json()}')
        print(f'Status Code: {e.response.status_code}')
    else:
        # Network Error (no response received)
        print(f'Network Error: {e}')
except Exception as e:
    # Other errors
    print(f'Error: {e}')

Common Error Codes:

  • 401: Invalid or expired API token
  • 400: Invalid request parameters
  • 404: Resource not found
  • 429: Rate limit exceeded
  • 500: Server error

Best Practices

  1. Error Handling: Always implement proper error handling using try/except blocks
  2. Token Security: Never expose your API token in client-side code
  3. Rate Limiting: Implement proper rate limiting in your application
  4. Message Templates: Use templates for recurring messages
  5. Contact Management: Keep contact information up to date
  6. Testing: Test your integration thoroughly in a development environment

Support

For support or inquiries, please contact:

License

MIT License - feel free to use this SDK in your projects.

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

wapilot_sdk-1.0.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

wapilot_sdk-1.0.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file wapilot_sdk-1.0.0.tar.gz.

File metadata

  • Download URL: wapilot_sdk-1.0.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for wapilot_sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 59944a082e21812d1430b8b1a2d4e7cb530286332d0ccf4f0884486ec26b22f6
MD5 619e21d6facef4217acb149e4c37a407
BLAKE2b-256 309abda7299975a2b6f91efd181476beb569304da13b64d04facfbd33c8dddc9

See more details on using hashes here.

File details

Details for the file wapilot_sdk-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: wapilot_sdk-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for wapilot_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2276003b1aa4aba3f596617b044553d207d0e55b5c5764e8ce5b5a72128446a6
MD5 a01c278fbae40f0731afdac58e0ff0d4
BLAKE2b-256 b450bb57a21db64ead27342003db43a1c8a0fb19a01f1690ce54a944150e6d49

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