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 messagemessages.get(message_id)- Get message by IDmessages.list(**kwargs)- List messagesmessages.send_bulk(messages)- Send multiple messages
Contacts
contacts.create(name, phone, **kwargs)- Create contactcontacts.get(contact_id)- Get contact by IDcontacts.list(**kwargs)- List contactscontacts.update(contact_id, **kwargs)- Update contactcontacts.delete(contact_id)- Delete contact
Campaigns
campaigns.create(name, channel, message_template, target_audience, **kwargs)- Create campaigncampaigns.get(campaign_id)- Get campaigncampaigns.list(**kwargs)- List campaignscampaigns.start(campaign_id)- Start campaigncampaigns.pause(campaign_id)- Pause campaigncampaigns.delete(campaign_id)- Delete campaign
AI
ai.chat_completion(messages, **kwargs)- Chat completionai.analyze_sentiment(text)- Sentiment analysisai.extract_intent(text)- Intent detectionai.generate_response(context, user_message, **kwargs)- Generate response
Analytics
analytics.get_overview(start_date, end_date, **kwargs)- Get overviewanalytics.get_messages_stats(start_date, end_date)- Messages statsanalytics.get_ai_stats(start_date, end_date)- AI statsanalytics.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
- Documentation: https://docs.omniaiassist.com
- GitHub Issues: https://github.com/omniaiassist/omniai-python-sdk/issues
- Email: support@omniaiassist.com
Project details
Release history Release notifications | RSS feed
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.0.tar.gz
(10.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file omniai_sdk-1.0.0.tar.gz.
File metadata
- Download URL: omniai_sdk-1.0.0.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e22b804beb3cfe93052582a311a2ef0f085224bf848874893867395d44c961fa
|
|
| MD5 |
6144ee3ba393ed2af1cf15bbc47886dc
|
|
| BLAKE2b-256 |
532de9d368d72314fbd4f657b011810cc8621a801ac6e1ffb37a36f98e9c6d1f
|
File details
Details for the file omniai_sdk-1.0.0-py3-none-any.whl.
File metadata
- Download URL: omniai_sdk-1.0.0-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76fb13e2c3c87a559f685b6b5f3e3d0860b58f47b25e1aecb07c9b260b0564b6
|
|
| MD5 |
5a19ef8209cd517fc6b1b9bab8326662
|
|
| BLAKE2b-256 |
b1a7f826900b384db61b56fc184712354a7d32bc39ad6dcafbe8702518c67f14
|