diff --git a/apps/livekit/.env.example b/apps/livekit/.env.example new file mode 100644 index 000000000..fe31a9d9b --- /dev/null +++ b/apps/livekit/.env.example @@ -0,0 +1,6 @@ +LIVEKIT_API_KEY=your_livekit_api_key +LIVEKIT_API_SECRET=your_livekit_api_secret +LIVEKIT_WS_URL=your_livekit_ws_url +OPENAI_API_KEY=your_openai_api_key +DEEPGRAM_API_KEY=your_deepgram_api_key +ELEVENLABS_API_KEY=your_elevenlabs_api_key \ No newline at end of file diff --git a/docs/images/livekit_keys.png b/docs/images/livekit_keys.png new file mode 100644 index 000000000..d22eae27b Binary files /dev/null and b/docs/images/livekit_keys.png differ diff --git a/docs/mint.json b/docs/mint.json index 36e5f60e5..6d661923a 100644 --- a/docs/mint.json +++ b/docs/mint.json @@ -65,6 +65,7 @@ "open-source/python-quickstart", "open-source/react-quickstart", "open-source/telephony", + "open-source/livekit-webrtc", "open-source/turn-based-conversation" ] }, diff --git a/docs/open-source/livekit-webrtc.mdx b/docs/open-source/livekit-webrtc.mdx new file mode 100644 index 000000000..d2409300f --- /dev/null +++ b/docs/open-source/livekit-webrtc.mdx @@ -0,0 +1,45 @@ +--- +title: "Using WebRTC with LiveKit" +description: "Deploy your Vocode Agents using WebRTC" +--- + +# Overview + +[WebRTC](https://webrtc.org/) is an alternative to websockets for real-time P2P communication. Vocode Agents are compatible with both WebRTC and websockets, enabling developers to pick +the stack best suited for their application. + +To connect Vocode agents to WebRTC, Vocode uses [LiveKit](https://livekit.io/)–an open source platform for building on WebRTC. For a background on how LiveKit +works, please see their [documentation](https://docs.livekit.io/home/get-started/intro-to-livekit/). + +In this guide, we'll be walking through how to connect a Vocode Agent to the [LiveKit Agents Playground](https://agents-playground.livekit.io/). + +# Walkthrough: hooking up a Vocode Agent to a LiveKit Room + +## Setting up your LiveKit Server + +First, you'll want to set up a LiveKit Server for your Agent. For simplicity, we are using LiveKit's hosted offering–but it can also be self hosted, since LiveKit is open source! + +In our LiveKit dashboard, we first generate our websocket URL, API key, and Secret Key. + +![Setup](/images/livekit_keys.png) + +## Deploying your Vocode agent to a LiveKit Room + +Once you have your LiveKit Server credentials, we can hook it up to Vocode via the `LiveKitConversation` abstraction. Using the starter code in +[vocode-core/apps/livekit/app.py](https://github.com/vocodedev/vocode-core/blob/main/apps/livekit/app.py), you can quickly deploy a Vocode Agent to accept +new job requests. + +Fill in your credentials in `.env`: + +```bash + +LIVEKIT_SERVER_URL=wss://your-livekit-ws-url.livekit.cloud +LIVEKIT_API_KEY="KEY" +LIVEKIT_API_SECRET="SECRET" +``` + +Followed by +`poetry run python app.py dev` + +And now you can connect to the [Agents Playground](https://agents-playground.livekit.io/) to interact with your agent. With LiveKit, you can connect Vocode +agents to any web application and leverage their [React Component](https://docs.livekit.io/reference/components/react/) library.