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).
Django
The same nine endpoints as Django urlpatterns — include them under the prefix you registered with the relay:
# urls.py
from django.urls import include, path
from bloonio_chat_relay_client import WebhookEventType
from bloonio_chat_relay_client.adapters.django import build_callback_urlpatterns
def on_message(ev): # sync or async — both work
...
urlpatterns = [
path(
"api/v1/chat-callbacks/",
include(build_callback_urlpatterns(handlers={WebhookEventType.MESSAGE_RECEIVED: on_message})),
),
]
settings=None reads BLOONIO_CHAT_* env vars. Semantics mirror the FastAPI
router: 401 on missing/bad HMAC#1 headers, 400 on a bad payload or a body
whose event_type doesn't match the path, handler exceptions logged but
still 200. Outbound calls need no adapter — build
ChatRelayClient(ChatRelaySettings()) anywhere.
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.
Metadata
Release files for bloonio-chat-relay-client 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bloonio_chat_relay_client-0.2.0.tar.gz | 21.1 kB | Without provenance | Details for bloonio_chat_relay_client-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bloonio_chat_relay_client-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for bloonio_chat_relay_client-0.2.0-py3-none-any.whl |
Total release size: 43.4 kB
Release files / bloonio_chat_relay_client-0.2.0.tar.gz
| Download URL | bloonio_chat_relay_client-0.2.0.tar.gz |
|---|---|
| Size | 21.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
14bc74f0757861c9355eaa88b8f5e81796ebd79d8a6df7763105274749fa5225
|
|
BLAKE2b-256 checksum How to use checksums |
2283441c4a9295080b9410ace6ab0838aa68e421493b7d4bd8999e53d338fbee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / bloonio_chat_relay_client-0.2.0-py3-none-any.whl
| Download URL | bloonio_chat_relay_client-0.2.0-py3-none-any.whl |
|---|---|
| Size | 22.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
82fdbd5d8c9ead463e750cc6e6eb8768c2ee076e211aeb06ac230830b1d0fa67
|
|
BLAKE2b-256 checksum How to use checksums |
43939ff5ebebf40410451989fcf993b842be2a2ffa7875bed5d013a5a1203188
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Security for bloonio-chat-relay-client 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.