# Chatwork Handbook > Chatwork documentation: quickstart, architecture, agents and Chatwork Router, channels, the operator dashboard, billing, security and the API reference. URL: https://chatwork.io/en/docs These pages are generated from the same repository as the product. When they disagree with the code, the code wins and the page gets fixed in the same change. ## Start here - [What Chatwork is](https://chatwork.io/en/docs/overview): The platform in one page — the pieces, who owns what, and the rules the product is built on. - [Quickstart](https://chatwork.io/en/docs/quickstart): Bring up chatwork, the bridge, Chatwork Router and the site on one host with Docker Compose. - [Domains and routing](https://chatwork.io/en/docs/domains): Which hostname serves what, how the edge keeps public contracts intact, and how to run it under your own domain. - [Signup and sign-in](https://chatwork.io/en/docs/signup): How a company creates its workspace, how team members sign in, and how an operator controls who may sign up. ## Platform - [Architecture](https://chatwork.io/en/docs/architecture): Services, request paths, storage and the delivery guarantees the bridge makes. - [Agents and Chatwork Router](https://chatwork.io/en/docs/router): How every message is routed to one Dot agent, grounded with built-in cited knowledge, logged and made explainable. - [What works today](https://chatwork.io/en/docs/channels): The capability table, copied from the engineering status file with its evidence. Marketing may not exceed it. - [Human handoff and tickets](https://chatwork.io/en/docs/handoff): The three handoff signals, what a handoff does, and how tickets and SLAs follow from it. - [Inbox engine](https://chatwork.io/en/docs/inbox-engine): The Chatwork inbox runs on the chatwork engine. How the bridge talks to it, and the version policy. - [Web widget](https://chatwork.io/en/docs/widget): One script tag, signed visitor sessions, every visitor in the inbox. - [MCP server and tools](https://chatwork.io/en/docs/mcp): The bridge as an MCP server for your tools, and tenant MCP servers as tools for Dot. - [Billing and plans](https://chatwork.io/en/docs/billing): Plans, quotas, invoices in halalas, subscriptions and what "paid" means. - [Operator dashboard](https://chatwork.io/en/docs/dashboard): A tour of the dashboard your team works in — overview, inbox, tickets, agents and knowledge, team, settings. ## Operate - [Security and permissions](https://chatwork.io/en/docs/security): Principals, roles, secrets at rest, rate limits and the identifiers that are frozen on purpose. - [Operations](https://chatwork.io/en/docs/operations): Backups, upgrades, migrations, rotation and the gate that runs before every release. ## Reference - [API reference](https://chatwork.io/en/docs/api): The HTTP surface by group, with the credential each route needs. Base URL https://chatwork.io or https://api.chatwork.io. - [Configuration](https://chatwork.io/en/docs/configuration): Every environment variable the stack reads, grouped by service, with what breaks without it. - [Changelog and version matrix](https://chatwork.io/en/docs/changelog): What changed in each platform version and which inbox engine (chatwork) version it ships with. --- # What Chatwork is > The platform in one page — the pieces, who owns what, and the rules the product is built on. URL: https://chatwork.io/en/docs/overview Section: Start here Chatwork is a customer-conversation platform you run yourself. It has three moving parts and one version number. | Part | What it is | Where it runs | |---|---|---| | **Inbox** | The Chatwork inbox, which runs on the chatwork engine, pinned to `v4.19.1`. It owns conversations, contacts, assignment and labels. | `chat.chatwork.io` | | **Bridge** | A FastAPI service: tenants, signup and sign-in, the Dot agent pipeline, Chatwork Router, tickets, billing, the MCP server and the operator dashboard (Arabic and English). | `app.chatwork.io` (dashboard, `/login`, `/signup`), `chatwork.io/api/*`, `/mcp`, `/widget.js` | | **Site** | This static site in English and Arabic: marketing, pricing calculator, docs, blog, the agents catalogue and downloadable PDFs. | `chatwork.io/en`, `chatwork.io/ar` | Behind them: PostgreSQL (`pgvector/pgvector:pg16`) as the system of record, Redis for counters, locks and control state, and Caddy as the edge that maps the four hostnames to the right service. ## The rules we build by - **Ground truth first.** Nothing is claimed in the UI, the docs or this site before it has code and a test. The [capability table](/en/docs/channels) is the ceiling for every sentence of marketing copy. - **One conversation store.** The inbox is the only place a conversation lives. The bridge reads and writes it through the REST API and the agent-bot webhook, never its database. - **No fabricated data.** No demo metrics, no invented defaults, no `paid` without a payment record. - **Outbound effects are dangerous.** Anything that sends to a customer, creates an inbox or writes an invoice has a test with the external call mocked. - **Prompts are files.** Agent prompts live in `agents/registry/*.yaml`, versioned, never in code strings. - **One version.** `VERSION` at the repository root is the platform version; the bridge, the MCP manifest and the site read it. ## Who it is for Teams in Saudi Arabia and the wider region that want AI on their support channels without handing conversations to a third-party SaaS: e-commerce stores on Salla or Zid, service businesses, and agencies operating inboxes for several clients (multi-tenant from day one). ## Where to go next - [Quickstart](/en/docs/quickstart) brings the stack up with Docker Compose. - [Architecture](/en/docs/architecture) explains the request paths and storage. - [Agents and Chatwork Router](/en/docs/router) explains how a message is routed and grounded. --- # Quickstart > Bring up chatwork, the bridge, Chatwork Router and the site on one host with Docker Compose. URL: https://chatwork.io/en/docs/quickstart Section: Start here You need a Linux host with Docker 24+, four DNS records pointing at it (`chatwork.io`, `app.`, `chat.`, `api.` or your own domain) and an OpenAI-compatible LLM endpoint. ## 1. Clone and configure ```bash git clone chatwork && cd chatwork cp infra/.env.example infra/.env ``` Open `infra/.env` and set at least: | Variable | Purpose | |---|---| | `PLATFORM_DOMAIN` | Your apex domain, e.g. `chatwork.io`. Caddy derives `app.`, `chat.` and `api.` from it. | | `ACME_EMAIL` | Let's Encrypt contact for automatic TLS. | | `POSTGRES_PASSWORD`, `REDIS_PASSWORD`, `SECRET_KEY_BASE`, `DOT_DB_PASSWORD` | Database, cache and chatwork secrets (`openssl rand -hex 32`). | | `DOT_ADMIN_API_KEY`, `CHATWOOT_WEBHOOK_SECRET`, `DOT_WIDGET_SIGNING_KEY`, `DOT_CREDENTIALS_KEY` | Bridge secrets; the first three must be at least 32 characters in production. | | `DOT_LLM_BASE_URL`, `DOT_LLM_API_KEY`, `DOT_LLM_MODEL` | Your LLM provider (OpenAI-compatible). Optional Chatwork Router embeddings use the same endpoint. | | `DOT_DATABASE_URL` | `postgresql://dot_bridge:@postgres:5432/dot_bridge` — required for Chatwork Router and the built-in knowledge base. | Never commit `.env`. The gate script fails if one is tracked. ## 2. Start the stack ```bash docker compose -f infra/docker-compose.yml up -d --build ``` Caddy obtains certificates, chatwork migrates its database on first boot, and the bridge starts once Postgres and Redis are healthy. ## 3. Apply the bridge migrations and seed the agents ```bash docker compose -f infra/docker-compose.yml exec bridge python -m storage.migrate docker compose -f infra/docker-compose.yml exec bridge python -m cloudrag.seed ``` The first command creates the bridge tables, including Chatwork Router's (`012_cloudrag.sql`, `014_knowledge_builtin.sql`). The second upserts the six agents; add `--embed` when `CLOUDRAG_EMBEDDINGS=provider` to embed their routing intents. ## 4. Create the chatwork account and the agent bot 1. Open `https://chat.` and create the first (super-admin) account. 2. Profile → Access token: put it in `CHATWOOT_ADMIN_API_TOKEN`; note the account id for `CHATWOOT_ACCOUNT_ID`. 3. Settings → Agent Bots → add a bot with the outgoing URL `https:///webhooks/chatwoot?token=`; put its token in `CHATWOOT_BOT_TOKEN`. 4. `docker compose -f infra/docker-compose.yml up -d bridge` to pick up the new variables. ## 5. Create the first workspace The quickest way is the signup page: open `https://app./en/signup` (or `/ar/signup`), enter the company, your name, email, a workspace ID and a password. One call creates the tenant, its first owner and a 14-day trial, and signs you in to the operator dashboard. See [Signup and sign-in](/en/docs/signup) for the modes (`open`, `code`, `closed`). Operators can also onboard a tenant with the admin key: ```bash curl -sS -X POST https:///api/v1/tenants/onboard \ -H "X-Admin-Key: $DOT_ADMIN_API_KEY" -H 'Content-Type: application/json' \ -d '{"slug":"acme","name_ar":"شركة أكمي","plan":"growth","channels":["web_widget"]}' ``` The response carries the tenant API key once. Embed the widget on any page: ```html ``` ## 6. Verify ```bash curl -fsS https:///health # {"status":"ok","service":...,"version":""} curl -fsS https:///ready # {"status":"ready","checks":{"redis":"ok","database":"ok"}} curl -fsS https://chat./api # chatwork version curl -s -o /dev/null -w '%{http_code}\n' https:///api/v1/tenants # 401 without a key ``` Send a message through the widget; it appears in the chatwork inbox, Dot answers, and the routing decision shows up under `GET /api/v1/tenants/acme/cloudrag/decisions`. --- # Domains and routing > Which hostname serves what, how the edge keeps public contracts intact, and how to run it under your own domain. URL: https://chatwork.io/en/docs/domains Section: Start here One Caddy instance (`infra/Caddyfile`) fronts the whole platform. The split is deliberate: the marketing site must never be able to break the API, and customer-embedded URLs must never move. | Host | Serves | Backed by | |---|---|---| | `chatwork.io`, `www.chatwork.io` | Marketing, pricing, agents, docs, blog and resources under `/en` and `/ar`; `/llms.txt` | Static files built from `apps/web` | | `chatwork.io/api/*`, `/mcp`, `/.well-known/mcp.json`, `/webhooks/*`, `/widget.js`, `/health`, `/static/portal/*` | Public API, MCP server, webhooks, widget | The bridge (same origin as the site, so the widget and the status strip need no CORS) | | `app.chatwork.io` | Operator dashboard and the sign-in / sign-up page, each under `/ar` and `/en` (`/en/login`, `/ar/signup`, `/en`) | The bridge | | `api.chatwork.io` | The API without the site in front of it (for integrators who prefer a clean host) | The bridge | | `chat.chatwork.io` | Inbox console and WebSocket (`/cable`) | chatwork Rails | ## Contracts that do not move Customers embed `https://chatwork.io/widget.js`; MCP clients discover `https://chatwork.io/mcp`; chatwork's agent bot posts to `https://chatwork.io/webhooks/chatwoot?token=…`. Those paths stay on the apex host forever. The Caddyfile routes them by path prefix before anything falls through to the static site. Legacy portal paths on the apex (`/saas`, `/inbox.html`) redirect to `app.chatwork.io` with a 301. ## Your own domain Set `PLATFORM_DOMAIN=example.com` in `infra/.env`. Caddy serves `example.com`, `www.`, `app.`, `api.` and `chat.` and requests certificates for all five. Set `DOT_PUBLIC_BASE_URL=https://example.com` and `CHATWOOT_PUBLIC_URL=https://chat.example.com` so generated URLs (agent-bot webhook, widget origin, payment return page) match. ## Behind Cloudflare The production deployment of chatwork.io sits behind a Cloudflare Worker that proxies the same hostnames to the origin over TLS. Keep "Full (strict)" TLS and forward `X-Forwarded-Host` and the WebSocket upgrade for `chat.`; the bridge trusts `X-Forwarded-*` only from `UVICORN_FORWARDED_ALLOW_IPS`. ## Languages Every public page exists under `/en` and `/ar`. The apex root redirects by the browser's `Accept-Language` (Arabic browsers to `/ar`, everyone else to `/en`); old unprefixed paths such as `/docs/quickstart` redirect to `/en/docs/quickstart`. On `app.`, an unprefixed path uses `DOT_DEFAULT_LOCALE` (default `ar`) unless the browser saved a choice; `/login` and `/signup` on the apex redirect to `app.`. --- # Signup and sign-in > How a company creates its workspace, how team members sign in, and how an operator controls who may sign up. URL: https://chatwork.io/en/docs/signup Section: Start here Both pages live on the dashboard host, in Arabic and English: `app.chatwork.io/ar/signup`, `/en/signup`, `/ar/login`, `/en/login`. ## Creating a workspace The signup form asks for the company name, your name, a work email, a workspace ID, a password and a plan. One request then: 1. creates the workspace (and its inbox, when the operator configured provisioning; otherwise the workspace is marked "needs setup" and the dashboard says what to connect); 2. creates you as its first **owner**, with a scrypt-hashed password; 3. starts a trial (`DOT_SIGNUP_TRIAL_DAYS`, default 14) on the plan you picked — no card, no invoice paid, AI replies within the plan's quota; 4. signs you in and opens the dashboard on the setup checklist. The workspace ID is 3 to 40 characters (lowercase letters, digits, hyphens). It is what your team types to sign in and what the chat widget code carries, so pick something stable. The form checks availability as you type. The price shown under the plan is the invoice total after the trial, VAT included, computed by the same code that issues the invoice. ## Signing in Team members sign in with the workspace ID, their email and password. If two-step verification is on, the page asks for the 6-digit code (or a recovery code) next. Sessions live in the browser tab, expire when idle and are revoked on sign-out or password change. - **Invited?** Choose "I have an invite code". The owner creates the invite under "Team & sign-in" and hands you the code; it works once, for 7 days. - **Forgot your password?** The owner issues a reset code from the same page; it works once, for one hour, and ends all your sessions. There is no email step because the platform sends no email yet. - **Operators** with an admin or workspace API key use "Sign in with an API key". ## Who may sign up | `DOT_SIGNUP_MODE` | Behaviour | |---|---| | `open` (default) | Anyone can create a workspace. Bounded by 5 signups per IP per hour and `DOT_SIGNUP_DAILY_CAP` (default 50) per day. | | `code` | The form asks for a signup code (`DOT_SIGNUP_CODE`). Use it for private betas and reseller onboarding. | | `closed` | The signup tab disappears; only operators create workspaces (`POST /api/v1/tenants/onboard`). | Email addresses are not verified (no email provider yet). On a public host, prefer `code` until that exists. --- # Architecture > Services, request paths, storage and the delivery guarantees the bridge makes. URL: https://chatwork.io/en/docs/architecture Section: Platform ## Services ``` chatwork.io ──► Caddy ──► site (static) apps/web ├──► bridge (FastAPI, :8090) apps/bridge └──► chatwoot-rails (:3000) + chatwoot-sidekiq │ postgres (pgvector/pg16) ── databases: chatwoot, dot_bridge redis 7 ── chatwork jobs + bridge counters, locks, control state ``` The bridge is one process with router auto-discovery (`routes/*.py`), two background workers (the X poller and the outbox drain) and no ORM: hand-written SQL migrations in `migrations/NNN_*.sql`, applied by `python -m storage.migrate` under an advisory lock. ## The webhook path (one customer message) 1. **Auth and shape.** The inbox engine (chatwork) does not sign webhooks, so the agent-bot URL carries a secret. Non-`message_created`, private notes and empty content are ignored. 2. **Dedup, then store.** `SET NX` on `(account, conversation, message)`, then the event is written to the inbox as `received` before anything else happens. 3. **Routing to a tenant.** The exact `(account, inbox)` pair must match one active tenant's match set; zero or two matches are quarantined. No reply, no usage. 4. **Guards.** The bot's own echoes, mirrored `/inbound` conversations and conversations a human already owns are skipped. 5. **Pipeline.** `can_ai_reply → begin_ai_reply (generation) → usage.reserve → LLM → may_dispatch(generation) → deliver`. Inside the LLM step Chatwork Router routes the message to an agent and grounds it ([details](/en/docs/router)). 6. **Delivery.** The reply is posted to the inbox with the tenant's bot token; on X conversations it is enqueued to the outbox, which re-checks ownership after the human delay and right before the send. 7. **Handoff.** A keyword, a model tag or an agent policy opens (or reuses) the conversation's ticket, posts a private note and sets the conversation to `open`. 8. **Settle.** Usage is settled with real token counts; the event ends `processed` or `failed(error)`, retryable by an admin. ## Storage - **PostgreSQL** is authoritative for tenants, usage ledger, invoices, payments, subscriptions, connections (encrypted secrets), members and sessions, tickets, commerce, events, audit, quarantine and Chatwork Router (agents, intents, sources, chunks, routing log). - **Redis** keeps rate limits, usage reservations, conversation control (owner + generation), MCP tool cache, X dedup/cursor, short-lived sessions and locks (`SET NX PX`, token-checked release). - **The inbox** (chatwork's database) keeps conversations, messages, contacts, assignment and labels. `DOT_STORAGE_BACKEND=redis` (the historical default) keeps bridge records in Redis with the same code paths; `postgres` makes PostgreSQL authoritative with a Redis mirror. Chatwork Router always uses PostgreSQL when `DOT_DATABASE_URL` is set, independent of that flag. ## Guarantees - **At least once.** Every accepted webhook is persisted before processing; every X send goes through the outbox with backoff (60 s → 5 min → 30 min → 2 h) and a dead state after `outbox_max_attempts`. - **Late AI replies never win.** The control generation is re-checked immediately before every send; a human takeover in between drops the AI reply. - **No customer-facing text on provider errors.** A failing LLM produces a private note and a handoff, never an invented answer. - **Quota before cost.** Usage is reserved before the model is called and released on failure. --- # Agents and Chatwork Router > How every message is routed to one Dot agent, grounded with built-in cited knowledge, logged and made explainable. URL: https://chatwork.io/en/docs/router Section: Platform Chatwork Router is the bridge's built-in agent-routing and knowledge layer. It is not an external service: it is a Python package (`apps/bridge/cloudrag/`) over PostgreSQL, called inside the LLM step of the pipeline. It is mandatory in the sense that every AI reply passes through it; it is resilient in the sense that no store or optional embeddings failure can block a reply. ## The registry is the product Each agent is one file in `agents/registry/`. The same file is read by: - the bridge at start-up (validated; a broken file refuses to start the router), - `python -m cloudrag.seed`, which upserts the agents into `cloudrag_agents` (and with `--embed` embeds their intents when an embeddings provider is enabled), - this site, which renders [/agents](/en/agents) and the routing playground from it, - the conformance fixtures (`agents/fixtures/routing.json`) that the Python router and the TypeScript mirror must both satisfy. Fields that matter for routing: `routing.priority` (tie-break), `routing.keywords` with weights, `routing.channel_boost`, `routing.min_score`, `routing.intents` (sentences for the optional semantic layer), `routing.always_handoff`, and `default: true` on exactly one agent. ## Two layers, one score 1. **Lexical layer (always on).** Text and keywords are normalised (lowercase, Arabic diacritics and tatweel stripped, `أإآ→ا`, `ى→ي`, `ة→ه`, `ؤ→و`, `ئ→ي`). Arabic keywords match as substrings; Latin ones on word boundaries. `lexical = min(1, Σ weight)` plus the channel boost when something matched. 2. **Optional semantic layer (`CLOUDRAG_EMBEDDINGS=provider`).** The message is embedded once (`CLOUDRAG_EMBEDDING_MODEL`, 1536 dimensions). Each agent's score is the best cosine similarity to its embedded intents. `final = 0.55 × semantic + 0.45 × lexical`. The best agent above its `min_score` wins; ties go to the lower priority number; otherwise the default agent (Concierge) takes the message. A tenant can pin an agent (`cloudrag_pinned_agent` on the tenant record) or disable one (`PATCH /cloudrag/agents/{slug}`); the default agent cannot be disabled. ## Built-in knowledge base and grounding By default (`CLOUDRAG_EMBEDDINGS=off`), the knowledge base runs entirely inside PostgreSQL with zero outbound calls: chunks are stored as text and retrieved by normalized term overlap for agents with `knowledge.retrieval: true`, then appended to the system prompt as numbered passages so the model cites them as `[n]` and says what it does not know when nothing matches. With `CLOUDRAG_EMBEDDINGS=provider`, hybrid `pgvector` similarity is merged in. Citations travel with the reply (`routing.citations` in the API response). Sources are pasted text or public https pages (`POST /api/v1/tenants/{slug}/cloudrag/sources`). URLs pass the same SSRF guard as tenant MCP servers; pages are reduced to prose, chunked (~800 characters, paragraph-aware, 120-character overlap) and stored. Identical content for the same workspace is not indexed twice (`deduplicated: true`); new content replaces every chunk of that source in one transaction. ## Policy handoff Guardian has `always_handoff: true`. When it is chosen, the reply ends with a handoff even if the model forgot the tag: the pipeline opens the ticket, posts the private note with the agent's name and sets the conversation to `open`. Keyword handoffs ("I want a human") still run before any routing, exactly as before. ## Explainability Every decision is logged in `cloudrag_routing_log` without the message text (only its hash): agent, reason (`keywords`, `semantic`, `default`, `pinned`), score, layers used, the top candidates with their matched keywords, and latency. `GET /api/v1/tenants/{slug}/cloudrag/decisions` returns the recent log and a 30-day breakdown per agent; `POST …/cloudrag/route` previews a decision without calling the model. ## Degradation, in order | Situation | Behaviour | |---|---| | No `DOT_DATABASE_URL` | Lexical layer on the registry files; no knowledge; `source: registry_files` in every trace. | | Database up, agents not seeded | Same as above until `python -m cloudrag.seed` runs. | | `CLOUDRAG_EMBEDDINGS=off` (default) | Lexical routing and the built-in knowledge base run inside PostgreSQL with no external call. | | Embeddings provider down (when enabled) | Lexical routing and built-in text retrieval continue; sources still index as searchable text. | | Routing log unwritable | Reply proceeds; a warning is logged. | Nothing in this list produces an error for the customer. ## In the operator dashboard The "Agents & knowledge" view lists the six agents with a per-workspace switch, previews a routing decision for any message, manages knowledge sources and shows the recent decisions. The overview shows the 30-day split of decisions per agent. Agent rows are cached per process for 30 seconds and invalidated on a switch, so routing costs one database read per workspace every half minute, not one per message. --- # What works today > The capability table, copied from the engineering status file with its evidence. Marketing may not exceed it. URL: https://chatwork.io/en/docs/channels Section: Platform ## What each state means States: **Live** = code, tests and exercised with real credentials. **Code-ready** = code and tests, waiting on a provider credential or approval. **Test-only** = proven against mocked providers, not yet against the real one. ## Capabilities | Capability | State | Notes | |---|---|---| | X DMs and mentions → Chatwork inbox → AI reply → X | **Live** | One X app today; per-tenant X credentials are not built. | | Self-hosted inbox (chatwork engine) | **Live** | Pinned `v4.19.1`; upgrading is a separate, deliberate change. | | Authentication: admin key, hashed tenant keys, MCP bearer, webhook secret, widget sessions, rate limits | **Live** | | | Tenant routing on exact `(account, inbox)`; ambiguous or unknown → quarantine | **Live** | | | Webhook dedup, bot-echo guard, event inbox with admin retry | **Live** | Retry re-runs the whole handler; side effects before the failure point can repeat. | | X outbox (at-least-once, backoff, dead letters) | **Live (tests)** | Not yet exercised against live X. | | Web widget with signed visitor sessions, `/inbound` into the real Chatwork inbox | **Live** | | | AI/human control with generations; explicit release | **Live** | | | Per-tenant MCP tools (discovery, auth header, cache, SSRF guard) and the MCP server | **Live** | | | Chatwork Router, lexical layer | **Live (tests)** | Conformance fixtures shared with the site. | | Chatwork Router: built-in knowledge base, routing log, optional semantic layer | **Live (tests) / Code-ready** | Built-in knowledge runs on `DOT_DATABASE_URL` with zero outside calls (`CLOUDRAG_EMBEDDINGS=off`); the optional semantic layer (`provider`) needs an embeddings endpoint. | | Usage quotas, subscriptions, invoices in halalas | **Live** | Invoices stay draft until a verified payment. | | Public pricing API and plan calculator | **Live (tests)** | Same arithmetic as the invoices; one catalogue file for the bridge and the site. | | Moyasar payments | **Test-only** | Mocked provider; live keys not configured. | | ZATCA e-invoicing | **Phase-1 QR data only** | Not a compliance claim. | | WhatsApp Cloud API, Telegram, Email (native inboxes) | **Code-ready** | Provisioned by API with the agent bot attached; needs tenant credentials. | | Instagram, Facebook | **Code-ready (register only)** | Connected in the inbox console (`chat.`), registered by the bridge; needs Meta app review. | | Salla and Zid commerce, `lookup_order` tool | **Test-only** | OAuth, webhooks, PII-free order cache built against mocks. | | Human logins, sessions, MFA, RBAC, password reset | **Live (tests)** | Invites and reset codes are hand-delivered (no email provider yet). | | Self-service signup (workspace + owner + trial) and the sign-in page | **Live (tests)** | No email verification yet; modes `open`, `code`, `closed`; rate-limited and capped per day. | | Operator dashboard in Arabic and English, phone layout, overview, agents and knowledge view | **Live (browser-checked locally)** | English coverage is enforced by a test; text the bridge itself returns in Arabic is translated from a fixed list. | | Readiness endpoint, request IDs | **Live (tests)** | `GET /ready`, `X-Request-ID`. | | Tickets with SLA, one open ticket per conversation, handoff → ticket | **Live (tests)** | Breach computed on read; no scheduler or notifications. | | Contacts (read-only CRM view) | **Test-only** | | | Service catalogue, automations | **Not built** | | ## Where this table comes from Source: `docs/STATUS.md` in the repository, updated in the same change as the code. --- # Human handoff and tickets > The three handoff signals, what a handoff does, and how tickets and SLAs follow from it. URL: https://chatwork.io/en/docs/handoff Section: Platform The inbox's conversation status is the ownership model: `pending` means the bot owns the conversation, `open` means a human does. The bridge never replies into an `open` conversation that has an assignee, and a new customer message never gives ownership back to the AI; release is explicit. ## Signals | Signal | When | Confidence | |---|---|---| | **Keyword** | The message contains a tenant handoff keyword (defaults: موظف, بشري, شكوى, مدير, تحويل, دعم فني, مشكلة مالية). Checked before any model call. | 0.95 | | **Model tag** | The model ends its reply with `[HANDOFF]`. The tag is stripped from the customer-facing text. | 0.7 | | **Agent policy** | Chatwork Router routed the message to an agent with `always_handoff: true` (Guardian). | 0.9 | Provider errors and exhausted quotas also hand off, with a private note and no customer-facing text. ## What a handoff does 1. Sets the conversation owner to `human` and bumps the control generation, so any AI reply still in flight is dropped before it is sent. 2. Posts a private note with the reason, the channel and a short summary. 3. Toggles the conversation to `open` in the inbox. 4. Opens the conversation's ticket, or reuses the open one. There is at most one `open|pending` ticket per conversation (a partial unique index enforces it). ## Tickets and SLA Tickets carry a per-tenant number, priority (`low`, `normal`, `high`, `urgent`), status (`open`, `pending`, `resolved`, `closed`), an assignee who must be a member of the tenant, and internal comments. SLA targets are `ticket_sla_first_response_minutes` and `ticket_sla_resolution_minutes` scaled by priority (urgent ×0.25, high ×0.5, normal ×1, low ×2). The first human reply from the inbox stamps `first_response_at`; resolve or close stamps `resolved_at`. Breach is computed when you read the ticket, never stored, so changing the SLA settings re-evaluates everything. ## Giving the conversation back `POST /api/v1/tenants/{slug}/control/{conversation_id} {"action":"release"}` returns ownership to the AI. `claim` and `pause` exist for the portal's take-over and pause buttons. --- # Inbox engine > The Chatwork inbox runs on the chatwork engine. How the bridge talks to it, and the version policy. URL: https://chatwork.io/en/docs/inbox-engine Section: Platform The Chatwork inbox is the only conversation store, and its engine is chatwork, self-hosted on your server. The rest of this page uses the engine's own name, because that is what you install, configure and upgrade. The bridge talks to it in exactly two ways: the REST application API (with the admin token, or the tenant's agent-bot token) and the agent-bot webhook. It never touches chatwork's database. ## Version policy The image is pinned (`chatwoot/chatwoot:v4.19.1`) in `infra/docker-compose.yml`. An upgrade is a separate change: back up, pull the new tag, start Rails and Sidekiq, check `/api`, then run the platform gate. Nothing else moves in that change. The platform `VERSION` does not change when chatwork does; the version matrix in the [changelog](/en/docs/changelog) records both. ## Accounts and inboxes - Outside production, and for the platform's own tenant, the shared `CHATWOOT_ACCOUNT_ID` is used. - In production every other tenant gets its own chatwork account through the Platform API (`CHATWOOT_PLATFORM_TOKEN`), with the bridge's admin user added as an administrator. - A tenant's match set is its own `(account, inbox)` pair plus every routable connection inbox. No two tenants may hold the same pair; the store refuses it and routing quarantines it. ## The agent bot One agent bot per account, `outgoing_url = {DOT_PUBLIC_BASE_URL}/webhooks/chatwoot?token=`. On a tenant's own account the bot token is stored Fernet-encrypted on the tenant record, so replies render as the bot; without it the admin token is used and the echo is recognised by a short-lived marker. ## Native channels WhatsApp Cloud, Telegram and Email are native chatwork inboxes created through the API (`POST /api/v1/accounts/{account}/inboxes`) with the bot attached; Instagram and Facebook are connected in chatwork's UI and then registered with the bridge. chatwork delivers to the provider and reports delivery state. Running a custom connector for a channel chatwork already supports is forbidden by design. --- # Web widget > One script tag, signed visitor sessions, every visitor in the inbox. URL: https://chatwork.io/en/docs/widget Section: Platform ```html ``` The widget is served by the bridge; `data-tenant` selects the tenant. On load it asks for a signed visitor session (`POST /api/v1/tenants/{slug}/widget/session`, rate-limited per IP and slug), caches it in `localStorage` and sends it as a bearer token on every message. ## What happens to a message `POST /api/v1/tenants/{slug}/inbound` runs the same pipeline as every other channel: control check, quota reservation, Chatwork Router routing, model call, delivery. The conversation is created or appended on the tenant's Chatwork inbox (awaited, not fire-and-forget); if the inbox is unreachable the visitor still gets the reply and a failed `inbound_mirror` event is stored for replay. The response includes `agent` and `routing` (the decision, candidates and citations), which you can use to show "answered by Dot Orders" in your own UI. ## Contracts - `GET /api/v1/tenants/{slug}/public` returns the company name and inbox id, never keys or invoices. - A widget token is valid only for its slug, its visitor id and `channel_type = web_widget`. - `window.DiamondDotWidget.{open, close, setTenant}` and the `localStorage` keys `diamond_dot_visitor_id`, `diamond_dot_widget_session` are frozen identifiers (customer pages depend on them). --- # MCP server and tools > The bridge as an MCP server for your tools, and tenant MCP servers as tools for Dot. URL: https://chatwork.io/en/docs/mcp Section: Platform ## The bridge as an MCP server Discovery is public: `GET https://chatwork.io/mcp` or `/.well-known/mcp.json` returns the server info and the tool manifest. Calls (`POST /mcp`, streamable HTTP, JSON-RPC 2.0) need a bearer key. | Tool | Tenant key | Admin key | |---|---|---| | `list_chatwoot_conversations` | own inbox | any tenant (`slug` required) | | `get_conversation_messages` | own inbox | any tenant (`slug` required) | | `list_saas_tenants` | own tenant | all | | `send_reply_to_conversation` | — | yes (sends to the customer on X conversations) | | `toggle_conversation_status` | — | yes | | `ask_dot_wdeftksa` | — | yes | Tool-level denial is JSON-RPC error `-32001 "unauthorized"`; bad arguments are `-32602`. Tool names are a public contract; renaming one breaks MCP clients. ## Tenant MCP servers as tools for Dot A tenant may configure `mcp_url` (https, public address, SSRF-guarded) and an auth header. The bridge runs `initialize → tools/list`, caches the tools for five minutes and passes them to the model as functions; each `tools/call` runs on the tenant's own server, isolated per tenant. `enabled_tools` narrows the list. Built-in tools are added per tenant state: `lookup_order` appears only when a Salla or Zid store is linked and active, and answers only for the verified contact. Agent definitions list the built-in tools they rely on; tenant MCP tools remain available to every agent. --- # Billing and plans > Plans, quotas, invoices in halalas, subscriptions and what "paid" means. URL: https://chatwork.io/en/docs/billing Section: Platform ## Plans | Plan | Monthly | Yearly | AI replies / month | Token quota | |---|---|---|---|---| | Starter | 299 SAR | 2,990 SAR | 1,500 | 300k | | Growth | 799 SAR | 7,990 SAR | 5,000 | 1M | | Enterprise | 1,999 SAR | 19,990 SAR | 50,000 | 10M | The catalogue is one file, `pricing/catalog.json`. The bridge loads it for invoices and quotas, the site reads it at build time, and operators override fields at runtime with `DOT_PLANS_JSON`. ## Quotes and the calculator `GET /api/v1/pricing` returns each plan with a computed quote per interval: subtotal, 15 % VAT rounded half-up to the halala, total, the monthly equivalent of a yearly price, the yearly saving and the cost per 1,000 AI replies. The total is, by construction and by test, the `total_halalas` of the invoice the checkout issues, because both use the same functions. `GET /api/v1/pricing/quote?replies=3200&interval=year` answers the question buyers actually ask: for this many AI replies a month, which plan fits and what does each plan cost. Above the largest quota the answer is `custom_required`; the product has no overage price and does not invent one. The [pricing page](/en/pricing) runs the same arithmetic in the browser (shared fixtures keep the two implementations identical) and refreshes from the API so an operator's override shows without a rebuild. ## Quotas Each AI reply reserves one unit before the model is called and settles with real token usage afterwards; a provider failure releases the reservation. Over quota, API routes answer `429 quota_exceeded`; the webhook stays silent towards the customer, posts a private note and hands off. Only `active` or live `trial` subscriptions may consume quota. ## Money Amounts are integer halalas; VAT is 15 %, rounded half-up to the halala; `*_sar` fields are presentation only. Invoice ids look like `INV-YYYYMM-XXXXXXXX`. An invoice is `draft` until the seller tax fields are configured, then `issued`; it becomes `paid` only through a payment record, either a Moyasar payment re-fetched server-side or a bank transfer confirmed by an admin with a reference. A plan change never switches the plan or quota before activation. ZATCA: invoices carry phase-1 QR TLV data (tags 1–5). This is not a compliance claim; phase-2 onboarding is an owner task. --- # Operator dashboard > A tour of the dashboard your team works in — overview, inbox, tickets, agents and knowledge, team, settings. URL: https://chatwork.io/en/docs/dashboard Section: Platform The dashboard is at `app.chatwork.io/en` (or `/ar`). It follows the language of the URL; the account menu at the bottom of the sidebar switches language and theme. Everything it shows comes from a real endpoint; an unavailable source renders as an explanation, never as a sample number. ## Overview The landing view for a new workspace, and one click away afterwards. - **Conversation counters** for the workspace's inbox set: total, waiting for you (a human owns them), with the bot, resolved. - **Tickets**: open tickets and how many are past their SLA. - **Usage and subscription**: AI replies used against the monthly quota, the plan, the subscription state and the period end. A trial shows the days left; an inactive subscription says plainly that agents are not replying. - **Agent routing**: the 30-day split of routing decisions per agent (needs the Chatwork Router database). - **Setup checklist**: connect the inbox, receive a first conversation, add a knowledge source, invite the team, activate the subscription. Each line is checked from live state and links to the place that fixes it. - **Channels**: the state of every channel connection. ## Inbox Three panes: the conversation list (server-paged, with status tabs and search), the conversation, and the customer's details with ownership, labels and tickets. Replies and internal notes go through the Chatwork inbox. "Take over" stops the AI for that conversation; "Resume AI" hands it back. The composer can ask the routed agent for a reply, which counts against the quota. On a phone the list and the conversation are separate screens, and the sidebar slides in from the menu button. ## Tickets Every handoff opens one ticket per conversation with an SLA clock scaled by priority. The view filters by status, priority and breach, and the detail shows the timeline with internal notes. ## Agents & knowledge - **Agents**: the six Dot agents with a switch per workspace. The default agent cannot be switched off. - **Routing preview**: type a customer message, pick a channel, and see which agent would take it, why, and every candidate's score. No model call, no quota. - **Knowledge sources**: paste text or give a public https page, choose a collection, and index it. Identical content is not indexed twice. - **Recent decisions**: time, channel, agent, reason, score and latency. The message text is never stored. ## Team & sign-in Invite members with a role (owner, manager, agent, billing), change roles, issue password-reset codes, and manage your own password and two-step verification. ## Settings Theme, language and density; usage and the widget embed code; channel connections with their requirements and next step; Salla and Zid stores; subscription and invoices with card or bank-transfer payment. --- # Security and permissions > Principals, roles, secrets at rest, rate limits and the identifiers that are frozen on purpose. URL: https://chatwork.io/en/docs/security Section: Operate ## Principals | Principal | Credential | Scope | |---|---|---| | admin | `DOT_ADMIN_API_KEY` (env, ≥ 32 chars) | every management route | | tenant | random key shown once, stored hashed, rotatable | its own slug | | member | `dot_sess_…` session from a login, stored as SHA-256 | its slug, filtered by role | | widget | HMAC-signed visitor session | its slug + visitor id, `web_widget` only | | webhook | URL secret, constant-time compare | `POST /webhooks/chatwoot` | Missing or invalid credentials get `401` with `WWW-Authenticate: Bearer`; a valid credential for the wrong tenant gets `403`. CORS credentials are always off. ## Self-service signup `POST /api/v1/signup` creates a tenant, its first owner and a trial. It is rate-limited per IP (5 per hour), capped per day platform-wide (`DOT_SIGNUP_DAILY_CAP`) and validates every field with stable error codes. There is no email provider yet, so addresses are not verified: use `DOT_SIGNUP_MODE=code` (a shared signup code, compared in constant time) or `closed` on a host you do not want strangers to create workspaces on. A signup that fails after the tenant was created removes the tenant again. ## Roles `owner`, `manager`, `agent`, `billing` with default-deny RBAC on every tenant path. Chatwork Router routes follow the knowledge-base scopes: reads and routing previews need `kb:read` (owner, manager, agent), writes need `kb` (owner, manager). The last active owner cannot be removed or demoted (atomic guard). TOTP with single-use recovery codes; login lockout per `(slug, email, ip)` and per `(slug, email)`. ## Secrets at rest Provider credentials, agent-bot tokens, commerce tokens and TOTP secrets are Fernet-encrypted with `DOT_CREDENTIALS_KEY`, which lives outside the database. No API returns a secret, a ciphertext, or any `*_token`, `*_secret`, `*_api_key`, `*_password` or `*_enc` field; logs redact `?token=`, `dot_sess_`, `dot_inv_` and `dot_rst_`. ## Response headers Every response carries `X-Request-ID` (the caller's, when well-formed, or a generated one), `X-Content-Type-Options: nosniff` and `Referrer-Policy: no-referrer`. HTML pages add `X-Frame-Options: DENY` and a restrictive `Permissions-Policy`; `/api/*` is `Cache-Control: no-store`. ## Outbound safety Tenant MCP URLs and Chatwork Router source URLs must be https and resolve to public addresses (private, loopback, link-local and reserved ranges are refused). Public X replies are cut to 280 characters, sent with an 8–20 s human delay and back off for 30 minutes on `402`/`429`. ## Frozen identifiers Some names are locked by `docs/INVARIANTS.md` because customers or data depend on them: Redis key prefixes (`diamond:dot:*`), the widget globals (`window.DiamondDotWidget`, `diamond_dot_visitor_id`), the `/health` `service` id, and the MCP tool names. The brand is Chatwork; these identifiers are plumbing and stay as they are. ## Reporting a vulnerability See `SECURITY.md` in the repository. Please do not open public issues for security reports. --- # Operations > Backups, upgrades, migrations, rotation and the gate that runs before every release. URL: https://chatwork.io/en/docs/operations Section: Operate ## The gate `scripts/check.sh` runs the whole platform's checks from a clean checkout: 1. bridge unit tests (Python 3.12 via `uv`, no network), 2. bridge PostgreSQL tier on a throwaway cluster: `pg_ctl` when installed, otherwise an embedded PostgreSQL 16 with pgvector (`scripts/pg_embedded.py`), so Chatwork Router's SQL is always exercised, 3. compile check and the 200-line budget (new files ≤ 200 lines; legacy files may only shrink), 4. registry validation, and the routing and pricing conformance fixtures in Python and TypeScript, 5. site type-check and production build, 6. secret scan and a check that no `.env` is tracked. Nothing merges red. ## Backups Before every deploy: Redis `SAVE` and copy of `dump.rdb`, `pg_dumpall` of PostgreSQL (both databases), copies of `docker-compose.yml` and `.env`, all under `backups/` with `chmod 600`. Test a restore quarterly. ## Upgrading the platform ```bash git pull docker compose -f infra/docker-compose.yml build bridge site docker compose -f infra/docker-compose.yml up -d docker compose -f infra/docker-compose.yml exec bridge python -m storage.migrate docker compose -f infra/docker-compose.yml exec bridge python -m cloudrag.seed ``` Migrations are idempotent and run under an advisory lock; the seed upserts agents by slug and version. Re-run `cloudrag.seed --embed` after changing an agent's intents. ## Upgrading chatwork Change the pinned tag in `infra/docker-compose.yml`, back up, `docker compose pull chatwoot-rails chatwoot-sidekiq && docker compose up -d chatwoot-rails chatwoot-sidekiq`, check `https://chat./api`. Record the new pair in the version matrix. ## Rotation `DOT_ADMIN_API_KEY`, `CHATWOOT_WEBHOOK_SECRET` (update the agent-bot URL in chatwork) and `DOT_WIDGET_SIGNING_KEY` rotate by editing `.env` and restarting the bridge; widget sessions re-issue themselves. Rotating `DOT_CREDENTIALS_KEY` requires re-connecting every channel and re-enrolling MFA, so plan it. ## Monitoring minimums `GET /health` is liveness: `{status, service, version}`; with the admin key it adds configuration and tenant count. `GET /ready` is readiness for the orchestrator: `200` only when Redis answers (and PostgreSQL, when it is the system of record); the Compose health check uses it. Watch `GET /api/v1/admin/events/stats` for `failed` and `dead` counts, and `GET /api/v1/tenants/{slug}/cloudrag/decisions` for routing latency. --- # API reference > The HTTP surface by group, with the credential each route needs. Base URL https://chatwork.io or https://api.chatwork.io. URL: https://chatwork.io/en/docs/api Section: Reference Credentials go in `Authorization: Bearer ` (also `X-Admin-Key` / `X-API-Key`). Responses are JSON with `ok` and, on failure, `error`. ## Public (no credential) | Route | Effect | |---|---| | `GET /api/v1/pricing` | plan catalogue with computed quotes per plan and interval (integer halalas, VAT, yearly saving, cost per 1,000 replies) | | `GET /api/v1/pricing/quote?replies=&interval=&plan=` | plan calculator: recommended plan for a monthly volume and each plan's quote | | `GET /api/v1/signup/config` | signup mode, trial days, password minimum, plan ids | | `GET /api/v1/signup/check?slug=` | workspace ID availability | | `POST /api/v1/signup` | create a workspace, its owner and a trial; returns a member session | | `GET /api/v1/agents` | agent catalogue without prompts | | `GET /ready` | readiness: `200 ready` when Redis (and the database, when it is the system of record) answer; `503 not_ready` otherwise | ## Tenants (admin) | Route | Effect | |---|---| | `GET /api/v1/plans` | plan catalogue | | `GET /api/v1/tenants` | list tenants (never returns keys) | | `POST /api/v1/tenants/onboard` | create a tenant; provisions an inbox or leaves `needs_setup`; key shown once | | `GET/PATCH/DELETE /api/v1/tenants/{slug}` | manage a tenant | | `POST /api/v1/tenants/{slug}/api-key/rotate` | new key shown once | | `GET /api/v1/tenants/{slug}/public` | public widget config (no auth) | ## Conversations and control (tenant) | Route | Effect | |---|---| | `GET …/chatwoot-hub?status=&page=` | paged inbox with server counts | | `GET/POST …/conversations/{id}/messages` | read; agent reply, private note, or `use_ai` | | `POST …/conversations/{id}/status` | `open` / `pending` / `resolved` | | `GET/POST …/control/{id}` | ownership: `claim`, `release`, `pause` | | `POST …/ask`, `POST …/inbound` | run the pipeline; `/inbound` mirrors to the inbox and accepts widget sessions | ## Agents and knowledge — Chatwork Router (tenant) | Route | Effect | |---|---| | `GET …/cloudrag/agents` | catalogue with per-tenant enabled flags | | `PATCH …/cloudrag/agents/{agent}` `{enabled}` | enable or disable an agent (the default agent cannot be disabled) | | `POST …/cloudrag/route` `{text, channel_type}` | routing preview: decision, candidates, matched keywords; no model call | | `GET/POST …/cloudrag/sources` | list; add `{kind: text\|url, title, collection, content\|url}` | | `DELETE …/cloudrag/sources/{id}` | remove a source and its chunks | | `GET …/cloudrag/decisions?limit=` | recent routing log and 30-day stats | Store-backed routes answer `503 cloudrag_unavailable` without `DOT_DATABASE_URL`. ## Tickets, contacts, members, billing, connections, commerce (tenant) `GET/POST …/tickets`, `GET/PATCH …/tickets/{id}`, `POST …/tickets/{id}/comments` · `GET …/contacts`, `GET …/contacts/{id}`, `GET …/contacts/{id}/tickets` · `POST /api/v1/auth/login`, `/auth/logout`, `GET /auth/me`, `/auth/mfa/*`, `/auth/password`, `GET/POST …/members`, `PATCH/DELETE …/members/{id}`, `POST …/members/{id}/reset` · `POST …/billing/change-plan`, `GET …/billing/subscription`, `POST …/billing/checkout`, `POST …/billing/bank-transfer`, `GET …/invoices/{id}` · `GET …/connections`, `POST …/connections/{channel}`, `POST …/connections/{channel}/test`, `DELETE …/connections/{channel}` · `GET …/commerce`, `POST …/commerce/{provider}/authorize`, `GET …/commerce/orders`. ## Platform | Route | Effect | |---|---| | `GET /health` | `{status, service, version}`; detailed with the admin key | | `GET /mcp`, `GET /.well-known/mcp.json`, `POST /mcp` | MCP discovery (public) and calls (bearer) | | `POST /webhooks/chatwoot?token=…` | agent-bot webhook | | `GET /api/v1/admin/events`, `…/stats`, `POST …/{id}/retry` | event inbox/outbox (admin) | | `GET /widget.js?tenant=` | the embeddable widget | --- # Configuration > Every environment variable the stack reads, grouped by service, with what breaks without it. URL: https://chatwork.io/en/docs/configuration Section: Reference Values live in `infra/.env` (never committed). The bridge refuses to start in production (`APP_ENV=production`) when `DOT_ADMIN_API_KEY`, `CHATWOOT_WEBHOOK_SECRET` or `DOT_WIDGET_SIGNING_KEY` are shorter than 32 characters or look like placeholders. ## Edge and site | Variable | Meaning | |---|---| | `PLATFORM_DOMAIN` | apex domain; Caddy serves `www.`, `app.`, `api.`, `chat.` under it | | `ACME_EMAIL` | Let's Encrypt contact | ## chatwork `SECRET_KEY_BASE`, `POSTGRES_DB`, `POSTGRES_USER`, `POSTGRES_PASSWORD`, `REDIS_PASSWORD`, `CHATWOOT_PUBLIC_URL` (`https://chat.`). Mail and storage variables follow chatwork's own documentation. ## Bridge — core | Variable | Meaning | |---|---| | `APP_ENV` | `development` or `production` | | `DOT_PUBLIC_BASE_URL` | `https://`; agent-bot webhook and widget origin are built from it | | `DOT_ALLOWED_ORIGINS` | CORS allowlist (portal origin + customer sites) | | `DOT_ADMIN_API_KEY`, `CHATWOOT_WEBHOOK_SECRET`, `DOT_WIDGET_SIGNING_KEY` | access-control secrets (≥ 32 chars) | | `DOT_CREDENTIALS_KEY` | Fernet key for secrets at rest | | `DOT_STORAGE_BACKEND` | `redis` (default) or `postgres` | | `DOT_DATABASE_URL` | bridge database URL; required by Chatwork Router and the built-in knowledge base | | `UVICORN_FORWARDED_ALLOW_IPS` | proxy IPs trusted for `X-Forwarded-*` | ## Bridge — signup and languages | Variable | Default | Meaning | |---|---|---| | `DOT_SIGNUP_MODE` | `open` | `open`, `code` (requires `DOT_SIGNUP_CODE`) or `closed` | | `DOT_SIGNUP_CODE` | — | shared code for `code` mode; without it `code` behaves as `closed` | | `DOT_SIGNUP_TRIAL_DAYS` | `14` | trial length for self-service signups; `0` starts in `pending_payment` | | `DOT_SIGNUP_DAILY_CAP` | `50` | platform-wide signups per day (bounds trial cost); `0` disables the cap | | `DOT_DEFAULT_LOCALE` | `ar` | language of unprefixed portal and sign-in paths | | `DOT_SITE_URL` | `https://chatwork.io` | marketing site origin (terms and privacy links on the signup page) | ## Bridge — chatwork and channels `CHATWOOT_BASE_URL` (internal, `http://chatwoot-rails:3000`), `CHATWOOT_ACCOUNT_ID`, `CHATWOOT_INBOX_ID`, `CHATWOOT_ADMIN_API_TOKEN`, `CHATWOOT_BOT_TOKEN`, `CHATWOOT_PLATFORM_TOKEN`; X: `X_API_KEY`, `X_API_SECRET`, `X_ACCESS_TOKEN`, `X_ACCESS_TOKEN_SECRET`, `X_BEARER_TOKEN`, `X_BOT_USER_ID`, `X_POLL_INTERVAL_SECONDS`, `X_REPLY_MIN_DELAY_SECONDS`, `X_REPLY_MAX_DELAY_SECONDS`, `ENABLE_X_DIRECT_DISPATCH`. ## Bridge — AI and Chatwork Router | Variable | Default | Meaning | |---|---|---| | `DOT_LLM_BASE_URL` | `https://api.openai.com/v1` | OpenAI-compatible endpoint | | `DOT_LLM_API_KEY`, `DOT_LLM_MODEL` | — / `gpt-4o-mini` | provider key and chat model | | `DOT_SYSTEM_PROMPT`, `DOT_HANDOFF_KEYWORDS` | file defaults | tenant-independent overrides | | `CLOUDRAG_ENABLED` | `true` | turn the store-backed layers off (lexical routing stays) | | `CLOUDRAG_EMBEDDINGS` | `off` | `off` (built-in knowledge base, no outside call) or `provider` (enable semantic vectors) | | `CLOUDRAG_EMBEDDING_MODEL` | `text-embedding-3-small` | embeddings model at the same endpoint | | `CLOUDRAG_EMBEDDING_DIM` | `1536` | must match the `vector(1536)` columns | | `CLOUDRAG_TOP_K` | `4` | default passages per grounded reply | | `CLOUDRAG_LOG_DECISIONS` | `true` | write the routing log | | `CLOUDRAG_REGISTRY_DIR` | bundled | override the registry location | | `PRICING_CATALOG_FILE` | bundled | override the location of `pricing/catalog.json` | ## Bridge — money and commerce `SELLER_NAME`, `SELLER_VAT_NUMBER`, `SELLER_CR_NUMBER`, `SELLER_ADDRESS`, `DOT_PLANS_JSON`, `MOYASAR_SECRET_KEY`, `MOYASAR_PUBLISHABLE_KEY`, `MOYASAR_WEBHOOK_SECRET`, `MOYASAR_LIVE`, `SALLA_CLIENT_ID`, `SALLA_CLIENT_SECRET`, `SALLA_WEBHOOK_SECRET`, `ZID_CLIENT_ID`, `ZID_CLIENT_SECRET`, `ZID_WEBHOOK_SECRET`, `ticket_sla_first_response_minutes`, `ticket_sla_resolution_minutes`. --- # Changelog and version matrix > What changed in each platform version and which inbox engine (chatwork) version it ships with. URL: https://chatwork.io/en/docs/changelog Section: Reference ## Version matrix | Platform | Inbox engine (chatwork) | PostgreSQL | Redis | Python | Node (site build) | |---|---|---|---|---|---| | 3.4.1 | v4.19.1 | 16 (pgvector) | 7 | 3.12 | 22 | | 3.4.0 | v4.19.1 | 16 (pgvector) | 7 | 3.12 | 22 | | 3.3.2 | v4.19.1 | 16 (pgvector) | 7 | 3.12 | 22 | | 3.3.1 | v4.19.1 | 16 (pgvector) | 7 | 3.12 | 22 | | 3.3.0 | v4.19.1 | 16 (pgvector) | 7 | 3.12 | 22 | | 3.2.0 | v4.19.1 | 16 (pgvector) | 7 | 3.12 | 22 | | 3.1.0 | v4.19.1 | 16 (pgvector) | 7 | 3.12 | 22 | | 3.0.0 | v4.19.1 | 16 (pgvector) | 7 | 3.12 | 22 | ## 3.4.1 — 2026-11-15 **Interactive operator dashboard and site polish.** Restored full interactive workflows across the inbox (canned responses, quick phrases, three-mode AI composer assist, tags, contact history and mobile drawer), searchable CRM contacts, `⌘K` command palette and notifications, channel connection setup, plan and billing cycle switching with printable tax invoices, live chat widget preview, super-admin workspace controls, bidi organization names, synchronized dark mode across site and portal, and 100% English/Arabic dashboard coverage. Rebuilt the documentation system (`/ar/docs` and `/en/docs`) on the Wateera handbook architecture: 3-column liquid-glass layout, `meta.json` page tree, `PageActions` copy/raw `.md` endpoints, `/llms-full.txt`, and instant `⌘K` search. ## 3.4.0 — 2026-11-12 **Chatwork Router and built-in knowledge base.** The routing and grounding layer is named **Chatwork Router** across the site, dashboard, sign-in page, plan catalogue, agent descriptions and PDFs, with documentation at [/docs/router](/en/docs/router). By default (`CLOUDRAG_EMBEDDINGS=off`), knowledge chunks are indexed and retrieved inside PostgreSQL with zero outbound embedding calls; optional `CLOUDRAG_EMBEDDINGS=provider` preserves hybrid vector and lexical search and falls back to text indexing if an embeddings request fails. ## 3.3.2 — 2026-11-12 **Security and reliability hardening.** Connect-time IP pinning blocks DNS rebinding across MCP and Chatwork Router URL fetches, knowledge URL fetching streams within a strict 2 MB limit, webhook and JSON endpoints enforce a 1 MiB body limit with strict MCP inbox isolation on empty conversations, rate limits self-heal missing TTLs, failed signups refund the daily cap, widget config escapes HTML breakout sequences, and the reverse proxy adds frame and permissions headers. **MCP sessions and operator dashboard.** Per-tenant MCP sessions (`Mcp-Session-Id`) are cached safely across tool calls with automatic stale-session retry; expired member sessions redirect cleanly to sign in again, workspace switching clears cached Chatwork Router/overview/ticket views, message URL links ignore trailing punctuation, and contacts are deduplicated in the CRM table. ## 3.3.1 — 2026-11-11 **Agents and Chatwork Router.** Built-in tools (`lookup_order`) are scoped to agents that declare them (`dot-orders`); `always_handoff` lexical matches (`dot-guardian`) cannot be diluted by semantic scores; all six agents carry both Arabic and English examples; Chatwork Router combines normalized lexical and vector retrieval with a minimum relevance threshold; and portal AI replies bind the conversation contact for order verification. **Dashboard and storage.** Members with the `billing` role open directly into subscription, quota and invoice payment; PostgreSQL usage settlement runs in one transaction and webhook routing loads connections in one query; dark-mode warning banners and `components.html` follow the "Night and Ember" rules without sample data. ## 3.3.0 — 2026-11-10 **"Night and Ember".** A new identity replaces the 3.2.0 look on the site, the dashboard, the sign-in page, the widget and the PDFs: a mark that is a smile and the Arabic ت (or a C when turned), night and sky blues with one warm colour kept for the main button, and one typeface, Alexandria, for Arabic and English. Brand files are on the [resources](/en/resources) page. **Home page.** Rebuilt around a chat example and the trial length from the catalogue. No placeholder statistics. ## 3.2.0 — 2026-11-10 **Chatwork identity.** The site, the operator dashboard, the sign-in page, the chat widget and the PDFs carry the Chatwork identity: the C mark with its reply dot and tail, sky blue and deep navy, Nunito Sans and IBM Plex Sans Arabic. Light is the default theme; dark mode is navy. Brand files are on the [resources](/en/resources) page. **One name.** Product copy, plan features, dashboard messages and MCP tool descriptions say Chatwork, and the inbox is the Chatwork inbox. The open-source engine keeps its name in these self-hosting docs and in one attribution line. No environment variable, URL or API field changed. The page about the engine moved to [/docs/inbox-engine](/en/docs/inbox-engine). **Self-hosted fonts in the dashboard.** The dashboard and sign-in page no longer call a font CDN. ## 3.1.0 — 2026-11-10 **Two languages everywhere.** The site, the operator dashboard and the sign-in page exist under `/en` and `/ar`. The dashboard's English is enforced by a coverage test: a new Arabic string without a translation fails the gate. **Signup and a clean sign-in page.** `app.chatwork.io/{lang}/signup` creates a workspace, its owner and a 14-day trial in one step; `/login` handles members, MFA, invites and password resets. Modes: open, code, closed. **Operator dashboard.** A real overview (inbox counts, tickets and SLA, usage and subscription, routing split, channel states, a setup checklist), an "Agents & knowledge" view (switches, routing preview, sources, decision log), and a layout that works on phones. **Real pricing.** One catalogue file feeds invoices, the API and the site. `GET /api/v1/pricing` and the calculator use the invoice arithmetic, so the price on the page is the amount on the invoice. **Tuning.** Readiness endpoint, request IDs, ticket updates serialised by a lock, Chatwork Router caching and source de-duplication, and a database test tier that runs anywhere (embedded PostgreSQL with pgvector). **Marketing PDFs** in Arabic and English: overview, pricing, agents, security. ## 3.0.0 — 2026-11-09 **One platform.** The Node "Studio" server that mirrored the portal with in-memory demo data is gone; the FastAPI bridge is the only backend. The portal HTML moved out of a Python string into a template file served at `app.chatwork.io`; design tokens exist once. A single `VERSION` file feeds the bridge, the MCP manifest and this site. **chatwork.io is a marketing site** with `/agents`, `/docs` and `/blog`, built statically; API, MCP, webhooks and the widget stay on the apex host at their existing paths. **Chatwork Router.** Agents are files in `agents/registry/`, loaded by the bridge and the site. Every message is routed to one agent (lexical layer always, semantic layer with pgvector), grounded with cited knowledge chunks, and logged. New API under `/cloudrag/*`, migration `012_cloudrag.sql`, `python -m cloudrag.seed`. **Six Dot agents.** Concierge (default), Support, Sales, Orders, Billing, Guardian (always hands off). **Brand.** User-facing copy says Chatwork; frozen identifiers are unchanged. ## 2.x — 2026-11-04 to 2026-11-05 (as `dot-x-chatwoot`) Sprints 1–5: authentication, tenant routing with quarantine, honest billing in halalas, single conversation store, event inbox/outbox, members with MFA and RBAC, tickets with SLA, Salla/Zid commerce, PostgreSQL repositories, rebrand to Chatwork. --- # دليل تشات وورك > وثائق تشات وورك: البدء السريع، التسجيل، المعمارية، الوكلاء وموجّه تشات وورك، القنوات، لوحة المشغل، الفوترة، الأمان، التشغيل، ومرجع API. URL: https://chatwork.io/ar/docs تُولَّد هذه الصفحات من المستودع نفسه الذي يُبنى منه المنتج. وإذا خالفت الكود فالكود هو الصحيح، وتُصحَّح الصفحة في التغيير نفسه. ## ابدأ هنا - [ما هو تشات وورك](https://chatwork.io/ar/docs/overview): المنصة في صفحة واحدة — الأجزاء، ومن يملك ماذا، والقواعد التي بُني عليها المنتج. - [البدء السريع](https://chatwork.io/ar/docs/quickstart): شغّل chatwork والجسر وموجّه تشات وورك والموقع على خادم واحد باستخدام Docker Compose. - [النطاقات والتوجيه](https://chatwork.io/ar/docs/domains): أي اسم مضيف يخدم ماذا، وكيف تُبقي طبقة الحافة العقود العامة سليمة، وكيف تشغّل المنصة تحت نطاقك الخاص. - [التسجيل وتسجيل الدخول](https://chatwork.io/ar/docs/signup): كيف تنشئ الشركة منشأتها، وكيف يسجّل أعضاء الفريق دخولهم، وكيف يتحكم المشغّل في من يحق له التسجيل. ## المنصة - [البنية](https://chatwork.io/ar/docs/architecture): الخدمات، ومسارات الطلبات، والتخزين، وضمانات التسليم التي يقدّمها الجسر. - [الوكلاء وموجّه تشات وورك](https://chatwork.io/ar/docs/router): كيف تُوجَّه كل رسالة إلى وكيل Dot واحد، وتُسنَد إلى قاعدة المعرفة المدمجة مع الاستشهاد بمصادرها، وتُسجَّل، وتصبح قابلة للتفسير. - [ما الذي يعمل اليوم](https://chatwork.io/ar/docs/channels): جدول القدرات، منقول من ملف الحالة الهندسي مع أدلته. لا يجوز للتسويق أن يتجاوزه. - [التحويل إلى موظف والتذاكر](https://chatwork.io/ar/docs/handoff): إشارات التحويل الثلاث، وما يفعله التحويل، وكيف تنشأ عنه التذاكر ومهل الخدمة (SLA). - [محرك صندوق الوارد](https://chatwork.io/ar/docs/inbox-engine): صندوق وارد تشات وورك يعمل على محرك chatwork. كيف يتخاطب الجسر معه، وسياسة الإصدارات. - [نافذة الدردشة للويب](https://chatwork.io/ar/docs/widget): وسم script واحد، وجلسات زوار موقّعة، وكل زائر في صندوق الوارد. - [خادم MCP والأدوات](https://chatwork.io/ar/docs/mcp): الجسر بوصفه خادم MCP لأدواتك، وخوادم MCP الخاصة بالمنشآت بوصفها أدوات لـ Dot. - [الفوترة والباقات](https://chatwork.io/ar/docs/billing): الباقات والحصص والفواتير بالهللة والاشتراكات ومعنى «مدفوعة». - [لوحة المشغل](https://chatwork.io/ar/docs/dashboard): جولة في اللوحة التي يعمل فيها فريقك — نظرة عامة، صندوق الوارد، التذاكر، الوكلاء والمعرفة، الفريق، الإعدادات. ## التشغيل - [الأمان والصلاحيات](https://chatwork.io/ar/docs/security): جهات الدخول، والأدوار، والأسرار المخزّنة، وحدود المعدّل، والمعرّفات المجمّدة عن قصد. - [التشغيل](https://chatwork.io/ar/docs/operations): النسخ الاحتياطية، والترقيات، والترحيلات، والتدوير، وبوابة الفحص التي تعمل قبل كل إصدار. ## المرجع - [مرجع API](https://chatwork.io/ar/docs/api): واجهة HTTP بحسب المجموعات، مع بيانات الاعتماد التي يحتاجها كل مسار. الرابط الأساسي https://chatwork.io أو https://api.chatwork.io. - [التهيئة](https://chatwork.io/ar/docs/configuration): كل متغيرات البيئة التي تقرؤها المنظومة، مجمّعة بحسب الخدمة، مع ما يتعطّل دونها. - [سجل التغييرات ومصفوفة الإصدارات](https://chatwork.io/ar/docs/changelog): ما الذي تغيّر في كل إصدار من المنصة، وأي إصدار من محرك صندوق الوارد (chatwork) يأتي معه. --- # ما هو تشات وورك > المنصة في صفحة واحدة — الأجزاء، ومن يملك ماذا، والقواعد التي بُني عليها المنتج. URL: https://chatwork.io/ar/docs/overview Section: Start here تشات وورك منصة لمحادثات العملاء تشغّلها بنفسك. تتكوّن من ثلاثة أجزاء عاملة ورقم إصدار واحد. | الجزء | ما هو | أين يعمل | |---|---|---| | **صندوق الوارد** | صندوق وارد تشات وورك، ويعمل على محرك chatwork، مثبّتاً على `v4.19.1`. يملك المحادثات وجهات الاتصال والتعيين والتصنيفات. | `chat.chatwork.io` | | **الجسر** | خدمة FastAPI: المنشآت، والتسجيل وتسجيل الدخول، ومسار معالجة وكيل Dot، وموجّه تشات وورك، والتذاكر، والفوترة، وخادم MCP، ولوحة المشغل (بالعربية والإنجليزية). | `app.chatwork.io` (اللوحة، `/login`، `/signup`)، `chatwork.io/api/*`، `/mcp`، `/widget.js` | | **الموقع** | هذا الموقع الثابت بالإنجليزية والعربية: التسويق، وحاسبة الأسعار، والتوثيق، والمدونة، وكتالوج الوكلاء، وملفات PDF قابلة للتنزيل. | `chatwork.io/en`، `chatwork.io/ar` | خلف هذه الأجزاء: PostgreSQL (`pgvector/pgvector:pg16`) بوصفه المرجع المعتمد للبيانات، وRedis للعدّادات والأقفال وحالة التحكم، وCaddy بوصفه طبقة الحافة التي توجّه أسماء المضيفين الأربعة إلى الخدمة الصحيحة. ## القواعد التي نبني عليها - **الحقيقة المثبتة أولاً.** لا يُذكر شيء في الواجهة أو التوثيق أو هذا الموقع قبل أن يكون له كود واختبار. [جدول القدرات](/ar/docs/channels) هو السقف لكل جملة في النصوص التسويقية. - **مخزن محادثات واحد.** صندوق الوارد هو المكان الوحيد الذي تُحفظ فيه المحادثة. يقرأ الجسر منه ويكتب فيه عبر REST API وWebhook بوت الوكيل، ولا يلمس قاعدة بياناته أبداً. - **لا بيانات مختلقة.** لا مقاييس تجريبية، ولا قيم افتراضية مخترعة، ولا حالة `paid` بلا سجل دفع. - **الآثار الصادرة خطرة.** كل ما يرسل إلى عميل أو ينشئ صندوق وارد أو يكتب فاتورة له اختبار يُحاكى فيه الاستدعاء الخارجي. - **التعليمات (prompts) ملفات.** تعليمات الوكلاء محفوظة في `agents/registry/*.yaml` مع تتبّع إصداراتها، ولا تُكتب أبداً كسلاسل نصية داخل الكود. - **إصدار واحد.** ملف `VERSION` في جذر المستودع هو إصدار المنصة؛ يقرؤه الجسر وبيان MCP والموقع. ## لمن هذه المنصة للفرق في المملكة العربية السعودية والمنطقة التي تريد ذكاءً اصطناعياً على قنوات الدعم دون تسليم المحادثات إلى خدمة SaaS من طرف ثالث: المتاجر الإلكترونية على Salla أو Zid، وشركات الخدمات، والوكالات التي تدير صناديق وارد لعدة عملاء (تعدد المنشآت منذ اليوم الأول). ## إلى أين بعد ذلك - [البدء السريع](/ar/docs/quickstart) يشغّل المنظومة باستخدام Docker Compose. - [البنية](/ar/docs/architecture) تشرح مسارات الطلبات والتخزين. - [الوكلاء وموجّه تشات وورك](/ar/docs/router) يشرح كيف تُوجَّه الرسالة وتُسنَد إلى المعرفة. --- # البدء السريع > شغّل chatwork والجسر وموجّه تشات وورك والموقع على خادم واحد باستخدام Docker Compose. URL: https://chatwork.io/ar/docs/quickstart Section: Start here تحتاج إلى خادم Linux عليه Docker 24+، وأربعة سجلات DNS تشير إليه (`chatwork.io` و`app.` و`chat.` و`api.` أو نطاقك الخاص)، ونقطة وصول لنموذج لغوي (LLM) متوافقة مع OpenAI. ## 1. انسخ المستودع واضبط الإعدادات ```bash git clone chatwork && cd chatwork cp infra/.env.example infra/.env ``` افتح `infra/.env` واضبط على الأقل: | المتغيّر | الغرض | |---|---| | `PLATFORM_DOMAIN` | نطاقك الجذري، مثل `chatwork.io`. يشتق Caddy منه `app.` و`chat.` و`api.`. | | `ACME_EMAIL` | بريد التواصل لدى Let's Encrypt لإصدار شهادات TLS تلقائياً. | | `POSTGRES_PASSWORD`, `REDIS_PASSWORD`, `SECRET_KEY_BASE`, `DOT_DB_PASSWORD` | أسرار قاعدة البيانات والذاكرة المؤقتة وchatwork (`openssl rand -hex 32`). | | `DOT_ADMIN_API_KEY`, `CHATWOOT_WEBHOOK_SECRET`, `DOT_WIDGET_SIGNING_KEY`, `DOT_CREDENTIALS_KEY` | أسرار الجسر؛ يجب ألا يقل طول الثلاثة الأولى عن 32 حرفاً في الإنتاج. | | `DOT_LLM_BASE_URL`, `DOT_LLM_API_KEY`, `DOT_LLM_MODEL` | مزوّد النموذج اللغوي (متوافق مع OpenAI). تستخدم التضمينات الاختيارية في موجّه تشات وورك نقطة الوصول نفسها. | | `DOT_DATABASE_URL` | `postgresql://dot_bridge:@postgres:5432/dot_bridge` — مطلوب لموجّه تشات وورك وقاعدة المعرفة المدمجة. | لا تودِع ملف `.env` في المستودع أبداً. يفشل سكربت بوابة الفحص إذا وُجد ملف منها ضمن الملفات المتتبَّعة. ## 2. شغّل المنظومة ```bash docker compose -f infra/docker-compose.yml up -d --build ``` يحصل Caddy على الشهادات، ويرحّل chatwork قاعدة بياناته عند أول إقلاع، ويبدأ الجسر عندما يصبح Postgres وRedis في حالة سليمة. ## 3. طبّق ترحيلات الجسر (migrations) وابذر الوكلاء ```bash docker compose -f infra/docker-compose.yml exec bridge python -m storage.migrate docker compose -f infra/docker-compose.yml exec bridge python -m cloudrag.seed ``` الأمر الأول ينشئ جداول الجسر، ومنها جداول موجّه تشات وورك (`012_cloudrag.sql` و`014_knowledge_builtin.sql`). الأمر الثاني يُدرج الوكلاء الستة أو يحدّثهم (upsert). وعند ضبط `CLOUDRAG_EMBEDDINGS=provider` أضف `--embed` لتوليد تضمينات مقاصد التوجيه. ## 4. أنشئ حساب chatwork وبوت الوكيل 1. افتح `https://chat.` وأنشئ الحساب الأول (super-admin). 2. من Profile → Access token: ضع الرمز في `CHATWOOT_ADMIN_API_TOKEN`؛ ودوّن معرّف الحساب لاستخدامه في `CHATWOOT_ACCOUNT_ID`. 3. من Settings → Agent Bots: أضف بوتاً يكون عنوان URL الصادر له `https:///webhooks/chatwoot?token=`؛ وضع رمزه في `CHATWOOT_BOT_TOKEN`. 4. نفّذ `docker compose -f infra/docker-compose.yml up -d bridge` ليلتقط الجسر المتغيرات الجديدة. ## 5. أنشئ أول منشأة أسرع طريقة هي صفحة التسجيل: افتح `https://app./en/signup` (أو `/ar/signup`)، وأدخل اسم الشركة واسمك وبريدك الإلكتروني ومعرّف المنشأة وكلمة مرور. طلب واحد ينشئ المنشأة ومالكها الأول وفترة تجريبية مدتها 14 يوماً، ويسجّل دخولك إلى لوحة المشغل. راجع [التسجيل وتسجيل الدخول](/ar/docs/signup) لمعرفة الأوضاع (`open`، `code`، `closed`). يستطيع المشغّلون أيضاً إنشاء منشأة بمفتاح الإدارة: ```bash curl -sS -X POST https:///api/v1/tenants/onboard \ -H "X-Admin-Key: $DOT_ADMIN_API_KEY" -H 'Content-Type: application/json' \ -d '{"slug":"acme","name_ar":"شركة أكمي","plan":"growth","channels":["web_widget"]}' ``` تتضمن الاستجابة مفتاح API الخاص بالمنشأة مرة واحدة فقط. ضمّن نافذة الدردشة في أي صفحة: ```html ``` ## 6. تحقّق ```bash curl -fsS https:///health # {"status":"ok","service":...,"version":""} curl -fsS https:///ready # {"status":"ready","checks":{"redis":"ok","database":"ok"}} curl -fsS https://chat./api # chatwork version curl -s -o /dev/null -w '%{http_code}\n' https:///api/v1/tenants # 401 without a key ``` أرسل رسالة عبر نافذة الدردشة؛ ستظهر في صندوق الوارد في chatwork، ويجيب Dot، ويظهر قرار التوجيه في `GET /api/v1/tenants/acme/cloudrag/decisions`. --- # النطاقات والتوجيه > أي اسم مضيف يخدم ماذا، وكيف تُبقي طبقة الحافة العقود العامة سليمة، وكيف تشغّل المنصة تحت نطاقك الخاص. URL: https://chatwork.io/ar/docs/domains Section: Start here نسخة واحدة من Caddy (`infra/Caddyfile`) تقف أمام المنصة كلها. هذا الفصل مقصود: يجب ألا يتمكن الموقع التسويقي من تعطيل API أبداً، ويجب ألا تتغير أبداً الروابط التي ضمّنها العملاء في صفحاتهم. | المضيف | ما يخدمه | الخدمة التي خلفه | |---|---|---| | `chatwork.io`، `www.chatwork.io` | التسويق والأسعار والوكلاء والتوثيق والمدونة والموارد تحت `/en` و`/ar`؛ و`/llms.txt` | ملفات ثابتة مبنية من `apps/web` | | `chatwork.io/api/*`، `/mcp`، `/.well-known/mcp.json`، `/webhooks/*`، `/widget.js`، `/health`، `/static/portal/*` | API العام، وخادم MCP، وWebhooks، ونافذة الدردشة | الجسر (على الأصل نفسه مع الموقع، فلا تحتاج نافذة الدردشة ولا شريط الحالة إلى CORS) | | `app.chatwork.io` | لوحة المشغل وصفحة تسجيل الدخول / التسجيل، كلٌّ منهما تحت `/ar` و`/en` (`/en/login`، `/ar/signup`، `/en`) | الجسر | | `api.chatwork.io` | API دون الموقع أمامه (للمكاملين الذين يفضّلون مضيفاً نظيفاً) | الجسر | | `chat.chatwork.io` | لوحة صندوق الوارد وWebSocket (`/cable`) | chatwork Rails | ## عقود لا تتغير يضمّن العملاء `https://chatwork.io/widget.js`؛ ويكتشف عملاء MCP العنوان `https://chatwork.io/mcp`؛ ويرسل بوت الوكيل في chatwork طلباته إلى `https://chatwork.io/webhooks/chatwoot?token=…`. تبقى هذه المسارات على النطاق الجذري دائماً. يوجّهها Caddyfile حسب بادئة المسار قبل أن يصل أي طلب إلى الموقع الثابت. مسارات البوابة القديمة على النطاق الجذري (`/saas`، `/inbox.html`) تُحوَّل إلى `app.chatwork.io` بإعادة توجيه 301. ## نطاقك الخاص اضبط `PLATFORM_DOMAIN=example.com` في `infra/.env`. يخدم Caddy النطاق `example.com` و`www.` و`app.` و`api.` و`chat.` ويطلب شهادات للخمسة كلها. اضبط `DOT_PUBLIC_BASE_URL=https://example.com` و`CHATWOOT_PUBLIC_URL=https://chat.example.com` حتى تتطابق الروابط المولَّدة (Webhook بوت الوكيل، وأصل نافذة الدردشة، وصفحة العودة من الدفع). ## خلف Cloudflare نشر الإنتاج لـ chatwork.io يقع خلف Cloudflare Worker يمرّر أسماء المضيفين نفسها إلى الخادم الأصلي عبر TLS. أبقِ وضع TLS على "Full (strict)" ومرّر `X-Forwarded-Host` وترقية WebSocket للمضيف `chat.`؛ ولا يثق الجسر بترويسات `X-Forwarded-*` إلا إذا جاءت من `UVICORN_FORWARDED_ALLOW_IPS`. ## اللغات كل صفحة عامة موجودة تحت `/en` و`/ar`. المسار الجذر على النطاق الجذري يعيد التوجيه حسب ترويسة `Accept-Language` في المتصفح (المتصفحات العربية إلى `/ar`، وغيرها إلى `/en`)؛ والمسارات القديمة بلا بادئة مثل `/docs/quickstart` تُحوَّل إلى `/en/docs/quickstart`. على `app.`، يستخدم المسار بلا بادئة قيمة `DOT_DEFAULT_LOCALE` (الافتراضي `ar`) ما لم يكن المتصفح قد حفظ اختياراً؛ و`/login` و`/signup` على النطاق الجذري يُحوَّلان إلى `app.`. --- # التسجيل وتسجيل الدخول > كيف تنشئ الشركة منشأتها، وكيف يسجّل أعضاء الفريق دخولهم، وكيف يتحكم المشغّل في من يحق له التسجيل. URL: https://chatwork.io/ar/docs/signup Section: Start here الصفحتان موجودتان على مضيف اللوحة، بالعربية والإنجليزية: `app.chatwork.io/ar/signup`، `/en/signup`، `/ar/login`، `/en/login`. ## إنشاء منشأة يطلب نموذج التسجيل اسم الشركة، واسمك، وبريد العمل الإلكتروني، ومعرّف المنشأة، وكلمة مرور، وباقة. بعدها ينفّذ طلب واحد ما يلي: 1. ينشئ المنشأة (وصندوق الوارد الخاص بها إذا كان المشغّل قد أعدّ الإنشاء التلقائي؛ وإلا توسَم المنشأة بأنها «بحاجة إلى إعداد» وتوضّح اللوحة ما يجب ربطه)؛ 2. ينشئك بصفتك أول **مالك** لها، بكلمة مرور مجزّأة بخوارزمية scrypt؛ 3. يبدأ فترة تجريبية (`DOT_SIGNUP_TRIAL_DAYS`، الافتراضي 14) على الباقة التي اخترتها — بلا بطاقة، وبلا فاتورة مدفوعة، مع ردود الذكاء الاصطناعي ضمن حصة الباقة؛ 4. يسجّل دخولك ويفتح اللوحة على قائمة التحقق من الإعداد. معرّف المنشأة من 3 إلى 40 خانة (أحرف صغيرة وأرقام وشرطات). هو ما يكتبه فريقك لتسجيل الدخول وما يحمله كود نافذة الدردشة، فاختر معرّفاً ثابتاً. يتحقق النموذج من توفره أثناء الكتابة. السعر المعروض تحت الباقة هو إجمالي الفاتورة بعد الفترة التجريبية، شاملاً ضريبة القيمة المضافة، ويحسبه الكود نفسه الذي يصدر الفاتورة. ## تسجيل الدخول يسجّل أعضاء الفريق دخولهم بمعرّف المنشأة وبريدهم الإلكتروني وكلمة المرور. إذا كان التحقق بخطوتين مفعّلاً، تطلب الصفحة بعد ذلك الرمز المكوّن من 6 أرقام (أو رمز استرداد). الجلسات محصورة في تبويب المتصفح، وتنتهي عند الخمول، وتُلغى عند تسجيل الخروج أو تغيير كلمة المرور. - **لديك دعوة؟** اختر «لدي رمز دعوة». ينشئ المالك الدعوة من «الفريق والدخول» ويسلّمك الرمز؛ يعمل مرة واحدة ولمدة 7 أيام. - **نسيت كلمة المرور؟** يصدر المالك رمز استعادة من الصفحة نفسها؛ يعمل مرة واحدة ولمدة ساعة واحدة، وينهي كل جلساتك. لا توجد خطوة بريد إلكتروني لأن المنصة لا ترسل بريداً إلكترونياً حتى الآن. - **المشغّلون** الذين لديهم مفتاح إدارة أو مفتاح API للمنشأة يستخدمون «الدخول بمفتاح API». ## من يحق له التسجيل | `DOT_SIGNUP_MODE` | السلوك | |---|---| | `open` (الافتراضي) | يستطيع أي شخص إنشاء منشأة. الحد 5 عمليات تسجيل لكل عنوان IP في الساعة و`DOT_SIGNUP_DAILY_CAP` (الافتراضي 50) في اليوم. | | `code` | يطلب النموذج رمز تسجيل (`DOT_SIGNUP_CODE`). استخدمه للإصدارات التجريبية الخاصة ولتسجيل المنشآت عبر الموزّعين. | | `closed` | يختفي تبويب التسجيل؛ والمشغّلون وحدهم ينشئون المنشآت (`POST /api/v1/tenants/onboard`). | لا يُتحقق من عناوين البريد الإلكتروني (لا يوجد مزوّد بريد حتى الآن). على مضيف عام، يُفضَّل وضع `code` إلى أن يتوفر ذلك. --- # البنية > الخدمات، ومسارات الطلبات، والتخزين، وضمانات التسليم التي يقدّمها الجسر. URL: https://chatwork.io/ar/docs/architecture Section: Platform ## الخدمات ``` chatwork.io ──► Caddy ──► site (static) apps/web ├──► bridge (FastAPI, :8090) apps/bridge └──► chatwoot-rails (:3000) + chatwoot-sidekiq │ postgres (pgvector/pg16) ── databases: chatwoot, dot_bridge redis 7 ── chatwork jobs + bridge counters, locks, control state ``` الجسر عملية واحدة تكتشف الموجّهات (routers) تلقائياً (`routes/*.py`)، وفيها عاملان في الخلفية (مستطلِع X ومفرِّغ صندوق الصادر)، ولا تستخدم ORM: ترحيلات SQL (migrations) مكتوبة يدوياً في `migrations/NNN_*.sql`، يطبّقها `python -m storage.migrate` تحت قفل استشاري (advisory lock). ## مسار Webhook (رسالة عميل واحدة) 1. **المصادقة والشكل.** لا يوقّع محرك صندوق الوارد (chatwork) طلبات Webhook، لذلك يحمل عنوان URL لبوت الوكيل سراً. تُتجاهَل الأحداث غير `message_created` والملاحظات الخاصة والمحتوى الفارغ. 2. **إزالة التكرار ثم التخزين.** `SET NX` على `(account, conversation, message)`، ثم يُكتب الحدث في صندوق وارد الأحداث بالحالة `received` قبل أي شيء آخر. 3. **التوجيه إلى منشأة.** يجب أن يطابق الزوج `(account, inbox)` بالضبط مجموعة المطابقة لمنشأة نشطة واحدة؛ وإذا لم تطابق أي منشأة أو طابقت منشأتان، يُعزل الحدث. لا رد ولا استهلاك. 4. **الحواجز.** يُتخطّى صدى رسائل البوت نفسه، ومحادثات `/inbound` المنعكسة، والمحادثات التي يملكها موظف بالفعل. 5. **مسار المعالجة.** `can_ai_reply → begin_ai_reply (generation) → usage.reserve → LLM → may_dispatch(generation) → deliver`. داخل خطوة LLM يوجّه موجّه تشات وورك الرسالة إلى وكيل ويسندها إلى المعرفة ([التفاصيل](/ar/docs/router)). 6. **التسليم.** يُنشر الرد في صندوق الوارد برمز البوت الخاص بالمنشأة؛ وفي محادثات X يُضاف إلى صندوق الصادر (outbox)، الذي يعيد التحقق من الملكية بعد مهلة التأخير البشري وقبل الإرسال مباشرة. 7. **التحويل إلى موظف.** كلمة مفتاحية أو وسم من النموذج أو سياسة وكيل تفتح تذكرة المحادثة (أو تعيد استخدامها)، وتنشر ملاحظة خاصة، وتضبط المحادثة على `open`. 8. **التسوية.** يُسوّى الاستهلاك بأعداد الرموز اللغوية (tokens) الفعلية؛ وينتهي الحدث بالحالة `processed` أو `failed(error)`، ويستطيع مسؤول إعادة محاولته. ## التخزين - **PostgreSQL** هو المرجع المعتمد للمنشآت، ودفتر الاستهلاك، والفواتير، والمدفوعات، والاشتراكات، والاتصالات (أسرار مشفّرة)، والأعضاء والجلسات، والتذاكر، والتجارة، والأحداث، والتدقيق، والعزل، وموجّه تشات وورك (الوكلاء، والمقاصد، والمصادر، والمقاطع، وسجل التوجيه). - **Redis** يحفظ حدود المعدّل، وحجوزات الاستهلاك، والتحكم في المحادثة (المالك + الجيل)، والذاكرة المؤقتة لأدوات MCP، وإزالة التكرار والمؤشر (cursor) الخاصين بـ X، والجلسات قصيرة العمر، والأقفال (`SET NX PX`، مع تحرير يتحقق من الرمز). - **صندوق الوارد** (قاعدة بيانات chatwork) يحفظ المحادثات والرسائل وجهات الاتصال والتعيين والتصنيفات. القيمة `DOT_STORAGE_BACKEND=redis` (الافتراضي التاريخي) تُبقي سجلات الجسر في Redis بمسارات الكود نفسها؛ والقيمة `postgres` تجعل PostgreSQL المرجع المعتمد مع نسخة مطابقة في Redis. يستخدم موجّه تشات وورك دائماً PostgreSQL عند ضبط `DOT_DATABASE_URL`، بصرف النظر عن هذا الخيار. ## الضمانات - **مرة واحدة على الأقل.** كل Webhook مقبول يُحفظ قبل المعالجة؛ وكل إرسال إلى X يمر عبر صندوق الصادر بتأخير متصاعد (60 ثانية ← 5 دقائق ← 30 دقيقة ← ساعتان) وحالة ميتة بعد `outbox_max_attempts`. - **ردود الذكاء الاصطناعي المتأخرة لا تفوز أبداً.** يُعاد التحقق من جيل التحكم مباشرة قبل كل إرسال؛ وإذا استلم موظف المحادثة في الأثناء، يُسقَط رد الذكاء الاصطناعي. - **لا نص يراه العميل عند أخطاء المزوّد.** تعطّل النموذج اللغوي ينتج ملاحظة خاصة وتحويلاً إلى موظف، ولا ينتج أبداً إجابة مختلقة. - **الحصة قبل التكلفة.** يُحجز الاستهلاك قبل استدعاء النموذج ويُحرَّر عند الفشل. --- # الوكلاء وموجّه تشات وورك > كيف تُوجَّه كل رسالة إلى وكيل Dot واحد، وتُسنَد إلى قاعدة المعرفة المدمجة مع الاستشهاد بمصادرها، وتُسجَّل، وتصبح قابلة للتفسير. URL: https://chatwork.io/ar/docs/router Section: Platform موجّه تشات وورك هو طبقة توجيه الوكلاء والمعرفة المدمجة في الجسر. ليس خدمة خارجية مستقلة: هو حزمة Python (`apps/bridge/cloudrag/`) فوق PostgreSQL، تُستدعى داخل خطوة LLM في مسار المعالجة. هو إلزامي بمعنى أن كل رد من الذكاء الاصطناعي يمر به؛ وهو متين بمعنى أن أي عطل في المخزن أو في مزوّد التضمينات الاختياري لا يستطيع منع الرد. ## سجل الوكلاء هو المنتج كل وكيل ملف واحد في `agents/registry/`. يقرأ الملف نفسه كلٌّ من: - الجسر عند بدء التشغيل (مع التحقق من صحته؛ الملف المعطوب يمنع تشغيل الموجّه)، - `python -m cloudrag.seed`، الذي يُدرج الوكلاء أو يحدّثهم في `cloudrag_agents` (ومع `--embed` يولّد تضمينات مقاصدهم عند تفعيل مزوّد التضمينات)، - هذا الموقع، الذي يعرض منه [/agents](/ar/agents) وساحة تجربة التوجيه، - عيّنات اختبار المطابقة (`agents/fixtures/routing.json`) التي يجب أن يستوفيها موجّه Python ونظيره المكتوب بـ TypeScript معاً. الحقول المهمة للتوجيه: `routing.priority` (لحسم التعادل)، و`routing.keywords` مع أوزانها، و`routing.channel_boost`، و`routing.min_score`، و`routing.intents` (جمل للطبقة الدلالية الاختيارية)، و`routing.always_handoff`، و`default: true` على وكيل واحد فقط. ## طبقتان ودرجة واحدة 1. **الطبقة المعجمية (تعمل دائماً).** يُوحَّد النص والكلمات المفتاحية (أحرف صغيرة، وحذف التشكيل والتطويل في العربية، `أإآ→ا`، `ى→ي`، `ة→ه`، `ؤ→و`، `ئ→ي`). الكلمات المفتاحية العربية تُطابَق كسلاسل جزئية؛ واللاتينية على حدود الكلمات. `lexical = min(1, Σ weight)` مع إضافة تعزيز القناة عند وجود تطابق. 2. **الطبقة الدلالية الاختيارية (`CLOUDRAG_EMBEDDINGS=provider`).** تُحوَّل الرسالة إلى تضمين مرة واحدة (`CLOUDRAG_EMBEDDING_MODEL`، 1536 بُعداً). درجة كل وكيل هي أعلى تشابه جيب تمام (cosine similarity) مع مقاصده المضمَّنة. `final = 0.55 × semantic + 0.45 × lexical`. يفوز أفضل وكيل تتجاوز درجته قيمة `min_score` الخاصة به؛ وعند التعادل يفوز صاحب رقم الأولوية الأدنى؛ وإلا يستلم الوكيل الافتراضي (Concierge) الرسالة. تستطيع المنشأة تثبيت وكيل (`cloudrag_pinned_agent` في سجل المنشأة) أو تعطيل وكيل (`PATCH /cloudrag/agents/{slug}`)؛ ولا يمكن تعطيل الوكيل الافتراضي. ## قاعدة المعرفة المدمجة والإسناد تعمل قاعدة المعرفة المدمجة افتراضياً داخل التطبيق (`CLOUDRAG_EMBEDDINGS=off`) دون أي استدعاء خارجي: تُحفظ المقاطع نصياً في PostgreSQL وتُرتَّب بمطابقة المصطلحات الموحَّدة للوكلاء الذين لديهم `knowledge.retrieval: true`، وتُلحَق بتعليمات النظام في صورة فقرات مرقّمة ليستشهد بها النموذج بالصيغة `[n]` ويصرّح بما لا يعرفه عند عدم وجود تطابق. وعند ضبط `CLOUDRAG_EMBEDDINGS=provider` يُضاف الاسترجاع المتجهي الهجين فوق `pgvector`. تنتقل الاستشهادات مع الرد (`routing.citations` في استجابة API). المصادر نص ملصوق أو صفحات https عامة (`POST /api/v1/tenants/{slug}/cloudrag/sources`). تمر الروابط عبر حاجز SSRF نفسه المطبّق على خوادم MCP الخاصة بالمنشآت؛ وتُختزل الصفحات إلى نص نثري، ثم تُقسَّم إلى مقاطع (نحو 800 حرف، مع مراعاة حدود الفقرات، وتداخل 120 حرفاً) وتُحفظ في قاعدة البيانات. المحتوى المتطابق للمنشأة نفسها لا يُفهرَس مرتين (`deduplicated: true`)؛ والمحتوى الجديد يستبدل كل مقاطع ذلك المصدر في معاملة واحدة. ## التحويل إلى موظف بحكم السياسة لدى Guardian الخاصية `always_handoff: true`. عند اختياره ينتهي الرد بتحويل إلى موظف حتى لو نسي النموذج الوسم: يفتح مسار المعالجة التذكرة، وينشر الملاحظة الخاصة مع اسم الوكيل، ويضبط المحادثة على `open`. التحويل بالكلمات المفتاحية («أريد موظفاً») ما زال يُنفَّذ قبل أي توجيه، تماماً كما كان. ## قابلية التفسير يُسجَّل كل قرار في `cloudrag_routing_log` دون نص الرسالة (تجزئتها فقط): الوكيل، والسبب (`keywords`، `semantic`، `default`، `pinned`)، والدرجة، والطبقات المستخدمة، وأبرز المرشحين مع كلماتهم المفتاحية المطابقة، وزمن الاستجابة. يعيد `GET /api/v1/tenants/{slug}/cloudrag/decisions` السجل الأخير وتوزيعاً لآخر 30 يوماً حسب الوكيل؛ ويعرض `POST …/cloudrag/route` معاينة للقرار دون استدعاء النموذج. ## التراجع التدريجي، بالترتيب | الحالة | السلوك | |---|---| | لا يوجد `DOT_DATABASE_URL` | الطبقة المعجمية على ملفات سجل الوكلاء؛ بلا معرفة؛ `source: registry_files` في كل أثر تتبّع. | | قاعدة البيانات تعمل والوكلاء لم يُبذروا | كما سبق إلى أن يُنفَّذ `python -m cloudrag.seed`. | | `CLOUDRAG_EMBEDDINGS=off` (الافتراضي) | التوجيه المعجمي وقاعدة المعرفة المدمجة يعملان بالكامل داخل PostgreSQL دون أي اتصال خارجي. | | مزوّد التضمينات متوقف (عند تفعيله) | يستمر التوجيه والاسترجاع النصي المدمج؛ وتُحفظ المصادر مفهرسة نصياً بدل فشلها. | | تعذّرت الكتابة في سجل التوجيه | يستمر الرد؛ ويُسجَّل تحذير. | لا شيء في هذه القائمة ينتج خطأً للعميل. ## في لوحة المشغل شاشة «الوكلاء والمعرفة» تعرض الوكلاء الستة مع مفتاح تفعيل لكل منشأة، وتعاين قرار التوجيه لأي رسالة، وتدير مصادر المعرفة، وتعرض القرارات الأخيرة. تعرض النظرة العامة توزيع القرارات حسب الوكيل لآخر 30 يوماً. تُخزَّن صفوف الوكلاء مؤقتاً في كل عملية لمدة 30 ثانية ويُبطَل التخزين عند تبديل المفتاح، فيكلّف التوجيه قراءة واحدة من قاعدة البيانات لكل منشأة كل نصف دقيقة، لا قراءة لكل رسالة. --- # ما الذي يعمل اليوم > جدول القدرات، منقول من ملف الحالة الهندسي مع أدلته. لا يجوز للتسويق أن يتجاوزه. URL: https://chatwork.io/ar/docs/channels Section: Platform ## ماذا تعني كل حالة الحالات: **يعمل** = كود واختبارات وجُرّب ببيانات اعتماد حقيقية. **جاهز برمجياً** = كود واختبارات، بانتظار بيانات اعتماد أو موافقة من المزوّد. **اختباري فقط** = مثبت أمام مزوّدين محاكَين، وليس بعد أمام المزوّد الحقيقي. ## القدرات | القدرة | الحالة | ملاحظات | |---|---|---| | رسائل X الخاصة والإشارات ← صندوق وارد تشات وورك ← رد الذكاء الاصطناعي ← X | **يعمل** | تطبيق X واحد حالياً؛ بيانات اعتماد X لكل منشأة غير مبنية. | | صندوق وارد مستضاف ذاتياً (محرك chatwork) | **يعمل** | مثبّت على `v4.19.1`؛ الترقية تغيير مستقل ومقصود. | | المصادقة: مفتاح الإدارة، مفاتيح المنشآت المجزّأة، رمز bearer لـ MCP، سر Webhook، جلسات نافذة الدردشة، حدود المعدّل | **يعمل** | | | توجيه المنشآت بمطابقة تامة للزوج `(account, inbox)`؛ الملتبس أو المجهول ← العزل | **يعمل** | | | إزالة تكرار Webhook، حاجز صدى البوت، صندوق وارد الأحداث مع إعادة المحاولة من المسؤول | **يعمل** | إعادة المحاولة تعيد تشغيل المعالج كاملاً؛ قد تتكرر الآثار الجانبية السابقة لنقطة الفشل. | | صندوق الصادر (outbox) لـ X (مرة واحدة على الأقل، تأخير متصاعد، رسائل ميتة) | **يعمل (اختبارات)** | لم يُجرَّب بعد مع X الحقيقي. | | نافذة دردشة الويب بجلسات زوار موقّعة، و`/inbound` إلى صندوق وارد تشات وورك الحقيقي | **يعمل** | | | التحكم بين الذكاء الاصطناعي والموظف بالأجيال؛ تحرير صريح | **يعمل** | | | أدوات MCP لكل منشأة (الاكتشاف، ترويسة المصادقة، التخزين المؤقت، حاجز SSRF) وخادم MCP | **يعمل** | | | موجّه تشات وورك، الطبقة المعجمية | **يعمل (اختبارات)** | عيّنات اختبار المطابقة مشتركة مع الموقع. | | موجّه تشات وورك: قاعدة المعرفة المدمجة، سجل التوجيه، والطبقة الدلالية الاختيارية | **يعمل (اختبارات) / جاهز برمجياً** | قاعدة المعرفة المدمجة تعمل على `DOT_DATABASE_URL` دون مزوّد خارجي (`CLOUDRAG_EMBEDDINGS=off`)؛ الطبقة الدلالية الاختيارية (`provider`) تحتاج إلى نقطة وصول للتضمينات. | | حصص الاستهلاك، الاشتراكات، الفواتير بالهللة | **يعمل** | تبقى الفواتير مسودة إلى أن يُتحقق من الدفع. | | API الأسعار العام وحاسبة الباقات | **يعمل (اختبارات)** | الحساب نفسه المستخدم في الفواتير؛ ملف كتالوج واحد للجسر والموقع. | | مدفوعات Moyasar | **اختباري فقط** | مزوّد محاكى؛ المفاتيح الحقيقية غير مضبوطة. | | الفوترة الإلكترونية ZATCA | **بيانات رمز QR للمرحلة الأولى فقط** | ليس ادعاء امتثال. | | WhatsApp Cloud API، Telegram، البريد الإلكتروني (صناديق وارد أصلية) | **جاهز برمجياً** | تُنشأ عبر API مع ربط بوت الوكيل بها؛ تحتاج إلى بيانات اعتماد المنشأة. | | Instagram، Facebook | **جاهز برمجياً (تسجيل فقط)** | تُربط من لوحة صندوق الوارد (`chat.`) ويسجّلها الجسر؛ تحتاج إلى مراجعة تطبيق Meta. | | التجارة عبر Salla وZid، أداة `lookup_order` | **اختباري فقط** | OAuth وWebhooks وذاكرة مؤقتة للطلبات خالية من البيانات الشخصية، مبنية أمام محاكيات. | | تسجيل دخول الأشخاص، الجلسات، MFA، RBAC، إعادة تعيين كلمة المرور | **يعمل (اختبارات)** | الدعوات ورموز الاستعادة تُسلَّم يدوياً (لا يوجد مزوّد بريد حتى الآن). | | التسجيل الذاتي (منشأة + مالك + فترة تجريبية) وصفحة تسجيل الدخول | **يعمل (اختبارات)** | لا تحقق من البريد الإلكتروني حتى الآن؛ الأوضاع `open`، `code`، `closed`؛ بحد معدّل وسقف يومي. | | لوحة المشغل بالعربية والإنجليزية، تخطيط الجوال، النظرة العامة، شاشة الوكلاء والمعرفة | **يعمل (فُحص في المتصفح محلياً)** | تغطية الإنجليزية يفرضها اختبار؛ النص الذي يعيده الجسر نفسه بالعربية يُترجم من قائمة ثابتة. | | نقطة الجاهزية، معرّفات الطلبات | **يعمل (اختبارات)** | `GET /ready`، `X-Request-ID`. | | تذاكر مع مهلة الخدمة (SLA)، تذكرة مفتوحة واحدة لكل محادثة، التحويل إلى موظف ← تذكرة | **يعمل (اختبارات)** | التجاوز يُحسب عند القراءة؛ لا مجدوِل ولا إشعارات. | | جهات الاتصال (عرض CRM للقراءة فقط) | **اختباري فقط** | | | كتالوج الخدمات، الأتمتة | **غير مبني** | | ## مصدر هذا الجدول المصدر: `docs/STATUS.md` في المستودع، يُحدَّث في التغيير نفسه مع الكود. --- # التحويل إلى موظف والتذاكر > إشارات التحويل الثلاث، وما يفعله التحويل، وكيف تنشأ عنه التذاكر ومهل الخدمة (SLA). URL: https://chatwork.io/ar/docs/handoff Section: Platform حالة المحادثة في صندوق الوارد هي نموذج الملكية: `pending` تعني أن البوت يملك المحادثة، و`open` تعني أن موظفاً يملكها. لا يرد الجسر أبداً في محادثة `open` لها موظف معيَّن، ورسالة العميل الجديدة لا تعيد الملكية إلى الذكاء الاصطناعي أبداً؛ التحرير يكون صريحاً. ## الإشارات | الإشارة | متى | الثقة | |---|---|---| | **كلمة مفتاحية** | تحتوي الرسالة على إحدى كلمات التحويل المفتاحية للمنشأة (الافتراضية: موظف، بشري، شكوى، مدير، تحويل، دعم فني، مشكلة مالية). تُفحص قبل أي استدعاء للنموذج. | 0.95 | | **وسم النموذج** | ينهي النموذج رده بالوسم `[HANDOFF]`. يُحذف الوسم من النص الذي يراه العميل. | 0.7 | | **سياسة الوكيل** | وجّه موجّه تشات وورك الرسالة إلى وكيل لديه `always_handoff: true` (Guardian). | 0.9 | أخطاء المزوّد واستنفاد الحصص تؤدي أيضاً إلى التحويل إلى موظف، مع ملاحظة خاصة ودون نص يراه العميل. ## ما الذي يفعله التحويل 1. يضبط مالك المحادثة على `human` ويرفع جيل التحكم، فيُسقَط أي رد من الذكاء الاصطناعي ما زال قيد التنفيذ قبل إرساله. 2. ينشر ملاحظة خاصة فيها السبب والقناة وملخص قصير. 3. يحوّل المحادثة إلى `open` في صندوق الوارد. 4. يفتح تذكرة المحادثة، أو يعيد استخدام التذكرة المفتوحة. لكل محادثة تذكرة واحدة على الأكثر بالحالة `open|pending` (يفرض ذلك فهرس فريد جزئي). ## التذاكر ومهلة الخدمة (SLA) تحمل التذكرة رقماً خاصاً بكل منشأة، وأولوية (`low`، `normal`، `high`، `urgent`)، وحالة (`open`، `pending`، `resolved`، `closed`)، وموظفاً معيَّناً يجب أن يكون عضواً في المنشأة، وتعليقات داخلية. أهداف مهلة الخدمة هي `ticket_sla_first_response_minutes` و`ticket_sla_resolution_minutes` مضروبة بمعامل حسب الأولوية (urgent ×0.25، high ×0.5، normal ×1، low ×2). أول رد من موظف عبر صندوق الوارد يسجّل `first_response_at`؛ والحل أو الإغلاق يسجّل `resolved_at`. يُحسب التجاوز عند قراءة التذكرة ولا يُخزَّن أبداً، ولذلك يعيد تغيير إعدادات مهلة الخدمة تقييم كل شيء. ## إعادة المحادثة `POST /api/v1/tenants/{slug}/control/{conversation_id} {"action":"release"}` يعيد الملكية إلى الذكاء الاصطناعي. أما `claim` و`pause` فموجودان لزرَّي الاستلام والإيقاف المؤقت في البوابة. --- # محرك صندوق الوارد > صندوق وارد تشات وورك يعمل على محرك chatwork. كيف يتخاطب الجسر معه، وسياسة الإصدارات. URL: https://chatwork.io/ar/docs/inbox-engine Section: Platform صندوق وارد تشات وورك هو مخزن المحادثات الوحيد، ومحركه chatwork المستضاف على خادمك. تستخدم بقية هذه الصفحة اسم المحرك نفسه، لأنه ما تثبّته وتضبطه وترقّيه. يتخاطب الجسر معه بطريقتين فقط: REST application API (برمز الإدارة، أو برمز بوت الوكيل الخاص بالمنشأة) وWebhook بوت الوكيل. لا يلمس قاعدة بيانات chatwork أبداً. ## سياسة الإصدارات الصورة مثبّتة (`chatwoot/chatwoot:v4.19.1`) في `infra/docker-compose.yml`. الترقية تغيير مستقل: خذ نسخة احتياطية، اسحب الوسم الجديد، شغّل Rails وSidekiq، افحص `/api`، ثم شغّل بوابة فحص المنصة. لا يتغير شيء آخر في ذلك التغيير. لا يتغير `VERSION` الخاص بالمنصة عند تغيّر إصدار chatwork؛ ومصفوفة الإصدارات في [سجل التغييرات](/ar/docs/changelog) تسجّل الاثنين. ## الحسابات وصناديق الوارد - خارج الإنتاج، ولمنشأة المنصة نفسها، يُستخدم `CHATWOOT_ACCOUNT_ID` المشترك. - في الإنتاج تحصل كل منشأة أخرى على حساب chatwork خاص بها عبر Platform API (`CHATWOOT_PLATFORM_TOKEN`)، مع إضافة مستخدم الإدارة التابع للجسر بصلاحية مسؤول. - مجموعة المطابقة للمنشأة هي زوجها `(account, inbox)` الخاص، إضافةً إلى كل صندوق وارد قابل للتوجيه تابع لأحد اتصالاتها. لا يجوز أن تحمل منشأتان الزوج نفسه؛ يرفضه المخزن ويعزله التوجيه. ## بوت الوكيل بوت وكيل واحد لكل حساب، `outgoing_url = {DOT_PUBLIC_BASE_URL}/webhooks/chatwoot?token=`. في الحساب الخاص بالمنشأة يُخزَّن رمز البوت مشفّراً بـ Fernet في سجل المنشأة، فتظهر الردود باسم البوت؛ وبدونه يُستخدم رمز الإدارة ويُتعرَّف على الصدى بعلامة قصيرة العمر. ## القنوات الأصلية WhatsApp Cloud وTelegram والبريد الإلكتروني صناديق وارد أصلية في chatwork تُنشأ عبر API (`POST /api/v1/accounts/{account}/inboxes`) مع ربط البوت بها؛ أما Instagram وFacebook فيُربطان من واجهة chatwork ثم يُسجَّلان لدى الجسر. يتولى chatwork التسليم إلى المزوّد ويبلّغ عن حالة التسليم. تشغيل موصّل مخصص لقناة يدعمها chatwork أصلاً ممنوع بحكم التصميم. --- # نافذة الدردشة للويب > وسم script واحد، وجلسات زوار موقّعة، وكل زائر في صندوق الوارد. URL: https://chatwork.io/ar/docs/widget Section: Platform ```html ``` يقدّم الجسر نافذة الدردشة؛ وتحدّد السمة `data-tenant` المنشأة. عند التحميل تطلب النافذة جلسة زائر موقّعة (`POST /api/v1/tenants/{slug}/widget/session`، مع حد معدّل لكل عنوان IP ولكل معرّف منشأة)، وتخزّنها مؤقتًا في `localStorage`، وترسلها رمز bearer مع كل رسالة. ## ماذا يحدث للرسالة يشغّل `POST /api/v1/tenants/{slug}/inbound` مسار المعالجة نفسه الذي تمر به كل قناة أخرى: فحص التحكم، ثم حجز الحصة، ثم موجّه تشات وورك، ثم استدعاء النموذج، ثم التسليم. تُنشأ المحادثة في صندوق وارد تشات وورك الخاص بالمنشأة أو تُضاف الرسالة إليها (ينتظر الجسر اكتمال العملية ولا يرسلها دون متابعة)؛ وإذا تعذّر الوصول إلى صندوق الوارد يصل الرد إلى الزائر مع ذلك، ويُخزَّن حدث `inbound_mirror` فاشل لإعادة تنفيذه. تتضمن الاستجابة `agent` و`routing` (القرار والمرشحون والاستشهادات)، ويمكنك استخدامهما لعرض «أجاب Dot Orders» في واجهتك. ## العقود - يعيد `GET /api/v1/tenants/{slug}/public` اسم الشركة ومعرّف صندوق الوارد، ولا يعيد المفاتيح أو الفواتير أبدًا. - رمز نافذة الدردشة صالح فقط لمعرّف منشأته ومعرّف زائره وللقيمة `channel_type = web_widget`. - `window.DiamondDotWidget.{open, close, setTenant}` ومفتاحا `localStorage`، وهما `diamond_dot_visitor_id` و`diamond_dot_widget_session`، معرّفات مجمّدة (تعتمد عليها صفحات العملاء). --- # خادم MCP والأدوات > الجسر بوصفه خادم MCP لأدواتك، وخوادم MCP الخاصة بالمنشآت بوصفها أدوات لـ Dot. URL: https://chatwork.io/ar/docs/mcp Section: Platform ## الجسر بوصفه خادم MCP الاكتشاف عام: يعيد `GET https://chatwork.io/mcp` أو `/.well-known/mcp.json` معلومات الخادم وبيان الأدوات. أما الاستدعاءات (`POST /mcp`، عبر streamable HTTP وبصيغة JSON-RPC 2.0) فتحتاج إلى مفتاح bearer. | الأداة | مفتاح المنشأة | مفتاح المشرف | |---|---|---| | `list_chatwoot_conversations` | صندوق الوارد الخاص بها | أي منشأة (`slug` مطلوب) | | `get_conversation_messages` | صندوق الوارد الخاص بها | أي منشأة (`slug` مطلوب) | | `list_saas_tenants` | المنشأة نفسها | الكل | | `send_reply_to_conversation` | — | نعم (ترسل إلى العميل في محادثات X) | | `toggle_conversation_status` | — | نعم | | `ask_dot_wdeftksa` | — | نعم | الرفض على مستوى الأداة هو خطأ JSON-RPC `-32001 "unauthorized"`؛ والوسائط غير الصحيحة تعيد `-32602`. أسماء الأدوات عقد عام؛ وإعادة تسمية أي منها تعطّل عملاء MCP. ## خوادم MCP الخاصة بالمنشآت بوصفها أدوات لـ Dot يمكن للمنشأة ضبط `mcp_url` (https، بعنوان عام، مع حماية من SSRF) وترويسة مصادقة. ينفّذ الجسر `initialize → tools/list`، ويخزّن الأدوات مؤقتًا لمدة خمس دقائق، ويمرّرها إلى النموذج بوصفها دوال؛ ويُنفَّذ كل `tools/call` على خادم المنشأة نفسها، معزولًا لكل منشأة. ويقلّص `enabled_tools` القائمة. تُضاف الأدوات المدمجة بحسب حالة المنشأة: لا تظهر `lookup_order` إلا عند وجود متجر Salla أو Zid مرتبط ونشط، ولا تجيب إلا عن جهة الاتصال الموثَّقة. تسرد تعريفات الوكلاء الأدوات المدمجة التي تعتمد عليها؛ وتبقى أدوات MCP الخاصة بالمنشأة متاحة لكل وكيل. --- # الفوترة والباقات > الباقات والحصص والفواتير بالهللة والاشتراكات ومعنى «مدفوعة». URL: https://chatwork.io/ar/docs/billing Section: Platform ## الباقات | الباقة | شهريًا | سنويًا | ردود الذكاء الاصطناعي / شهر | حصة الرموز (tokens) | |---|---|---|---|---| | Starter | 299 ريال سعودي | 2,990 ريال سعودي | 1,500 | 300 ألف | | Growth | 799 ريال سعودي | 7,990 ريال سعودي | 5,000 | 1 مليون | | Enterprise | 1,999 ريال سعودي | 19,990 ريال سعودي | 50,000 | 10 ملايين | الكتالوج ملف واحد هو `pricing/catalog.json`. يحمّله الجسر للفواتير والحصص، ويقرؤه الموقع وقت البناء، ويستبدل المشغّلون قيم حقوله وقت التشغيل عبر `DOT_PLANS_JSON`. ## عروض الأسعار والحاسبة يعيد `GET /api/v1/pricing` كل باقة مع عرض سعر محسوب لكل فترة: المجموع قبل الضريبة، وضريبة القيمة المضافة 15 % مقرّبة إلى أقرب هللة (النصف يُقرَّب إلى الأعلى)، والإجمالي، والمعادل الشهري للسعر السنوي، والتوفير السنوي، وتكلفة كل 1,000 رد من ردود الذكاء الاصطناعي. والإجمالي يساوي، بحكم التصميم وبالاختبار، قيمة `total_halalas` في الفاتورة التي تصدرها عملية الدفع، لأن كليهما يستخدم الدوال نفسها. يجيب `GET /api/v1/pricing/quote?replies=3200&interval=year` عن السؤال الذي يطرحه المشترون فعلًا: لهذا العدد من ردود الذكاء الاصطناعي شهريًا، أي باقة تناسب وكم تكلّف كل باقة؟ فوق أكبر حصة يكون الجواب `custom_required`؛ فالمنتج ليس له سعر للاستهلاك الزائد ولا يختلق سعرًا. تجري [صفحة الأسعار](/ar/pricing) الحساب نفسه في المتصفح (بيانات الاختبار المشتركة تُبقي التنفيذين متطابقين) وتحدّث أرقامها من واجهة API، فيظهر تعديل المشغّل دون إعادة بناء. ## الحصص يحجز كل رد من ردود الذكاء الاصطناعي وحدة واحدة قبل استدعاء النموذج، ثم يُسوّى بعد ذلك بالاستهلاك الفعلي للرموز (tokens)؛ وإذا فشل المزوّد يُلغى الحجز. عند تجاوز الحصة تجيب مسارات API بـ `429 quota_exceeded`؛ أما الـ Webhook فلا يرسل شيئًا إلى العميل، ويضيف ملاحظة خاصة، ويحوّل المحادثة إلى موظف. لا يستهلك الحصة إلا اشتراك حالته `active` أو `trial` سارية. ## الأموال المبالغ أعداد صحيحة بالهللة؛ وضريبة القيمة المضافة 15 %، مقرّبة إلى أقرب هللة (النصف يُقرَّب إلى الأعلى)؛ وحقول `*_sar` للعرض فقط. معرّفات الفواتير على الصيغة `INV-YYYYMM-XXXXXXXX`. تبقى الفاتورة `draft` إلى أن تُضبط الحقول الضريبية للبائع، ثم تصبح `issued`؛ ولا تصبح `paid` إلا عبر سجل دفع: إما دفعة Moyasar يُعاد جلبها من جهة الخادم، وإما تحويل بنكي يؤكده مشرف مع رقم مرجعي. تغيير الباقة لا يبدّل الباقة أو الحصة قبل التفعيل أبدًا. ZATCA: تحمل الفواتير بيانات QR بصيغة TLV للمرحلة الأولى (الوسوم 1–5). هذا ليس ادعاء امتثال؛ والانضمام إلى المرحلة الثانية مهمة تقع على المالك. --- # لوحة المشغل > جولة في اللوحة التي يعمل فيها فريقك — نظرة عامة، صندوق الوارد، التذاكر، الوكلاء والمعرفة، الفريق، الإعدادات. URL: https://chatwork.io/ar/docs/dashboard Section: Platform اللوحة على `app.chatwork.io/en` (أو `/ar`). تتبع لغة الرابط؛ وقائمة الحساب أسفل الشريط الجانبي تبدّل اللغة والمظهر. كل ما تعرضه يأتي من نقطة نهاية حقيقية؛ والمصدر غير المتاح يظهر شرحًا، لا رقمًا نموذجيًا أبدًا. ## نظرة عامة العرض الأول لأي منشأة جديدة، وبعد ذلك على بُعد نقرة واحدة. - **عدّادات المحادثات** لمجموعة صناديق الوارد في المنشأة: الإجمالي، بانتظارك (يتولاها موظف)، لدى البوت، محلولة. - **التذاكر**: التذاكر المفتوحة وعدد ما تجاوز منها مهلة الخدمة (SLA). - **الاستخدام والاشتراك**: ردود الذكاء الاصطناعي المستخدمة مقابل الحصة الشهرية، والباقة، وحالة الاشتراك، ونهاية الفترة. الفترة التجريبية تعرض الأيام المتبقية؛ والاشتراك غير النشط يذكر بوضوح أن الوكلاء لا يردّون. - **توجيه الوكلاء**: توزيع قرارات التوجيه على الوكلاء خلال 30 يومًا (يحتاج إلى قاعدة بيانات موجّه تشات وورك). - **قائمة الإعداد**: ربط صندوق الوارد، واستقبال أول محادثة، وإضافة مصدر معرفة، ودعوة الفريق، وتفعيل الاشتراك. يُتحقق من كل بند من الحالة الفعلية، ويرتبط بالمكان الذي يعالجه. - **القنوات**: حالة كل اتصال قناة. ## صندوق الوارد ثلاثة أقسام: قائمة المحادثات (مقسّمة إلى صفحات من الخادم، مع تبويبات للحالة وبحث)، والمحادثة، وتفاصيل العميل مع الملكية والوسوم والتذاكر. تمر الردود والملاحظات الداخلية عبر صندوق وارد تشات وورك. «استلام» يوقف الذكاء الاصطناعي في تلك المحادثة؛ و«استئناف الذكاء الاصطناعي» يعيدها إليه. يمكن لمحرّر الرسائل أن يطلب ردًّا من الوكيل الذي وُجّهت إليه المحادثة، ويُحتسب ذلك من الحصة. على الهاتف تكون القائمة والمحادثة شاشتين منفصلتين، وينزلق الشريط الجانبي إلى الداخل من زر القائمة. ## التذاكر كل تحويل إلى موظف يفتح تذكرة واحدة لكل محادثة، مع عدّاد لمهلة الخدمة (SLA) يتناسب مع الأولوية. يتيح العرض التصفية بحسب الحالة والأولوية وتجاوز المهلة، وتعرض التفاصيل الخط الزمني مع الملاحظات الداخلية. ## الوكلاء والمعرفة - **الوكلاء**: وكلاء Dot الستة مع زر تفعيل لكل منشأة. لا يمكن إيقاف الوكيل الافتراضي. - **معاينة التوجيه**: اكتب رسالة عميل، واختر قناة، وشاهد أي وكيل سيتولاها ولماذا، ودرجة كل مرشح. دون استدعاء للنموذج ودون استهلاك للحصة. - **مصادر المعرفة**: الصق نصًا أو أدخل صفحة https عامة، واختر مجموعة، ثم فهرسها. المحتوى المتطابق لا يُفهرس مرتين. - **أحدث القرارات**: الوقت والقناة والوكيل والسبب والدرجة وزمن الاستجابة. نص الرسالة لا يُخزَّن أبدًا. ## الفريق والدخول ادعُ أعضاء بدور محدد (مالك، مدير، موظف، مسؤول الفوترة)، وغيّر الأدوار، وأصدر رموز إعادة تعيين كلمة المرور، وأدر كلمة مرورك والتحقق بخطوتين. ## الإعدادات المظهر واللغة والكثافة؛ الاستخدام وكود تضمين نافذة الدردشة؛ اتصالات القنوات مع متطلباتها والخطوة التالية؛ متاجر Salla و Zid؛ الاشتراك والفواتير مع الدفع بالبطاقة أو بالتحويل البنكي. --- # الأمان والصلاحيات > جهات الدخول، والأدوار، والأسرار المخزّنة، وحدود المعدّل، والمعرّفات المجمّدة عن قصد. URL: https://chatwork.io/ar/docs/security Section: Operate ## جهات الدخول | جهة الدخول | بيانات الاعتماد | النطاق | |---|---|---| | المشرف | `DOT_ADMIN_API_KEY` (متغير بيئة، ≥ 32 حرفًا) | كل مسارات الإدارة | | المنشأة | مفتاح عشوائي يُعرض مرة واحدة، يُخزَّن بصيغة hash، وقابل للتدوير | معرّف المنشأة الخاص بها | | العضو | جلسة `dot_sess_…` ناتجة عن تسجيل دخول، تُخزَّن بصيغة SHA-256 | معرّف منشأته، مع التصفية بحسب الدور | | نافذة الدردشة | جلسة زائر موقّعة بـ HMAC | معرّف منشأتها + معرّف الزائر، `web_widget` فقط | | Webhook | سر في الرابط، يُقارن في زمن ثابت | `POST /webhooks/chatwoot` | بيانات الاعتماد المفقودة أو غير الصالحة تتلقى `401` مع `WWW-Authenticate: Bearer`؛ وبيانات الاعتماد الصالحة لمنشأة أخرى تتلقى `403`. إرسال بيانات الاعتماد عبر CORS معطّل دائمًا. ## التسجيل الذاتي ينشئ `POST /api/v1/signup` منشأة ومالكها الأول وفترة تجريبية. يخضع لحد معدّل لكل عنوان IP (5 في الساعة)، ولسقف يومي على مستوى المنصة (`DOT_SIGNUP_DAILY_CAP`)، ويتحقق من كل حقل برموز أخطاء ثابتة. لا يوجد مزوّد بريد إلكتروني بعد، لذلك لا يُتحقق من العناوين: استخدم `DOT_SIGNUP_MODE=code` (رمز تسجيل مشترك، يُقارن في زمن ثابت) أو `closed` على أي خادم لا تريد أن ينشئ الغرباء منشآت عليه. التسجيل الذي يفشل بعد إنشاء المنشأة يحذف المنشأة من جديد. ## الأدوار `owner` و`manager` و`agent` و`billing`، مع RBAC يرفض افتراضيًا على كل مسار خاص بالمنشأة. تتبع مسارات موجّه تشات وورك نطاقات قاعدة المعرفة: القراءة ومعاينات التوجيه تحتاج إلى `kb:read` (مالك، مدير، موظف)، والكتابة تحتاج إلى `kb` (مالك، مدير). لا يمكن إزالة آخر مالك نشط أو تخفيض دوره (حماية ذرّية). TOTP مع رموز استرداد تُستخدم مرة واحدة؛ وقفل تسجيل الدخول لكل `(slug, email, ip)` ولكل `(slug, email)`. ## الأسرار المخزّنة بيانات اعتماد المزوّدين ورموز agent-bot ورموز التجارة وأسرار TOTP مشفّرة بـ Fernet باستخدام `DOT_CREDENTIALS_KEY`، وهو محفوظ خارج قاعدة البيانات. لا تعيد أي واجهة API سرًا أو نصًا مشفّرًا أو أي حقل `*_token` أو `*_secret` أو `*_api_key` أو `*_password` أو `*_enc`؛ وتحجب السجلات `?token=` و`dot_sess_` و`dot_inv_` و`dot_rst_`. ## ترويسات الاستجابة تحمل كل استجابة `X-Request-ID` (قيمة المستدعي إن كانت سليمة الصيغة، وإلا قيمة مولَّدة)، و`X-Content-Type-Options: nosniff` و`Referrer-Policy: no-referrer`. تضيف صفحات HTML `X-Frame-Options: DENY` و`Permissions-Policy` مقيِّدة؛ ومسارات `/api/*` تحمل `Cache-Control: no-store`. ## أمان الاتصالات الصادرة روابط MCP الخاصة بالمنشآت وروابط مصادر المعرفة في موجّه تشات وورك يجب أن تكون https وأن تُحلّ إلى عناوين عامة (تُرفض النطاقات الخاصة ونطاقات loopback و link-local والنطاقات المحجوزة). الردود العامة على X تُقصّ إلى 280 حرفًا، وتُرسل بتأخير يحاكي البشر مدته 8–20 ثانية، وتتوقف 30 دقيقة عند `402`/`429`. ## المعرّفات المجمّدة بعض الأسماء مقفلة بموجب `docs/INVARIANTS.md` لأن العملاء أو البيانات يعتمدون عليها: بادئات مفاتيح Redis (`diamond:dot:*`)، والمتغيرات العامة لنافذة الدردشة (`window.DiamondDotWidget` و`diamond_dot_visitor_id`)، ومعرّف `service` في `/health`، وأسماء أدوات MCP. العلامة التجارية هي تشات وورك؛ وهذه المعرّفات جزء من البنية الداخلية وتبقى كما هي. ## الإبلاغ عن ثغرة راجع `SECURITY.md` في المستودع. يُرجى عدم فتح issues عامة للبلاغات الأمنية. --- # التشغيل > النسخ الاحتياطية، والترقيات، والترحيلات، والتدوير، وبوابة الفحص التي تعمل قبل كل إصدار. URL: https://chatwork.io/ar/docs/operations Section: Operate ## بوابة الفحص يشغّل `scripts/check.sh` فحوص المنصة كلها انطلاقًا من نسخة نظيفة من المستودع: 1. اختبارات الوحدة للجسر (Python 3.12 عبر `uv`، دون شبكة)، 2. طبقة اختبارات PostgreSQL للجسر على عنقود مؤقت: `pg_ctl` إن كان مثبتًا، وإلا PostgreSQL 16 مضمَّن مع pgvector (`scripts/pg_embedded.py`)، فيُختبر دائمًا SQL موجّه تشات وورك، 3. فحص compile وحد 200 سطر (الملفات الجديدة ≤ 200 سطر؛ والملفات القديمة لا يجوز إلا أن تتقلص)، 4. التحقق من السجل (registry)، وبيانات اختبار المطابقة للتوجيه والتسعير في Python و TypeScript، 5. فحص الأنواع للموقع وبناء الإنتاج، 6. فحص الأسرار، والتأكد من عدم تتبّع أي ملف `.env`. لا يُدمج شيء والبوابة حمراء. ## النسخ الاحتياطية قبل كل نشر: أمر `SAVE` في Redis ونسخ `dump.rdb`، و`pg_dumpall` لـ PostgreSQL (قاعدتا البيانات كلتاهما)، ونسخ من `docker-compose.yml` و`.env`، وكلها تحت `backups/` مع `chmod 600`. اختبر الاستعادة كل ثلاثة أشهر. ## ترقية المنصة ```bash git pull docker compose -f infra/docker-compose.yml build bridge site docker compose -f infra/docker-compose.yml up -d docker compose -f infra/docker-compose.yml exec bridge python -m storage.migrate docker compose -f infra/docker-compose.yml exec bridge python -m cloudrag.seed ``` عمليات الترحيل (migration) يمكن تكرارها دون أثر إضافي، وتعمل تحت قفل استشاري؛ والبذر يُدرج الوكلاء أو يحدّثهم بحسب slug والإصدار. أعد تشغيل `cloudrag.seed --embed` بعد تغيير مقاصد (intents) أي وكيل. ## ترقية chatwork غيّر الوسم المثبَّت في `infra/docker-compose.yml`، ثم خذ نسخة احتياطية، ثم نفّذ `docker compose pull chatwoot-rails chatwoot-sidekiq && docker compose up -d chatwoot-rails chatwoot-sidekiq`، ثم تحقق من `https://chat./api`. سجّل الزوج الجديد في مصفوفة الإصدارات. ## التدوير تُدوَّر `DOT_ADMIN_API_KEY` و`CHATWOOT_WEBHOOK_SECRET` (حدّث رابط agent-bot في chatwork) و`DOT_WIDGET_SIGNING_KEY` بتعديل `.env` وإعادة تشغيل الجسر؛ وجلسات نافذة الدردشة تعيد إصدار نفسها. تدوير `DOT_CREDENTIALS_KEY` يتطلب إعادة ربط كل قناة وإعادة تسجيل MFA، فخطّط له مسبقًا. ## الحد الأدنى للمراقبة `GET /health` فحص حيوية (liveness): `{status, service, version}`؛ ومع مفتاح المشرف يضيف الإعدادات وعدد المنشآت. `GET /ready` فحص الجاهزية للمنسّق (orchestrator): يعيد `200` فقط عندما يجيب Redis (و PostgreSQL، عندما يكون هو مخزن البيانات المرجعي)؛ ويستخدمه فحص الصحة في Compose. راقب `GET /api/v1/admin/events/stats` لمتابعة أعداد `failed` و`dead`، و`GET /api/v1/tenants/{slug}/cloudrag/decisions` لمتابعة زمن استجابة التوجيه. --- # مرجع API > واجهة HTTP بحسب المجموعات، مع بيانات الاعتماد التي يحتاجها كل مسار. الرابط الأساسي https://chatwork.io أو https://api.chatwork.io. URL: https://chatwork.io/ar/docs/api Section: Reference تُرسل بيانات الاعتماد في `Authorization: Bearer ` (وكذلك `X-Admin-Key` / `X-API-Key`). الاستجابات بصيغة JSON وتتضمن `ok`، وعند الفشل `error`. ## عام (دون بيانات اعتماد) | المسار | الأثر | |---|---| | `GET /api/v1/pricing` | كتالوج الباقات مع عروض أسعار محسوبة لكل باقة وفترة (هللات بأعداد صحيحة، ضريبة القيمة المضافة، التوفير السنوي، تكلفة كل 1,000 رد) | | `GET /api/v1/pricing/quote?replies=&interval=&plan=` | حاسبة الباقات: الباقة الموصى بها لحجم شهري معيّن وعرض سعر كل باقة | | `GET /api/v1/signup/config` | وضع التسجيل، أيام الفترة التجريبية، الحد الأدنى لكلمة المرور، معرّفات الباقات | | `GET /api/v1/signup/check?slug=` | توفّر معرّف المنشأة | | `POST /api/v1/signup` | ينشئ منشأة ومالكها وفترة تجريبية؛ يعيد جلسة عضو | | `GET /api/v1/agents` | كتالوج الوكلاء دون prompts | | `GET /ready` | الجاهزية: `200 ready` عندما يجيب Redis (وقاعدة البيانات، عندما تكون هي مخزن البيانات المرجعي)؛ وإلا `503 not_ready` | ## المنشآت (المشرف) | المسار | الأثر | |---|---| | `GET /api/v1/plans` | كتالوج الباقات | | `GET /api/v1/tenants` | يسرد المنشآت (لا يعيد المفاتيح أبدًا) | | `POST /api/v1/tenants/onboard` | ينشئ منشأة؛ يجهّز صندوق وارد أو يتركها في `needs_setup`؛ يُعرض المفتاح مرة واحدة | | `GET/PATCH/DELETE /api/v1/tenants/{slug}` | إدارة منشأة | | `POST /api/v1/tenants/{slug}/api-key/rotate` | مفتاح جديد يُعرض مرة واحدة | | `GET /api/v1/tenants/{slug}/public` | الإعدادات العامة لنافذة الدردشة (دون مصادقة) | ## المحادثات والتحكم (المنشأة) | المسار | الأثر | |---|---| | `GET …/chatwoot-hub?status=&page=` | صندوق الوارد مقسّمًا إلى صفحات مع أعداد من الخادم | | `GET/POST …/conversations/{id}/messages` | قراءة؛ رد موظف، أو ملاحظة خاصة، أو `use_ai` | | `POST …/conversations/{id}/status` | `open` / `pending` / `resolved` | | `GET/POST …/control/{id}` | الملكية: `claim`، `release`، `pause` | | `POST …/ask`, `POST …/inbound` | يشغّل مسار المعالجة؛ `/inbound` ينسخ المحادثة إلى صندوق الوارد ويقبل جلسات نافذة الدردشة | ## الوكلاء والمعرفة — موجّه تشات وورك (المنشأة) | المسار | الأثر | |---|---| | `GET …/cloudrag/agents` | الكتالوج مع حالة التفعيل لكل منشأة | | `PATCH …/cloudrag/agents/{agent}` `{enabled}` | تفعيل وكيل أو تعطيله (لا يمكن تعطيل الوكيل الافتراضي) | | `POST …/cloudrag/route` `{text, channel_type}` | معاينة التوجيه: القرار، المرشحون، الكلمات المفتاحية المطابقة؛ دون استدعاء للنموذج | | `GET/POST …/cloudrag/sources` | سرد؛ إضافة `{kind: text\|url, title, collection, content\|url}` | | `DELETE …/cloudrag/sources/{id}` | حذف مصدر ومقاطعه | | `GET …/cloudrag/decisions?limit=` | سجل التوجيه الأخير وإحصاءات 30 يومًا | المسارات المعتمدة على مخزن البيانات تجيب بـ `503 cloudrag_unavailable` دون `DOT_DATABASE_URL`. ## التذاكر، جهات الاتصال، الأعضاء، الفوترة، الاتصالات، التجارة (المنشأة) `GET/POST …/tickets`, `GET/PATCH …/tickets/{id}`, `POST …/tickets/{id}/comments` · `GET …/contacts`, `GET …/contacts/{id}`, `GET …/contacts/{id}/tickets` · `POST /api/v1/auth/login`, `/auth/logout`, `GET /auth/me`, `/auth/mfa/*`, `/auth/password`, `GET/POST …/members`, `PATCH/DELETE …/members/{id}`, `POST …/members/{id}/reset` · `POST …/billing/change-plan`, `GET …/billing/subscription`, `POST …/billing/checkout`, `POST …/billing/bank-transfer`, `GET …/invoices/{id}` · `GET …/connections`, `POST …/connections/{channel}`, `POST …/connections/{channel}/test`, `DELETE …/connections/{channel}` · `GET …/commerce`, `POST …/commerce/{provider}/authorize`, `GET …/commerce/orders`. ## المنصة | المسار | الأثر | |---|---| | `GET /health` | `{status, service, version}`؛ وتفاصيل أكثر مع مفتاح المشرف | | `GET /mcp`, `GET /.well-known/mcp.json`, `POST /mcp` | اكتشاف MCP (عام) والاستدعاءات (bearer) | | `POST /webhooks/chatwoot?token=…` | Webhook الخاص بـ agent-bot | | `GET /api/v1/admin/events`, `…/stats`, `POST …/{id}/retry` | الأحداث الواردة/الصادرة (inbox/outbox) (المشرف) | | `GET /widget.js?tenant=` | نافذة الدردشة القابلة للتضمين | --- # التهيئة > كل متغيرات البيئة التي تقرؤها المنظومة، مجمّعة بحسب الخدمة، مع ما يتعطّل دونها. URL: https://chatwork.io/ar/docs/configuration Section: Reference القيم محفوظة في `infra/.env` (لا يُضاف إلى المستودع أبدًا). يرفض الجسر أن يبدأ في الإنتاج (`APP_ENV=production`) إذا كان `DOT_ADMIN_API_KEY` أو `CHATWOOT_WEBHOOK_SECRET` أو `DOT_WIDGET_SIGNING_KEY` أقصر من 32 حرفًا أو بدا قيمة مؤقتة (placeholder). ## الحافة والموقع | المتغير | المعنى | |---|---| | `PLATFORM_DOMAIN` | النطاق الرئيسي (apex)؛ يقدّم Caddy `www.` و`app.` و`api.` و`chat.` تحته | | `ACME_EMAIL` | بريد التواصل لدى Let's Encrypt | ## chatwork `SECRET_KEY_BASE`, `POSTGRES_DB`, `POSTGRES_USER`, `POSTGRES_PASSWORD`, `REDIS_PASSWORD`, `CHATWOOT_PUBLIC_URL` (`https://chat.`). متغيرات البريد والتخزين تتبع وثائق chatwork نفسها. ## الجسر — الأساس | المتغير | المعنى | |---|---| | `APP_ENV` | `development` أو `production` | | `DOT_PUBLIC_BASE_URL` | `https://`؛ يُبنى منه Webhook الخاص بـ agent-bot ومصدر (origin) نافذة الدردشة | | `DOT_ALLOWED_ORIGINS` | قائمة المصادر المسموح بها في CORS (مصدر البوابة + مواقع العملاء) | | `DOT_ADMIN_API_KEY`, `CHATWOOT_WEBHOOK_SECRET`, `DOT_WIDGET_SIGNING_KEY` | أسرار التحكم في الوصول (≥ 32 حرفًا) | | `DOT_CREDENTIALS_KEY` | مفتاح Fernet للأسرار المخزّنة | | `DOT_STORAGE_BACKEND` | `redis` (الافتراضي) أو `postgres` | | `DOT_DATABASE_URL` | رابط قاعدة بيانات الجسر؛ يتطلبه موجّه تشات وورك وقاعدة المعرفة المدمجة | | `UVICORN_FORWARDED_ALLOW_IPS` | عناوين IP للوسيط (proxy) الموثوق بها لترويسات `X-Forwarded-*` | ## الجسر — التسجيل واللغات | المتغير | الافتراضي | المعنى | |---|---|---| | `DOT_SIGNUP_MODE` | `open` | `open` أو `code` (يتطلب `DOT_SIGNUP_CODE`) أو `closed` | | `DOT_SIGNUP_CODE` | — | الرمز المشترك لوضع `code`؛ دونه يتصرف `code` مثل `closed` | | `DOT_SIGNUP_TRIAL_DAYS` | `14` | مدة الفترة التجريبية للتسجيل الذاتي؛ القيمة `0` تبدأ في `pending_payment` | | `DOT_SIGNUP_DAILY_CAP` | `50` | عدد عمليات التسجيل يوميًا على مستوى المنصة (يحدّ من تكلفة الفترات التجريبية)؛ القيمة `0` تعطّل السقف | | `DOT_DEFAULT_LOCALE` | `ar` | لغة مسارات البوابة وتسجيل الدخول التي لا تحمل بادئة لغة | | `DOT_SITE_URL` | `https://chatwork.io` | مصدر (origin) الموقع التسويقي (روابط الشروط والخصوصية في صفحة التسجيل) | ## الجسر — chatwork والقنوات `CHATWOOT_BASE_URL` (داخلي، `http://chatwoot-rails:3000`), `CHATWOOT_ACCOUNT_ID`, `CHATWOOT_INBOX_ID`, `CHATWOOT_ADMIN_API_TOKEN`, `CHATWOOT_BOT_TOKEN`, `CHATWOOT_PLATFORM_TOKEN`؛ X: `X_API_KEY`, `X_API_SECRET`, `X_ACCESS_TOKEN`, `X_ACCESS_TOKEN_SECRET`, `X_BEARER_TOKEN`, `X_BOT_USER_ID`, `X_POLL_INTERVAL_SECONDS`, `X_REPLY_MIN_DELAY_SECONDS`, `X_REPLY_MAX_DELAY_SECONDS`, `ENABLE_X_DIRECT_DISPATCH`. ## الجسر — الذكاء الاصطناعي وموجّه تشات وورك | المتغير | الافتراضي | المعنى | |---|---|---| | `DOT_LLM_BASE_URL` | `https://api.openai.com/v1` | نقطة نهاية متوافقة مع OpenAI | | `DOT_LLM_API_KEY`, `DOT_LLM_MODEL` | — / `gpt-4o-mini` | مفتاح المزوّد ونموذج المحادثة | | `DOT_SYSTEM_PROMPT`, `DOT_HANDOFF_KEYWORDS` | القيم الافتراضية في الملفات | قيم بديلة لا ترتبط بمنشأة | | `CLOUDRAG_ENABLED` | `true` | إيقاف الطبقات المعتمدة على مخزن البيانات (يبقى التوجيه المعجمي) | | `CLOUDRAG_EMBEDDINGS` | `off` | `off` (قاعدة معرفة مدمجة بلا اتصال خارجي) أو `provider` (تفعيل الطبقة الدلالية) | | `CLOUDRAG_EMBEDDING_MODEL` | `text-embedding-3-small` | نموذج التضمينات (embeddings) على نقطة النهاية نفسها | | `CLOUDRAG_EMBEDDING_DIM` | `1536` | يجب أن يطابق أعمدة `vector(1536)` | | `CLOUDRAG_TOP_K` | `4` | العدد الافتراضي للمقاطع في كل رد مستند إلى مصادر المعرفة | | `CLOUDRAG_LOG_DECISIONS` | `true` | كتابة سجل التوجيه | | `CLOUDRAG_REGISTRY_DIR` | المضمَّن | تغيير موقع السجل (registry) | | `PRICING_CATALOG_FILE` | المضمَّن | تغيير موقع `pricing/catalog.json` | ## الجسر — الأموال والتجارة `SELLER_NAME`, `SELLER_VAT_NUMBER`, `SELLER_CR_NUMBER`, `SELLER_ADDRESS`, `DOT_PLANS_JSON`, `MOYASAR_SECRET_KEY`, `MOYASAR_PUBLISHABLE_KEY`, `MOYASAR_WEBHOOK_SECRET`, `MOYASAR_LIVE`, `SALLA_CLIENT_ID`, `SALLA_CLIENT_SECRET`, `SALLA_WEBHOOK_SECRET`, `ZID_CLIENT_ID`, `ZID_CLIENT_SECRET`, `ZID_WEBHOOK_SECRET`, `ticket_sla_first_response_minutes`, `ticket_sla_resolution_minutes`. --- # سجل التغييرات ومصفوفة الإصدارات > ما الذي تغيّر في كل إصدار من المنصة، وأي إصدار من محرك صندوق الوارد (chatwork) يأتي معه. URL: https://chatwork.io/ar/docs/changelog Section: Reference ## مصفوفة الإصدارات | المنصة | محرك صندوق الوارد (chatwork) | PostgreSQL | Redis | Python | Node (بناء الموقع) | |---|---|---|---|---|---| | 3.4.1 | v4.19.1 | 16 (pgvector) | 7 | 3.12 | 22 | | 3.4.0 | v4.19.1 | 16 (pgvector) | 7 | 3.12 | 22 | | 3.3.2 | v4.19.1 | 16 (pgvector) | 7 | 3.12 | 22 | | 3.3.1 | v4.19.1 | 16 (pgvector) | 7 | 3.12 | 22 | | 3.3.0 | v4.19.1 | 16 (pgvector) | 7 | 3.12 | 22 | | 3.2.0 | v4.19.1 | 16 (pgvector) | 7 | 3.12 | 22 | | 3.1.0 | v4.19.1 | 16 (pgvector) | 7 | 3.12 | 22 | | 3.0.0 | v4.19.1 | 16 (pgvector) | 7 | 3.12 | 22 | ## 3.4.1 — 2026-11-15 **التفاعلية الشاملة للوحة التحكم والموقع.** استكمال كافة المسارات التفاعلية في صندوق الوارد (الردود الجاهزة، العبارات السريعة، المساعد الذكي بثلاثة أوضاع، الوسوم، سجل العميل ودرج الجوال)، سجل العملاء (CRM) بالبحث والترقيم، لوحة الأوامر السريعة `⌘K` والإشعارات ومساحة عمل اليوم، نماذج ربط القنوات، تبديل الباقات ودورة الفوترة ومعاينة وطباعة الفاتورة الضريبية، المعاينة الحية لمكوّن الدردشة، لوحة المشرف العام، ضبط اتجاه أسماء المنشآت، ومزامنة الوضع الداكن بين الموقع واللوحة مع تغطية ترجمة ثنائية كاملة. كما أُعيد بناء نظام التوثيق (`/ar/docs` و`/en/docs`) وفق تصميم وهيكلة وبنية قالب وتيرة (تخطيط ثلاثي الأعمدة بشريط جانبي زجاجي، شجرة `meta.json`، شريط إجراءات نسخ وعرض Markdown الخام لكل صفحة، ملف `/llms-full.txt`، وبحث فوري `⌘K`). ## 3.4.0 — 2026-11-12 **موجّه تشات وورك وقاعدة المعرفة المدمجة.** أصبحت طبقة التوجيه والإسناد تحمل اسم **موجّه تشات وورك** في كافة صفحات الموقع ولوحة التحكم وصفحة الدخول والباقات وسجل الوكلاء وملفات PDF، مع نقل التوثيق إلى [/docs/router](/ar/docs/router). افتراضياً (`CLOUDRAG_EMBEDDINGS=off`) تُفهرس المقاطع وتُسترجع نصياً داخل PostgreSQL دون أي اتصال بمزوّد تضمين خارجي؛ وعند تفعيل `CLOUDRAG_EMBEDDINGS=provider` يستمر البحث الهجين مع التراجع التلقائي للفهرسة النصية عند تعذّر مزوّد التضمين. ## 3.3.2 — 2026-11-12 **تعزيز الأمان والاعتمادية.** تثبيت عنوان IP عند زمن الاتصال لمنع هجمات إعادة ربط DNS في روابط MCP وموجّه تشات وورك، وجلب صفحات المعرفة بالبث المتدفق ضمن حد 2 ميجابايت، وفرض حد 1 ميجابايت لحجم الطلبات مع التحقق الصارم وعزل المحادثات الفارغة في خادم MCP، والمعالجة التلقائية لانتهاء صلاحية محددات المعدل، واسترداد حصة التسجيل اليومية عند فشل الإنشاء، وتهريب محارف الإغلاق في ويدجت الدردشة، وإضافة ترويسات الحماية على الحافة. **جلسات MCP ولوحة المشغّل.** تخزين جلسات MCP لكل منشأة مع إعادة المصافحة تلقائياً عند انتهاء صلاحيتها؛ وإعادة توجيه العضو تلقائياً إلى صفحة الدخول عند انتهاء جلسته، وتفريغ ذاكرة التبويبات عند تبديل المنشأة، وتنسيق روابط الرسائل دون التباس علامات الترقيم، ومنع تكرار جهات الاتصال في جدول العملاء. ## 3.3.1 — 2026-11-11 **الوكلاء وموجّه تشات وورك.** حصر الأدوات المدمجة (`lookup_order`) بالوكيل المصرّح بها (`dot-orders`)؛ ضمان عدم إضعاف أولوية وكلاء التحويل البشري الفوري (`dot-guardian`) بالدرجات الدلالية؛ توفير أمثلة عربية وإنجليزية لجميع الوكلاء الستة؛ دمج الاسترجاع المعجمي المطبّع مع المتجهات وحدّ أدنى للصلة في موجّه تشات وورك؛ وربط بيانات جهة الاتصال في ردود الذكاء الاصطناعي من اللوحة للتحقق من الطلبات. **اللوحة والتخزين.** فتح جلسات دور «مسؤول الفوترة» مباشرة على الاشتراك والحصة والفواتير؛ تسوية الاستخدام على PostgreSQL في معاملة واحدة وجلب القنوات للتوجيه باستعلام واحد؛ وتنقية `components.html` وتباين التنبيهات الداكنة وفق هوية «ليل وجمرة». ## 3.3.0 — 2026-11-10 **«ليل وجمرة».** هوية جديدة تحل محل مظهر 3.2.0 في الموقع واللوحة وصفحة تسجيل الدخول ونافذة الدردشة وملفات PDF: رمز هو ابتسامة وحرف التاء (أو حرف C إذا أُدير)، أزرقان ليلي وسماوي مع لون دافئ واحد للزر الأساسي، وخط واحد هو Alexandria للعربية والإنجليزية. ملفات العلامة في صفحة [الموارد](/ar/resources). **الصفحة الرئيسية.** أُعيد بناؤها حول مثال محادثة ومدة التجربة من الكتالوج. بلا أرقام افتراضية. **الاسم بالعربية.** يُكتب المنتج «تشات وورك» في النصوص العربية. ## 3.2.0 — 2026-11-10 **هوية تشات وورك.** الموقع ولوحة المشغّل وصفحة تسجيل الدخول ونافذة الدردشة وملفات PDF تحمل الآن هوية تشات وورك: حرف C مع نقطة الرد والذيل، الأزرق السماوي والكحلي العميق، وخطّا Nunito Sans وIBM Plex Sans Arabic. الوضع الفاتح هو الافتراضي، والوضع الداكن كحلي. ملفات العلامة متاحة في صفحة [الموارد](/ar/resources). **اسم واحد.** نصوص المنتج ومزايا الباقات ورسائل اللوحة وأوصاف أدوات MCP تقول تشات وورك، وصندوق الوارد هو صندوق وارد تشات وورك. يبقى اسم المحرك مفتوح المصدر في وثائق الاستضافة الذاتية هذه وفي سطر إسناد واحد. لم يتغير أي متغير بيئة أو رابط أو حقل في API. صفحة المحرك انتقلت إلى [/docs/inbox-engine](/ar/docs/inbox-engine). **خطوط مستضافة ذاتياً في اللوحة.** لم تعد اللوحة وصفحة تسجيل الدخول تطلبان الخطوط من شبكة خارجية. ## 3.1.0 — 2026-11-10 **لغتان في كل مكان.** الموقع ولوحة المشغل وصفحة تسجيل الدخول متاحة تحت `/en` و`/ar`. إنجليزية اللوحة مضمونة باختبار تغطية: أي نص عربي جديد بلا ترجمة يُفشل بوابة الفحص. **التسجيل وصفحة تسجيل دخول مرتّبة.** ينشئ `app.chatwork.io/{lang}/signup` منشأة ومالكها وفترة تجريبية مدتها 14 يومًا في خطوة واحدة؛ ويتولى `/login` الأعضاء و MFA والدعوات وإعادة تعيين كلمات المرور. الأوضاع: مفتوح، برمز، مغلق. **لوحة المشغل.** نظرة عامة حقيقية (أعداد صندوق الوارد، التذاكر ومهلة الخدمة (SLA)، الاستخدام والاشتراك، توزيع التوجيه، حالات القنوات، قائمة الإعداد)، وعرض «الوكلاء والمعرفة» (أزرار التفعيل، معاينة التوجيه، المصادر، سجل القرارات)، وتخطيط يعمل على الهواتف. **تسعير حقيقي.** ملف كتالوج واحد يغذّي الفواتير وواجهة API والموقع. يستخدم `GET /api/v1/pricing` والحاسبة حساب الفاتورة نفسه، فالسعر الظاهر في الصفحة هو المبلغ في الفاتورة. **تحسينات.** نقطة نهاية للجاهزية، ومعرّفات للطلبات، وتحديثات تذاكر متسلسلة بقفل، وتخزين مؤقت في موجّه تشات وورك ومنع تكرار المصادر، وطبقة اختبارات لقاعدة البيانات تعمل في أي مكان (PostgreSQL مضمَّن مع pgvector). **ملفات PDF تسويقية** بالعربية والإنجليزية: نظرة عامة، الأسعار، الوكلاء، الأمان. ## 3.0.0 — 2026-11-09 **منصة واحدة.** أُزيل خادم Node المسمى «Studio» الذي كان يحاكي البوابة ببيانات تجريبية في الذاكرة؛ وجسر FastAPI هو الواجهة الخلفية الوحيدة. انتقل HTML البوابة من سلسلة نصية في Python إلى ملف قالب يُقدَّم على `app.chatwork.io`؛ ورموز التصميم (design tokens) معرّفة مرة واحدة. ملف `VERSION` واحد يغذّي الجسر وبيان MCP وهذا الموقع. **chatwork.io موقع تسويقي** يضم `/agents` و`/docs` و`/blog`، ويُبنى بناءً ثابتًا؛ وتبقى واجهة API و MCP والـ Webhooks ونافذة الدردشة على النطاق الرئيسي (apex) في مساراتها الحالية. **موجّه تشات وورك.** الوكلاء ملفات في `agents/registry/`، يحمّلها الجسر والموقع. تُوجَّه كل رسالة إلى وكيل واحد (الطبقة المعجمية دائمًا، والطبقة الدلالية مع pgvector)، ويُسنَد ردّها إلى مقاطع معرفة مع الاستشهاد بها، وتُسجَّل. واجهة API جديدة تحت `/cloudrag/*`، وترحيل (migration) `012_cloudrag.sql`، و`python -m cloudrag.seed`. **ستة وكلاء Dot.** Concierge (الافتراضي)، Support، Sales، Orders، Billing، Guardian (يحوّل إلى موظف دائمًا). **العلامة التجارية.** النصوص الظاهرة للمستخدم تقول تشات وورك؛ والمعرّفات المجمّدة لم تتغير. ## 2.x — من 2026-11-04 إلى 2026-11-05 (باسم `dot-x-chatwoot`) دورات العمل (Sprints) 1–5: المصادقة، وتوجيه المنشآت مع العزل (quarantine)، وفوترة صادقة بالهللة، ومخزن واحد للمحادثات، والأحداث الواردة/الصادرة (inbox/outbox)، وأعضاء مع MFA و RBAC، وتذاكر مع مهلة الخدمة (SLA)، وتجارة Salla/Zid، ومستودعات بيانات على PostgreSQL، وتغيير العلامة التجارية إلى تشات وورك.