Documentation
¶
Overview ¶
Package channels is the /v1/channels transport plane: the portable chat envelope, per-org access policy (pairing / allowlist / open), a durable inbox, and outbound send across the connected chat transports (Discord, Slack, Teams, Telegram). Identity and token custody stay in clients/integrations — channels consumes its ingress seam (integrations.RegisterIngress) and its send doors, so the dependency points one way: channels → integrations, never back.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Action ¶
type Action struct {
Kind ActionKind `json:"kind"`
Label string `json:"label,omitempty"`
Command string `json:"command,omitempty"`
URL string `json:"url,omitempty"`
Options []SelectOption `json:"options,omitempty"`
Approval *Approval `json:"approval,omitempty"`
}
Action is the kind-tagged closed union (command | url | select | approval); exactly the fields of its Kind are set — validate enforces per-kind exclusivity so a channel never has to guess from string shape.
type ActionKind ¶
type ActionKind string
ActionKind tags the closed Action union.
const ( ActionCommand ActionKind = "command" ActionURL ActionKind = "url" ActionSelect ActionKind = "select" ActionApproval ActionKind = "approval" )
type Approval ¶
type Approval struct {
ID string `json:"id"`
}
Approval names the approval request an approval action refers to.
type Attachment ¶
type Attachment struct {
Kind AttachmentKind `json:"kind"`
URL string `json:"url"`
MIME string `json:"mime,omitempty"`
}
Attachment is a URL-addressed media item.
type AttachmentKind ¶
type AttachmentKind string
AttachmentKind is the closed attachment media class.
const ( AttachmentImage AttachmentKind = "image" AttachmentAudio AttachmentKind = "audio" AttachmentVideo AttachmentKind = "video" AttachmentFile AttachmentKind = "file" )
type GroupPolicy ¶
type GroupPolicy string
GroupPolicy governs group (and thread) surfaces on a channel.
const ( GroupOpen GroupPolicy = "open" GroupAllowlist GroupPolicy = "allowlist" GroupDisabled GroupPolicy = "disabled" )
type Message ¶
type Message struct {
Channel string `json:"channel"`
Account string `json:"account,omitempty"`
Sender Sender `json:"sender"`
Room Room `json:"room"`
Text string `json:"text,omitempty"`
Attachments []Attachment `json:"attachments,omitempty"`
Actions []Action `json:"actions,omitempty"`
ReplyTo string `json:"replyTo,omitempty"`
Idempotency string `json:"idempotency,omitempty"`
}
Message is the normalized envelope. Account is informational — the lowercased external id of the org's connected platform account; the policy key is (org, channel) only.
type SelectOption ¶
SelectOption is one choice of a select action.
type SendRequest ¶
type SendRequest struct {
Room Room `json:"room"`
Text string `json:"text,omitempty"`
Attachments []Attachment `json:"attachments,omitempty"`
Actions []Action `json:"actions,omitempty"`
ReplyTo string `json:"replyTo,omitempty"`
Idempotency string `json:"idempotency,omitempty"`
}
SendRequest is the narrow body of POST /v1/channels/:channel/send — the envelope's outbound projection. Identity fields (Sender, Account, Channel) are not decodable here: the route path names the channel and the caller's authenticated org supplies the tenant.
type Sender ¶
type Sender struct {
ExternalID string `json:"externalId"`
Display string `json:"display,omitempty"`
UserID string `json:"userId,omitempty"`
Org string `json:"org,omitempty"`
}
Sender identifies who sent an inbound message. UserID is the bound Hanzo subject (integrations.LinkedSubject) and may be empty when the platform user has not linked. Org is filled on ingress and ignored on egress.