Skip to main content

bloonio_chat_relay_client

Python SDK for bloonio_chat_relay. Lets a tenant backend integrate the bloonio chat PaaS via the same tenant_id + tenant_secret model that bloonio_auth_relay_client uses for auth.

Install

pip install bloonio-chat-relay-client[fastapi]   # for FastAPI tenants
pip install bloonio-chat-relay-client[django]    # for Django tenants
pip install bloonio-chat-relay-client            # framework-agnostic core only

Two-minute integration (FastAPI)

# .env
BLOONIO_CHAT_BASE_URL=https://chat-relay.example.com
BLOONIO_CHAT_TENANT_ID=<uuid>
BLOONIO_CHAT_TENANT_SECRET=sk_...
BLOONIO_CHAT_CALLBACK_BASE_URL=https://your-backend.example.com
# main.py
from fastapi import FastAPI
from bloonio_chat_relay_client.adapters.fastapi import BloonioChatAdapter

app = FastAPI()
BloonioChatAdapter.from_env(app)   # mounts /api/v1/chat-callbacks/* + wires the client
# anywhere
from bloonio_chat_relay_client import get_chat_client

chat = get_chat_client()
convo = chat.create_conversation(
    visitor_user_id="user-123",
    visitor_display_name="Marie",
    locale="fr",
    metadata={"order_id": "ORD-9981"},
)
chat.send_message(convo.id, role="visitor", content="Where is my order?")

# For in-app SDKs (web/Flutter) — mint a short-lived signed token your
# client SDK uses to authenticate its WebSocket to chat-relay.
token = chat.mint_visitor_token(
    visitor_user_id="user-123",
    visitor_email_hash="sha256:...",
    ttl_seconds=3600,
)

Public surface

from bloonio_chat_relay_client import (
    ChatRelayClient,         # sync
    AsyncChatRelayClient,    # async
    ChatRelaySettings,
    ChatRelayError,
    # Domain types (Pydantic)
    Conversation,
    Message,
    Ticket,
    KnowledgeDocument,
    WebhookEvent,
    # Enums
    MessageRole,
    ConversationStatus,
    TicketStatus,
    TicketPriority,
    WebhookEventType,
)

Webhook callbacks

The adapter mounts nine HMAC#1-verified endpoints under /api/v1/chat-callbacks/*:

Path Event Phase
POST /api/v1/chat-callbacks/conversation-started New conversation opened 8
POST /api/v1/chat-callbacks/message-received Visitor sent a message 8
POST /api/v1/chat-callbacks/ticket-created Ticket auto-created via escalation 8
POST /api/v1/chat-callbacks/ticket-assigned Ticket claimed by a human agent 8
POST /api/v1/chat-callbacks/ticket-resolved Ticket marked resolved 8
POST /api/v1/chat-callbacks/escalation-triggered Bot escalated to human handoff 8
POST /api/v1/chat-callbacks/agent-assigned Operator claimed a conversation (visitor handoff in progress) 10a
POST /api/v1/chat-callbacks/agent-released Operator released the conversation back to inbox 10a
POST /api/v1/chat-callbacks/agent-resolved Operator marked the conversation resolved 10a

Provide handlers in BloonioChatAdapter.from_env(app, handlers={...}) to react to events on your side. Handlers are optional — events without a registered handler are accepted (HMAC#1 verified), logged at debug, and return {"received": True}.

Agent-takeover event payloads (phase 10a)

The three agent_* events share the same body shape:

{
  "conversation_id": "<chat_api ObjectId>",
  "tenant_id": "<UUID v7>",
  "status": "ASSIGNED" | "WAITING" | "RESOLVED",
  "operator_id": "<UUID v7>",
  "operator_display_name": "Sarah Chen",   // only on agent_assigned
  "visitor_session_id": "vs_<base64url>",
  "escalation_reason": "user_requested" | "restricted_topic" | "low_confidence" | "user_request" | "direct" | null,
  "claim_count": 1,
  "claimed_at":  "2026-05-22T12:34:56Z",
  "released_at": null,
  "resolved_at": null
}

Use these to update your CRM, send push notifications, or trigger analytics — apps_api's ChatIntegrationService.handle_agent_assigned(...) is the canonical reference handler (phase 10d).

Relationship to bloonio_auth_relay_client

This SDK is the chat analog of bloonio_auth_relay_client. The HMAC scheme is identical (header names, signature format, replay-protection window), so a backend that already integrates the auth SDK can reuse operator muscle memory. Only the domain types and the wrapped methods differ. See bloonio_chat_api/docs/12_PAAS_CONVERSION_PLAN.md §4.2 / §7.1.

License

Proprietary — Bloonio internal.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bloonio_chat_relay_client-0.1.1.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

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

bloonio_chat_relay_client-0.1.1-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file bloonio_chat_relay_client-0.1.1.tar.gz.

File metadata

File hashes

Hashes for bloonio_chat_relay_client-0.1.1.tar.gz
Algorithm Hash digest
SHA256 357f7bb99f64f9cfcceb5d6e0c0b907751f2d65db3fc73d45e8948a42c08bbd2
MD5 7b4e80175e509d572cd11bfa6610888d
BLAKE2b-256 768356821f6141b779105dc840699a253a7e0b37b75f6e053faf8c974b3bf8f0

See more details on using hashes here.

File details

Details for the file bloonio_chat_relay_client-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for bloonio_chat_relay_client-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 11ab3f74240fb5148487580e701bee5b4fbb644f019ed6a9cd85772d580ae7c2
MD5 dc4006195849c272bf94b66039bae4bf
BLAKE2b-256 907f1662ac8eedc5b1ca4df8874072ca59d22c494dfa992b112ee9ace4654606

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 Sentry Error logging StatusPage Status page