Skip to main content

Official Python SDK for OmniAI API

Project description

OmniAI Python SDK

Official Python SDK for the OmniAI API - Multi-channel messaging platform with AI automation.

Installation

pip install omniai-sdk

Quick Start

from omniai import Client

# Initialize client
client = Client('YOUR_API_KEY')

# Send a message
message = client.messages.send(
    phone='+5511999999999',
    channel='whatsapp',
    type='text',
    content='Olá! Como posso ajudar?'
)

print(f'Message sent: {message["id"]}')

Features

  • Multi-channel messaging - WhatsApp, Email, SMS, Telegram
  • Contact management - Create, update, search contacts
  • Campaign automation - Schedule and manage marketing campaigns
  • AI-powered features - Chat completions, sentiment analysis, intent detection
  • Analytics & Reports - Get insights and export reports
  • Type hints - Full type annotation support
  • Error handling - Comprehensive exception classes

Usage Examples

Send Messages

# Text message
message = client.messages.send(
    phone='+5511999999999',
    channel='whatsapp',
    type='text',
    content='Hello from OmniAI!'
)

# Media message
message = client.messages.send(
    phone='+5511999999999',
    channel='whatsapp',
    type='image',
    content='Check this image',
    media_url='https://example.com/image.jpg'
)

# Bulk send
result = client.messages.send_bulk([
    {
        'phone': '+5511999999999',
        'channel': 'whatsapp',
        'type': 'text',
        'content': 'Message 1'
    },
    {
        'phone': '+5511888888888',
        'channel': 'whatsapp',
        'type': 'text',
        'content': 'Message 2'
    }
])

Manage Contacts

# Create contact
contact = client.contacts.create(
    name='João Silva',
    phone='+5511999999999',
    email='joao@example.com',
    tags=['customer', 'vip']
)

# List contacts
contacts = client.contacts.list(
    page=1,
    limit=50,
    search='João'
)

# Update contact
updated = client.contacts.update(
    contact_id='contact-123',
    tags=['customer', 'vip', 'premium']
)

Create Campaigns

campaign = client.campaigns.create(
    name='Black Friday 2024',
    channel='whatsapp',
    message_template='Aproveite 50% OFF em todos os produtos!',
    target_audience={
        'tags': ['customer'],
        'segment': 'active'
    },
    scheduled_at='2024-11-29T09:00:00Z'
)

# Start campaign
client.campaigns.start(campaign['id'])

AI Features

# Chat completion
response = client.ai.chat_completion([
    {'role': 'user', 'content': 'Preciso de ajuda com meu pedido'}
])

# Sentiment analysis
sentiment = client.ai.analyze_sentiment(
    'Estou muito satisfeito com o atendimento!'
)
print(sentiment['sentiment'])  # 'positive'

# Intent detection
intent = client.ai.extract_intent(
    'Quero cancelar minha assinatura'
)
print(intent['intent'])  # 'cancel_subscription'

# Generate response
suggestion = client.ai.generate_response(
    context='Cliente perguntou sobre prazo de entrega',
    user_message='Quando chega meu pedido?',
    tone='professional'
)

Analytics

# Get overview
analytics = client.analytics.get_overview(
    start_date='2024-01-01',
    end_date='2024-01-31',
    channel='whatsapp'
)

# Export report
export = client.analytics.export_report(
    report_type='messages',
    start_date='2024-01-01',
    end_date='2024-01-31',
    format='pdf'
)
print(export['downloadUrl'])

Error Handling

from omniai import Client, AuthenticationError, ValidationError, RateLimitError

client = Client('YOUR_API_KEY')

try:
    message = client.messages.send(
        phone='+5511999999999',
        channel='whatsapp',
        type='text',
        content='Hello!'
    )
except AuthenticationError:
    print('Invalid API key')
except ValidationError as e:
    print(f'Validation error: {e}')
except RateLimitError:
    print('Rate limit exceeded, please wait')

Configuration

# Custom base URL
client = Client(
    api_key='YOUR_API_KEY',
    base_url='https://api.omniaiassist.com/v1'
)

API Reference

Messages

  • messages.send(phone, channel, type, content, **kwargs) - Send message
  • messages.get(message_id) - Get message by ID
  • messages.list(**kwargs) - List messages
  • messages.send_bulk(messages) - Send multiple messages

Contacts

  • contacts.create(name, phone, **kwargs) - Create contact
  • contacts.get(contact_id) - Get contact by ID
  • contacts.list(**kwargs) - List contacts
  • contacts.update(contact_id, **kwargs) - Update contact
  • contacts.delete(contact_id) - Delete contact

Campaigns

  • campaigns.create(name, channel, message_template, target_audience, **kwargs) - Create campaign
  • campaigns.get(campaign_id) - Get campaign
  • campaigns.list(**kwargs) - List campaigns
  • campaigns.start(campaign_id) - Start campaign
  • campaigns.pause(campaign_id) - Pause campaign
  • campaigns.delete(campaign_id) - Delete campaign

AI

  • ai.chat_completion(messages, **kwargs) - Chat completion
  • ai.analyze_sentiment(text) - Sentiment analysis
  • ai.extract_intent(text) - Intent detection
  • ai.generate_response(context, user_message, **kwargs) - Generate response

Analytics

  • analytics.get_overview(start_date, end_date, **kwargs) - Get overview
  • analytics.get_messages_stats(start_date, end_date) - Messages stats
  • analytics.get_ai_stats(start_date, end_date) - AI stats
  • analytics.export_report(report_type, start_date, end_date, format) - Export report

Requirements

  • Python 3.7+
  • requests >= 2.25.0

License

MIT License - see LICENSE file for details

Support

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

omniai_sdk-1.0.1.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

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

omniai_sdk-1.0.1-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file omniai_sdk-1.0.1.tar.gz.

File metadata

  • Download URL: omniai_sdk-1.0.1.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for omniai_sdk-1.0.1.tar.gz
Algorithm Hash digest
SHA256 db37646c1235b3c1f0ec8a044a71c89e5f8997e5e44a04bc1e729aa9d3e56d4d
MD5 e282dde55b477d7476a5e2e8c5f121d3
BLAKE2b-256 a1fb438f1f99f7787f378aef343cbdf7c7ade0820688685b2a52a153dd782ff6

See more details on using hashes here.

File details

Details for the file omniai_sdk-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: omniai_sdk-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for omniai_sdk-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 62c70bc545f192787ec44c79f0e7da5e7d65b3a9711fcdced16bd0537947c61d
MD5 064670c43781b69325275469d29b34fc
BLAKE2b-256 2ee28aa356dde9c23966fe58b5966e4c274f4fdb00d00ffa4f1f89458d540a2b

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