Skip to main content

Chatwoot management bridge with REST API and async Python client

Project description

vital-chatwoot-bridge

Chatwoot management bridge with REST API and async Python client.

What It Does

  • REST Management API — CRUD endpoints for Chatwoot contacts, conversations, messages, agents, and inboxes, secured with Keycloak JWT
  • Unified Messaging — Single POST /messages endpoint for inbound and outbound messages across SMS, email, and iMessage (via LoopMessage)
  • Webhook Bridge — Routes Chatwoot webhook events to AI agents via WebSocket (AIMP protocol)
  • API Inbox Integrations — LoopMessage (bidirectional iMessage) and Attentive (inbound aggregation)

Client Library

Install with client dependencies only (no server deps):

pip install vital-chatwoot-bridge[client]

Usage

from vital_chatwoot_bridge.client.client import ChatwootBridgeClient

async with ChatwootBridgeClient(
    base_url="https://bridge.example.com",
    keycloak_url="https://keycloak.example.com",
    realm="myrealm",
    client_id="my-client",
    client_secret="secret",
) as client:
    # Contacts
    contacts = await client.list_contacts(page=1)
    contact = await client.create_contact(name="Jane Doe", email="jane@example.com")

    # Conversations
    convs = await client.list_conversations(status="open")
    summary = await client.account_summary()

    # Messages
    result = await client.post_message(
        direction="outbound",
        contact_identifier="jane@example.com",
        message_content="Hello from the bridge!",
        inbox_id=1,
    )

    # Force a new conversation instead of reusing an open one
    result = await client.post_message(
        direction="outbound",
        contact_identifier="+15551234567",
        message_content="New thread",
        inbox_id=6,
        conversation_mode="create_new",
    )

Exception Handling

from vital_chatwoot_bridge.client.exceptions import (
    BridgeClientError,
    AuthenticationError,
    NotFoundError,
    ValidationError,
    ServerError,
)

try:
    contact = await client.get_contact(999999)
except NotFoundError:
    print("Contact not found")
except AuthenticationError:
    print("Token expired or invalid")

Response Models

from vital_chatwoot_bridge.client.models import PaginatedResponse, SingleResponse

All list endpoints return PaginatedResponse (with .data, .meta).
All single-item endpoints return SingleResponse (with .data).

Server Deployment

See aws_deploy/README.md for ECS Fargate deployment.

Local Development

# Start with Docker Compose
docker compose up --build

# Run endpoint tests
python -m test_endpoint_scripts.test_contacts
python -m test_endpoint_scripts.test_conversations
python -m test_endpoint_scripts.test_messages --case m-send-lm -v

# List all test case IDs
python -m test_endpoint_scripts.test_messages --list

Configuration

All configuration via environment variables. Hierarchical config (inbox mappings, API integrations) uses CW_BRIDGE__ prefix with __ separator. See env.example.

Architecture

vital_chatwoot_bridge/
  api/
    routes.py                    # Health endpoint
    api_inbox_routes.py          # LoopMessage / Attentive inbound/outbound
    chatwoot_management_routes.py  # Management REST API (36 endpoints)
  chatwoot/
    api_client.py                # Chatwoot API client (httpx, retries)
    management_models.py         # Pydantic request/response models
  client/                        # Standalone client library
    client.py                    # ChatwootBridgeClient (async)
    auth.py                      # Keycloak JWT token management
    base.py                      # HTTP client with error mapping
    models.py                    # Response envelope models
    exceptions.py                # Typed exception hierarchy
  core/
    config.py                    # CW_BRIDGE__ env parser integration
  utils/
    env_parser.py                # Generic hierarchical env var parser
    jwt_verify.py                # Keycloak JWT verification (server-side)
    logging_config.py            # JSON / text log formatting
  handlers/
    webhook_handler.py           # Chatwoot webhook → AI agent routing

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

vital_chatwoot_bridge-0.1.0.tar.gz (79.9 kB view details)

Uploaded Source

Built Distribution

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

vital_chatwoot_bridge-0.1.0-py3-none-any.whl (98.4 kB view details)

Uploaded Python 3

File details

Details for the file vital_chatwoot_bridge-0.1.0.tar.gz.

File metadata

  • Download URL: vital_chatwoot_bridge-0.1.0.tar.gz
  • Upload date:
  • Size: 79.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for vital_chatwoot_bridge-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0feec8b2f70df691b4993dd18a93e6fb9af7e45b181fdd6a2026508feeac6bc0
MD5 c4f085228db56f3bdd602cfa6ad5db85
BLAKE2b-256 e816c7474c5fda1e639fe2e7285e13d4f29744832772f1307a3350021043c233

See more details on using hashes here.

File details

Details for the file vital_chatwoot_bridge-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for vital_chatwoot_bridge-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 df9feaf92375461b7e70365ee3dd879d9016b32ab2913e7fd5d6c18239f50e4f
MD5 777f051d5b54df08af154d5b2d0519f2
BLAKE2b-256 fe900256a57bc8b3d2d75df75216a4f52ed8016b0ec0a4bc862b4f618105cec4

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