Getting Started
1. System requirements
Section titled “1. System requirements”Octoroom uses ex_webrtc, which requires the system libsrtp library:
brew install srtpapt install libsrtp2-devAdd this to your app’s config/config.exs so ex_libsrtp builds against your system libsrtp (the precompiled artifact links a libcrypto that isn’t on the default path):
config :bundlex, :disable_precompiled_os_deps, apps: [:ex_libsrtp]2. Add dependencies
Section titled “2. Add dependencies”Add :octoroom (and optionally :octoroom_agents if you want AI voice/vision participants) to mix.exs:
defp deps do [ {:octoroom, "~> 0.1.0"}, {:octoroom_agents, "~> 0.1.0"} # optional: AI voice & vision agents ]endThen fetch and compile:
mix deps.get3. Configure the SFU backend
Section titled “3. Configure the SFU backend”Local development (no Cloudflare account required)
Section titled “Local development (no Cloudflare account required)”Octoroom ships with Octoroom.Cloudflare.Local, an in-process localhost SFU backed by ex_webrtc. It lets you test multi-party audio, video, and workers locally with zero credentials:
config :octoroom, cloudflare: [client: Octoroom.Cloudflare.Local], ice_servers: []Production (Cloudflare Realtime SFU)
Section titled “Production (Cloudflare Realtime SFU)”In production, configure Octoroom.Cloudflare.HTTP (the default client) with your Cloudflare Realtime SFU app credentials:
config :octoroom, cloudflare: [ client: Octoroom.Cloudflare.HTTP, app_id: System.fetch_env!("CLOUDFLARE_SFU_APP_ID"), app_secret: System.fetch_env!("CLOUDFLARE_SFU_APP_SECRET") ]4. Define a Room and Phoenix Channel
Section titled “4. Define a Room and Phoenix Channel”A room is a module using Octoroom.Room. Only join/2 is required—subscriptions/2 defaults to subscribing every participant to every other participant’s mic, camera, screen share, and every worker output:
defmodule MyApp.CallRoom do use Octoroom.Room
@impl true def join(%{"name" => name}, _socket) do {:ok, %{name: name}} endendMount a Phoenix channel backed by your room:
defmodule MyAppWeb.RoomChannel do use Octoroom.Phoenix.Channel, room: MyApp.CallRoomendRegister it in your Phoenix UserSocket:
channel "room:*", MyAppWeb.RoomChannelThe room ID is everything after the first : in the topic—so "room:lobby" starts room "lobby", and "room:support:1234" starts room "support:1234".
5. Connect from the browser
Section titled “5. Connect from the browser”Octoroom includes a zero-npm ES module browser client at priv/static/octoroom.mjs:
import { RoomClient } from "octoroom";
const room = new RoomClient({ socket, // a connected Phoenix Socket topic: "room:lobby", params: { name: "Ada" }, video: true,});
room.on("participants", (list) => console.log("Participants:", list));room.on("tracks", (tracks) => { // Remote audio plays automatically; attach remote video tracks to <video> elements for (const track of tracks) { if (track.kind === "video") { videoEl.srcObject = track.stream; } }});
await room.join();Next steps
Section titled “Next steps”- Learn how the media and control planes fit together in Architecture.
- Customize audio routing, whisper tracks, and permissions in Rooms & Routing Policies.
- Add AI voice and vision participants in AI Voice & Vision Agents.