Skip to content

@anvia/channel ​

@anvia/channel is the platform-neutral foundation for channels: it defines addresses, normalized events, portable messages, splitting, runtime validation, and the Channel interface every adapter implements, with no dependency on @anvia/core or a platform SDK.

The package is currently a private workspace package in the channels monorepo; @anvia/channel is its intended npm name.

Pick the right utility ​

TaskUtility
Describe a destinationChannelAddress
Describe portable outputChannelMessage
Receive normalized platform inputChannelEvent and ChannelEventHandler
Send potentially long outputsendChannelMessage()
Send one already-bounded messagechannel.send()
Split a complete portable messagesplitChannelMessage()
Split raw text onlysplitChannelText()
Validate a whole portable payloadvalidateChannelMessage()
Validate portable buttonsvalidateChannelActions()
Validate portable outbound filesvalidateChannelAttachments()
Check whether an action ID is portableisChannelActionId()
Implement a new adapterChannel<RawEvent>

For a normal Discord, Slack, or Telegram application, create the channel with the platform factory (Discord, Slack, Telegram) and use only the shared types plus sendChannelMessage() from this package.

Addresses ​

A ChannelAddress identifies where output should go:

ts
import type { ChannelAddress } from '@anvia/channel'

const address: ChannelAddress = {
  platform: 'discord',
  accountId: '123456789012345678',
  conversationId: '234567890123456789',
  threadId: '345678901234567890',
}
  • platform must match the adapter.
  • accountId distinguishes two bot/application accounts on the same platform and is optional — copy it from the inbound event when replying; omit it for proactive delivery unless you address a second account.
  • conversationId is the channel, chat, or direct-message conversation.
  • threadId is the platform thread/topic identifier when present.

When replying to an incoming event, copy these fields from event.platform, event.accountId, and event.conversation instead of reconstructing platform IDs.

Continue with ​

Built for Anvia.