Metadata-Version: 2.4
Name: omnichat
Version: 1.0.0
Summary: Direct omnichannel chat SDK for Python — Telegram, Slack, Google Chat, Teams, WhatsApp. No server needed — install, connect your channels, handle messages.
Project-URL: Homepage, https://github.com/omnichat/chat-sdk
Project-URL: Repository, https://github.com/omnichat/chat-sdk
Project-URL: Issues, https://github.com/omnichat/chat-sdk/issues
Author-email: AASolutions <support@aasolutions.io>
License: MIT
License-File: LICENSE
Keywords: bot,chat,gchat,messaging,multichannel,omnichannel,sdk,slack,teams,telegram,whatsapp
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Requires-Dist: cryptography>=41.0.0
Requires-Dist: httpx>=0.24.0
Requires-Dist: pyjwt>=2.8.0
Requires-Dist: websockets>=12.0
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
Requires-Dist: pytest>=7.4.0; extra == 'dev'
Description-Content-Type: text/markdown

# OmniChat

Omnichannel chat SDK for Python. Connect Telegram, Slack, Google Chat, Microsoft Teams, and WhatsApp with a single package — no server deployment needed.

## Install

```bash
pip install omnichat
```

## Usage

```python
import asyncio
from omnichat import OmniChatBot

async def main():
    sdk = OmniChatBot()
    
    sdk.use_telegram("your-bot-token")
    # sdk.use_slack("xoxb-bot-token", "xapp-app-token")
    # sdk.use_gchat(service_account_key="/path/to/service-account.json")
    # sdk.use_teams("your-app-id", "your-app-password")
    
    async def on_message(thread, msg):
        print(f"[{msg.platform}] {msg.author.user_name}: {msg.text}")
        await thread.reply(f"You said: {msg.text}")
    
    async def on_mention(thread, msg):
        await thread.reply(f"Hey {msg.author.user_name}! You mentioned me.")
    
    sdk.on_message(on_message)
    sdk.on_mention(on_mention)
    
    await sdk.start()

asyncio.run(main())
```

## Live-updating replies (tracked messages)

For streaming AI output, don't wait for the full response before showing anything — send once, then rewrite that same message in place as more text arrives:

```python
handle = await thread.reply_tracked("Thinking")  # appears immediately
await thread.update_reply(handle, "Thinking about it...")  # rewrites the same message
await thread.update_reply(handle, "Here's the full answer.")
```

This avoids a chat platform showing "not responding" during long generations, and avoids leaving a stray "Thinking..." message behind — there's only ever one message, and it's rewritten as it grows.

Support varies by platform:

| Platform | `reply_tracked()` | `update_reply()` |
|---|---|---|
| Google Chat | ✅ | ✅ — PATCH `messages.update` |
| Slack | ✅ | ✅ — `chat.update` |
| Telegram | ✅ | ✅ — `editMessageText` |
| Microsoft Teams | ✅ | ✅ — Bot Framework activity update |
| WhatsApp | ✅ (returns a real message id) | ❌ raises `NotImplementedError` — the Cloud API has no endpoint to edit a sent message |

## Supported Platforms

| Platform | Method | How it works |
|---|---|---|
| Telegram | `use_telegram(bot_token)` | Long polling — no public URL needed |
| Slack | `use_slack(bot_token, app_token)` | Socket Mode — no public URL needed |
| Google Chat | `use_gchat(service_account_key, port, path, upload_as_user)` | HTTP webhook + service-account app auth |
| Microsoft Teams | `use_teams(app_id, app_password)` | HTTP webhook + Azure OAuth2 |
| WhatsApp | `use_whatsapp(access_token, phone_number_id, verify_token, port, path)` | HTTP webhook + Graph API |

## Credentials

| Platform | What you need | Where to get it |
|---|---|---|
| Telegram | Bot Token | Talk to @BotFather on Telegram |
| Slack | Bot Token + App Token | api.slack.com — enable Socket Mode |
| Google Chat | Service account JSON key (+ HTTPS endpoint registered in the Chat API config) | console.cloud.google.com — enable the Chat API, configure the app, create a service account |
| Microsoft Teams | App ID + App Password | portal.azure.com — Register a Bot |
| WhatsApp | Access Token + Phone Number ID + Verify Token | developers.facebook.com — create a Meta Business App with WhatsApp integration |

Google Chat file attachments (`send_file()`) additionally need `upload_as_user` set to a Workspace user your service account has [domain-wide delegation](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user#delegate-domain-wide-authority) for — the Chat API's attachment upload endpoint only accepts user authentication, not the app (service-account) authentication used for text messages.

## Requirements

- Python >= 3.10
- No server deployment needed
- No database needed

## Testing

The SDK includes unit tests for core logic (history, state, fluent chaining, etc.):

```bash
pytest tests/
```

**Note:** Network-level tests for real platform integrations are not included. To verify platform integration, deploy the package and test against real platform APIs (Telegram Bot API, Slack Web API, Google Chat API, etc.) with valid credentials and a public URL tunnel (ngrok, Cloudflare tunnel, etc.).
