twilio-video
Video rooms: group/P2P, recording composition, track publication, network quality API, bandwidth
What this skill does
# twilio-video ## Purpose Enable OpenClaw to design, implement, operate, and troubleshoot Twilio Video in production: - Create and manage Video Rooms (Group and Peer-to-Peer), including lifecycle controls. - Issue Access Tokens with Video grants (identity, room scoping, TTL, key rotation). - Publish/subscribe tracks (audio/video/data), manage track priorities, and implement moderation (mute/unpublish/remove participants). - Enable and operate recording via Compositions (server-side recording outputs), including callbacks and storage pipelines. - Use Network Quality API and bandwidth profiles to maintain call quality under real-world network constraints. - Integrate Video with Twilio cluster patterns: webhooks, auth, rate limits, cost controls, and operational playbooks. This guide assumes you are building a multi-tenant, production WebRTC system with compliance, observability, and incident response requirements. --- ## Prerequisites ### Twilio account + credentials - Twilio Account SID (format `AC...`) - Twilio API Key SID (format `SK...`) and Secret - (Optional) Twilio Auth Token (format `...`) for legacy/basic auth; prefer API Key + Secret for server-to-server. - A Twilio Video-enabled project (default for most accounts). Create API Key: ```bash twilio api:core:keys:create --friendly-name "video-prod-key-2026-02" ``` ### Supported SDKs / libraries (pin versions) Server-side (token minting, REST API calls): - Node.js: `node >= 20.11.1` (LTS), npm `>= 10.2.4` - `[email protected]` (Twilio Node helper library) - `[email protected]` (if you implement custom JWT handling; Twilio helper can mint tokens) - Python: `python >= 3.11.7` - `twilio==9.4.1` - Go: `go >= 1.22.1` - `github.com/twilio/[email protected]` Client-side: - Twilio Video JS SDK: `[email protected]` - Browser support: latest Chrome/Edge, Firefox ESR, Safari 17+ (macOS/iOS constraints apply) - iOS: TwilioVideo iOS SDK `5.10.0` (CocoaPods/SPM) - Android: Twilio Video Android SDK `7.6.0` (Gradle) Twilio CLI: - `[email protected]` (Node-based) - Plugins: - `@twilio-labs/[email protected]` (Video commands; plugin availability varies—verify in your environment) Install Twilio CLI: ```bash npm i -g [email protected] twilio --version ``` Install plugin: ```bash twilio plugins:install @twilio-labs/[email protected] twilio plugins ``` ### Auth setup (local dev + CI) Prefer environment variables: - `TWILIO_ACCOUNT_SID` - `TWILIO_API_KEY` - `TWILIO_API_SECRET` - (Optional) `TWILIO_AUTH_TOKEN` (avoid in CI if possible) Example (bash): ```bash export TWILIO_ACCOUNT_SID="YOUR_ACCOUNT_SID" export TWILIO_API_KEY="YOUR_API_KEY_SID" export TWILIO_API_SECRET="your_api_secret_from_console" ``` Twilio CLI login (stores credentials locally; not recommended for CI runners): ```bash twilio login ``` ### Network + infra prerequisites - Public HTTPS endpoint for webhooks (Composition callbacks, Status callbacks). - TLS: modern ciphers; certificate from a trusted CA (Let’s Encrypt OK). - Time sync: NTP enabled on servers minting JWTs (clock skew breaks tokens). - TURN/STUN: Twilio provides; ensure outbound UDP/TCP 3478/5349 allowed; enterprise networks may require TCP/TLS fallback. --- ## Core Concepts ### Rooms: Group vs Peer-to-Peer (P2P) - **Group Room**: media routed via Twilio’s SFU; supports larger rooms, recording/compositions, bandwidth profiles, network quality, dominant speaker, etc. Default for most production use. - **Peer-to-Peer Room**: direct mesh between participants; limited scalability; fewer server-side features; generally not recommended for production beyond 1:1 with strict latency constraints. Key properties: - `type`: `group` | `group-small` | `peer-to-peer` (availability depends on account/region) - `status`: `in-progress` | `completed` - `maxParticipants`: enforce caps to control cost and quality ### Participants and Tracks - **Participant**: identity in a room (unique per room). - **Tracks**: - Audio track - Video track - Data track (reliable/unreliable messaging) - Track lifecycle: `published` → `subscribed` (remote) → `unpublished` / `stopped` - Server-side moderation often means: - Disconnect participant - Force unpublish (where supported) - Enforce client behavior via signaling + policy ### Access Tokens (JWT) Twilio Video uses JWT access tokens with a **VideoGrant**: - `identity`: stable user identifier (tenant-scoped) - `ttl`: seconds; keep short (e.g., 3600) and refresh - `room`: optional; restrict token to a specific room - Signed with API Key Secret Clock skew is a common failure mode; keep NTP. ### Recording via Compositions Twilio Video “recording” in production typically means **Compositions**: - A Composition is a server-side rendered output (e.g., MP4) created from recorded tracks. - You can configure: - Layout (grid, active speaker, custom) - Format - Status callback URL - You must handle asynchronous completion and storage (S3/GCS/Azure) yourself. ### Network Quality API - Provides per-participant network quality levels (0–5) and stats. - Use it to: - Adapt bitrate/resolution - Trigger UI warnings - Decide when to switch to audio-only - Combine with bandwidth profiles for predictable behavior. ### Bandwidth Profiles and Track Priority - Bandwidth profiles define how Twilio allocates bandwidth among tracks. - Track priority (`low`/`standard`/`high`) influences which tracks degrade first. - Use for: - Prioritizing presenter video - Keeping audio stable under congestion ### Webhooks and callbacks Common callback types: - Composition status callbacks - Room status callbacks (where configured) - Participant events (often handled client-side; server can poll REST API) Webhooks must be: - HTTPS - Verified (Twilio signature validation) - Idempotent (Twilio retries) --- ## Installation & Setup ### Official Python SDK — Video **Repository:** https://github.com/twilio/twilio-python **PyPI:** `pip install twilio` · **Supported:** Python 3.7–3.13 ```python from twilio.rest import Client from twilio.jwt.access_token import AccessToken from twilio.jwt.access_token.grants import VideoGrant client = Client() # Create a room room = client.video.v1.rooms.create( unique_name="DailyStandup", type="go" # or 'group' / 'peer-to-peer' ) print(room.sid) # Generate participant access token token = AccessToken( os.environ["TWILIO_ACCOUNT_SID"], os.environ["TWILIO_API_KEY"], os.environ["TWILIO_API_SECRET"], identity="alice" ) token.add_grant(VideoGrant(room="DailyStandup")) print(token.to_jwt()) ``` Source: [twilio/twilio-python — video](https://github.com/twilio/twilio-python/blob/main/twilio/rest/video/) ### Ubuntu 22.04 LTS (x86_64) ```bash sudo apt-get update sudo apt-get install -y ca-certificates curl gnupg jq curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - sudo apt-get install -y nodejs node -v npm -v sudo npm i -g [email protected] twilio --version twilio plugins:install @twilio-labs/[email protected] ``` ### Fedora 39/40 (x86_64) ```bash sudo dnf install -y nodejs npm jq node -v npm -v sudo npm i -g [email protected] twilio plugins:install @twilio-labs/[email protected] ``` ### macOS (Intel + Apple Silicon) Using Homebrew: ```bash brew install node@20 jq echo 'export PATH="/opt/homebrew/opt/node@20/bin:$PATH"' >> ~/.zshrc # Apple Silicon echo 'export PATH="/usr/local/opt/node@20/bin:$PATH"' >> ~/.zshrc # Intel source ~/.zshrc npm i -g [email protected] twilio plugins:install @twilio-labs/[email protected] ``` ### Windows 11 (PowerShell) Install Node.js 20 LTS from official installer or winget: ```powershell winget install OpenJS.NodeJS.LTS node -v npm -v npm i -g [email protected] twilio --version twilio plugins:install @twilio-labs/[email protected] ``` ### Server library setup (Node.js) ```bash mkdir -p video-service && cd video-service npm init -y npm i [email protected] [email protected] @fastify/[email protected] [email protected] npm i -D typescr
Related in Image & Video
watch
IncludedWatch a video (URL or local path). Downloads with yt-dlp, extracts auto-scaled frames with ffmpeg, pulls the transcript from captions (or Whisper API fallback), and hands the result to Claude so it can answer questions about what's in the video.
physical-ai-defect-image-generation
IncludedUse when the user wants to orchestrate defect image generation, run associated setup, or handle outputs on OSMO. The Day 0 path handles cold-start with USD-to-ROI, image-edit augmentation, and AnomalyGen to create initial PCBA datasets. The Day 1 path performs inference and labeling on real images. This skill helps with first-time asset setup, creation of finetuning checkpoints, and configuring deployment. Trigger keywords: defect image generation, dig workflow, dig pipeline, defect image detection workflow, aoi pipeline, aoi anomalygen, usd2roi anomalygen, day 0 pcba, day 1 pcba, day 1 real-photo alignment, day 1 manual roi, metal surface anomaly, glass defect, anomalygen finetune, setup_pcb, setup_metal, setup_glass, setup_pretrained, dig setup, dig datasets, dig pretrained checkpoint, dig image-edit endpoint.
accelint-react-best-practices
IncludedReact performance optimization and best practices. ALWAYS use this skill when working with any React code - writing components, hooks, JSX; refactoring; optimizing re-renders, memoization, state management; reviewing for performance; fixing hydration mismatches; debugging infinite re-renders, stale closures, input focus loss, animations restarting; preventing remounting; implementing transitions, lazy initialization, effect dependencies. Even simple React tasks benefit from these patterns. Covers React 19+ (useEffectEvent, Activity, ref props). Triggers - useEffect, useState, useMemo, useCallback, memo, inline components, nested components, components inside components, re-render, performance, hydration, SSR, Next.js, useDeferredValue, combined hooks.
elevenlabs-agents
IncludedBuild conversational AI voice agents with ElevenLabs Platform using React, JavaScript, React Native, or Swift SDKs. Configure agents, tools (client/server/MCP), RAG knowledge bases, multi-voice, and Scribe real-time STT. Use when: building voice chat interfaces, implementing AI phone agents with Twilio, configuring agent workflows or tools, adding RAG knowledge bases, testing with CLI "agents as code", or troubleshooting deprecated @11labs packages, Android audio cutoff, CSP violations, dynamic variables, or WebRTC config. Keywords: ElevenLabs Agents, ElevenLabs voice agents, AI voice agents, conversational AI, @elevenlabs/react, @elevenlabs/client, @elevenlabs/react-native, @elevenlabs/elevenlabs-js, @elevenlabs/agents-cli, elevenlabs SDK, voice AI, TTS, text-to-speech, ASR, speech recognition, turn-taking model, WebRTC voice, WebSocket voice, ElevenLabs conversation, agent system prompt, agent tools, agent knowledge base, RAG voice agents, multi-voice agents, pronunciation dictionary, voice speed control, elevenlabs scribe, @11labs deprecated, Android audio cutoff, CSP violation elevenlabs, dynamic variables elevenlabs, case-sensitive tool names, webhook authentication
humanizer
IncludedHumanize AI-generated text by detecting and removing patterns typical of LLM output. Rewrites text to sound natural, specific, and human. Uses 28 pattern detectors, 560+ AI vocabulary terms across 3 tiers, and statistical analysis (burstiness, type-token ratio, readability) for comprehensive detection. Use when asked to humanize text, de-AI writing, make content sound more natural/human, review writing for AI patterns, score text for AI detection, or improve AI-generated drafts. Covers content, language, style, communication, and filler categories.
generating-mermaid-diagrams
IncludedSalesforce architecture diagrams using Mermaid with ASCII fallback. Use this skill when generating text-based diagrams for Salesforce architecture, OAuth flows, ERDs, integration sequences, or Agentforce structure. TRIGGER when: user says "diagram", "visualize", "ERD", or asks for sequence diagrams, flowcharts, class diagrams, or architecture visualizations in Mermaid. DO NOT TRIGGER when: user wants PNG/SVG image output (use generating-visual-diagrams), or asks about non-Salesforce systems.