# `Noizu.Comms`
[🔗](https://github.com/noizu-labs-sdks/elixir-comms/blob/main/lib/lib/noizu/comms.ex#L1)

Channel-agnostic outbound messaging (Discord, Slack, Telegram, WhatsApp).

One call surface, one policy model:

```
Noizu.Comms.send("ops-alerts", "deploy finished", level: :success)
Noizu.Comms.send("discord://channel/123456789012345678", "**hey**")
Noizu.Comms.broadcast(["ops-alerts", "releases"], "build ok")
```

Targets are URIs or named aliases resolved from a YAML targets file
(`COMMS_TARGETS_FILE`, default `~/.config/noizu-comms/targets.yaml`).
Each channel ships as an adapter with the channel SDK as an *optional*
dependency, so a service pulls in only the channels it uses.

Architecture (contract: `docs/arch/comms-channels.md`):

```
            agents (Claude Code, tobor crew)      services / hooks
                     │ MCP                              │ library call
     ┌───────────────┼──────────────────────┐           │
     │ comms-mcp (one tool surface)         │◄──────────┘ Noizu.Comms.send/3
     └───────────────┬──────────────────────┘
                     │ noizu_comms: Message · Target · Router · Policy
     ┌───────────┬───┴────────┬──────────────┬──────────────┐
     │ Discord   │ Slack      │ Telegram     │ WhatsApp     │  adapters
     ├───────────┼────────────┼──────────────┼──────────────┤
     │noizu_     │noizu_slack │noizu_telegram│noizu_whatsapp│  SDKs
     │discord    │            │              │              │
     └───────────┴────────────┴──────────────┴──────────────┘
```

# `broadcast`

```elixir
@spec broadcast(
  [Noizu.Comms.Target.t() | String.t()],
  Noizu.Comms.Message.t() | String.t(),
  keyword()
) ::
  [
    {Noizu.Comms.Target.t() | String.t(),
     {:ok, Noizu.Comms.Receipt.t()} | {:error, Noizu.Comms.Error.t()}}
  ]
```

Fans out to several targets concurrently (`Task.async_stream`).

Returns `[{target_or_alias, result}]` in input order, where `result` is the
same shape as `send/3`.

# `parse_target`

```elixir
@spec parse_target(String.t()) ::
  {:ok, Noizu.Comms.Target.t()} | {:error, Noizu.Comms.Error.t()}
```

Parses a target URI or alias into a `%Noizu.Comms.Target{}`.

# `send`

```elixir
@spec send(
  Noizu.Comms.Target.t() | String.t(),
  Noizu.Comms.Message.t() | String.t(),
  keyword()
) ::
  {:ok, Noizu.Comms.Receipt.t()} | {:error, Noizu.Comms.Error.t()}
```

Sends `message_or_text` (a `%Noizu.Comms.Message{}` or a text binary) to
`target_or_alias`.

Target forms: full URIs (`discord://channel/<snowflake>`,
`discord://webhook/<alias>`, `slack://channel/<id>`, `slack://webhook/<alias>`,
`telegram://chat/<id-or-@username>`, `whatsapp://<E.164>`), a bare config
alias (`ops-alerts`), or a `%Noizu.Comms.Target{}`.

Options are merged into the message (`:title`, `:fields`, `:level`,
`:attachments`, `:reply_to`, `:thread`, `:silent`, `:format`,
`:idempotency_key`, `:metadata`) and forwarded to the adapter
(`:req_options`, `:retry`, `:client`).

Returns `{:ok, %Noizu.Comms.Receipt{}}` or
`{:error, %Noizu.Comms.Error{}}`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
