Skip to main content

D-13 Channel Gateway

Brick D: Tools, skills, plugins, MCP, connectors. French version: D-13-channel-gateway

1. Role and responsibilities​

Connects channels (web, mobile, email, messaging, voice) to agents: inbound message -> session -> run.

  • Normalize inbound messages
  • Attach or create the session (C-07)
  • Apply limits and DLP per channel

2. Position in the architecture and interactions​

  • Callers: Web and mobile apps, messaging providers, voice (brick F).
  • Execution path: Synchronous (inbound) then durable run; reply by SSE or callback.
  • Every interaction goes through the Control Plane API v1 (/v1) behind the API Gateway (D-14).

3. Open source component and developed part​

  • Open source: none (to develop)
  • Developed: Fully developed.
  • External integration through an adapter eai/integrations/<system>.py with an in-process fallback when the URL is not configured.

4. Data model​

Tables (schema eai, tenant_id RLS):

  • eai.channels
  • eai.sessions

Common columns: id uuid, tenant_id uuid NOT NULL, created_at, updated_at; RLS policy current_setting('app.tenant_id', true)::uuid.

5. Contract​

  • Applied contract: channel-manifest
  • JSON Schema: contracts/v1/channel-manifest.schema.json
  • Key fields: spec.type, spec.agent_ref, spec.auth, spec.transport, spec.limits, spec.sessions, spec.dlp
  • Validation: POST /v1/contracts/{name}/validate; manifest apply: POST /v1/manifests/apply.

6. API endpoints​

  • GET /v1/channels
  • POST /v1/channels
  • GET /v1/channels/{name}
  • PATCH /v1/channels/{name}
  • DELETE /v1/channels/{name}
  • POST /v1/channels/{name}/inbound
  • GET /v1/channels/{name}/sessions

Request POST /v1/channels/{name}/inbound:

{
"external_user": "+33600000000",
"text": "I want to cancel my order"
}

Response:

{
"session_id": "ses_9a1",
"run_id": "run_01JB",
"state": "queued"
}

7. SDK examples​

Python:

from enterprise_ai import EnterpriseAI

client = EnterpriseAI(base_url="<control-plane-url>", api_key="eai_xxx_secret")
client.channels.inbound("whatsapp-fr", "Hello", user="+33600000000")

TypeScript:

import { EnterpriseAI } from "@enterprise-ai/sdk";

const client = new EnterpriseAI({ baseUrl: "<control-plane-url>", apiKey: process.env.EAI_API_KEY });
await client.channels.inbound("web-widget", { user: "u1", text: "Hello" });

Java:

EnterpriseAIClient client = EnterpriseAIClient.builder()
.baseUrl("<control-plane-url>")
.apiKey(System.getenv("EAI_API_KEY"))
.build();
client.channels().inbound("web-widget", Map.of("user", "u1", "text", "Hello"));

Go:

c, _ := eai.NewClient(eai.WithBaseURL("<control-plane-url>"), eai.WithAPIKey(os.Getenv("EAI_API_KEY")))
c.Channels.Inbound(ctx, "web-widget", map[string]any{"user": "u1", "text": "Hello"})

8. Configuration​

  • Environment variables: EAI_DATABASE_URL
  • Helm values keys: controlPlane.config, controlPlane.secrets

9. Security controls​

  • Channel specific authentication (spec.auth)
  • Inbound and outbound DLP
  • Every request carries the tenant resolved from the credential; PostgreSQL RLS
  • Every mutation and policy decision writes a hash-chained audit event

10. Observability​

  • Prometheus metrics: eai_channel_messages_total{channel,direction}
  • Traces: OpenTelemetry spans with GenAI semantic conventions (gen_ai.operation.name, gen_ai.agent.id, gen_ai.tool.name), attributes eai.tenant_id, eai.run_id, traceparent propagation.
  • Audit actions: channel.inbound

11. FinOps units​

  • Messages per channel.
  • Emitted as Usage Event (POST /v1/finops/usage) with tenant, project, agent and run.

12. Failure modes and resilience​

  • Deduplication by provider message id
  • Rate limit -> 429
  • Normalized errors (error envelope, message_i18n en/fr)

13. Standalone adoption (client of a client)​

  • enterprise_ai.channels + Control Plane + Agent Runtime.
  • SDK: enterprise_ai.tools / mcp / skills / plugins / connectors / channels
  • Minimal deployment: Helm chart with controlPlane.enabled=true and PostgreSQL; disabled external components use their in-process fallback.

14. Acceptance tests​

  1. Inbound message creates session and run
  2. Cross-tenant access refused
  3. Error returned in fr with Accept-Language: fr