Channels

A channel binds one external account to one inbox. A message that arrives on Gmail or Telegram becomes an ordinary thread and message, so search, webhooks, runs, and the API work without knowing the platform. A reply on that thread goes back out through the platform it came from.

Status

Provider Direction Status
Telegram inbound webhook, outbound sendMessage Live, round trip verified
Gmail inbound poll, outbound messages.send Deployed, waiting on operator consent
WhatsApp, Slack — Not built

Lifecycle

pending ──► connected ──► needs_reauth
   │            │              │
   └────────────┴──────────────┴──► revoked
  • pending — a row exists and a signed state has been issued. No credential is stored.
  • connected — the provider handshake finished and the credential is stored.
  • needs_reauth — the refresh token stopped working. Connecting again replaces the row.
  • revoked — the credential is dropped and delivery stops. Stored messages follow inbox retention.

One channel per provider per workspace. A second inbox needs its own channel.

Connect

curl -X POST "$AMB_API/v1/channels" \
  -H "Authorization: Bearer $AMB_KEY" \
  -H "Content-Type: application/json" \
  -d '{"provider":"telegram","inbox_id":"inx_..."}'

The response includes a connect URL. For Telegram, open the bot and send /start; the signed state binds the chat to the inbox. For Gmail, the URL starts the OAuth consent flow. The state is single-use, expires in fifteen minutes, and only its hash is stored.

Inbound

  • Telegram updates are verified with the bot’s secret_token, normalised into the thread model, and deduplicated on update_id.
  • Gmail polling maps the provider thread to an AgentMailbox thread and drops the account’s own messages.
  • The provider message id is claimed before anything is stored, so a retried webhook or an overlapping poll cannot create a second copy.
  • Provider metadata (platform, sender, external id) is kept on the message.

Replies

A reply uses the channel of the thread. Telegram replies with reply_to_message_id; Gmail replies with threadId, In-Reply-To, and References. If the channel is revoked, the reply falls back to email.

Endpoints

Method Path
GET /v1/channels
POST /v1/channels
DELETE /v1/channels/{id}
POST /v1/channels/telegram/webhook/{id}

The Telegram webhook is called by Telegram, not by your integration. It is authenticated with the derived secret, not with an API key.