Skip to main content

Messaging transport edge for the Cogno cognitive pipeline — Telegram / WhatsApp (Evolution) / Web channel adapters behind a normalized, content-typed message model

Project description

cogno-gateway

Messaging transport edge for the Cogno cognitive pipeline — Telegram / WhatsApp (Evolution) / Web channel adapters behind a normalized, content-typed message model.

cogno-gateway is the sibling of cogno-vox: where vox converts audio ⇆ text, gateway converts channel messages ⇆ a normalized model. Pure transport — it verifies a webhook, parses the provider payload, fetches media, and sends a reply. It does not orchestrate the pipeline, read a database, or run an HTTP server.

Status: alpha — Telegram, WhatsApp (Evolution), and Web channels + the unit suite are in place.

webhook → verify + parse_inbound → [audio? fetch_media → vox STT] → PIPELINE (host)
        → reply → [vox TTS] → send

One port, pluggable channels

Every adapter satisfies the Channel protocol — verify · parse_inbound · fetch_media · send — so the host treats Telegram, WhatsApp, and Web uniformly:

from cogno_gateway import create_channel, ChannelConfig, OutboundMessage

tg = create_channel("telegram", ChannelConfig(token=bot_token, secret=hook_secret))
wa = create_channel("whatsapp", ChannelConfig(base_url=evo_url, token=apikey, instance="tenant1"))
web = create_channel("web")     # the cogno-cloud-ui {session_id, message} contract

msg = tg.parse_inbound(payload)                 # → InboundMessage (content-typed)
await tg.send(msg.sender, OutboundMessage(text="resposta"))   # auto-chunked

Rich, content-typed messages

InboundMessage.kind is a MessageKind: TEXT · IMAGE · AUDIO · VIDEO · DOCUMENT · LOCATION · REACTION · STICKER · INTERACTIVE. So a host handles reactions (emoji + target message id), media (a MediaRef resolved lazily via fetch_media — e.g. to feed audio to cogno-vox), quick-reply buttons (send OutboundMessage(buttons=[Button(...)]); the tap returns kind=INTERACTIVE with selection.id), replies, and plain text uniformly across channels.

Decoupled from cognition & audio

The gateway imports neither cogno-anima nor cogno-vox. Inbound audio comes back as bytes (fetch_media) for the host to run through vox STT; a voice reply is just OutboundMessage(audio=tts_bytes). The host wires the two edges to the pipeline.

WhatsApp: two providers, one port

WhatsApp is pluggable — the host picks per tenant:

  • EvolutionChannel ("evolution") — Evolution API, unofficial (QR/Baileys), free, full-featured; good for dev/testing.
  • WhatsAppCloudChannel ("whatsapp_cloud") — the official Meta Cloud API, for production/compliance: HMAC webhook verification, free-form replies within the 24h service window, and template messages for proactive sends outside it (OutboundMessage(template=Template(...))).

Install

pip install cogno-gateway          # adapters talk to providers over httpx; no web framework
pip install -e ".[dev]"            # tests (provider calls are mocked — no network)

The Cogno ecosystem

cogno-gateway is one organ of Cogno — a family of small, composable, Apache-2.0 libraries that together form a complete conversational-agent platform. Each library owns a single concern and stays infra-agnostic; a host assembles them into a running agent:

The Cogno ecosystem

The open-source libraries are the organs; the host is the body that joins them. Our reference host — cogno-host, with its cogno-ui dashboard — is the private product layer, but it holds no special powers: everything it does rides on the public seams documented in each library's docs/HOST_INTEGRATION.md, so you can assemble a body of your own.

Test

pytest tests/unit -q

Project details


Download files

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

Source Distribution

cogno_gateway-0.1.0.tar.gz (24.3 kB view details)

Uploaded Source

Built Distribution

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

cogno_gateway-0.1.0-py3-none-any.whl (28.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for cogno_gateway-0.1.0.tar.gz
Algorithm Hash digest
SHA256 44f0c1d24c61495e84f583f936947a3fb455d7336223e1006cc55ae17c1db758
MD5 8f3cd25ddccec208d152636089189e1d
BLAKE2b-256 fc491da5ee26d6cc5b8ca7a12c2af5813dded431067912b8459bc447ae366f60

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cogno_gateway-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 28.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for cogno_gateway-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 59818b1662e3ae609d553a4806bea7f421347b2768e3a49db0c75f8d9801230b
MD5 e1591453fee1b9aff9033db009a5dd92
BLAKE2b-256 6f27f2eb12d2e495a43fb1cf8ff3d5c79ae2f37627d3f320cca5c4d21e5f72fa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page