# Examples

> Runnable voice bots in the repository, over WebRTC, over a WebSocket, on the phone, on Cloudflare Durable Objects, and mounted in each major framework.

Source: https://polvallverdu.github.io/pipedog/docs/examples/



Each example is a complete project in the repository's
[`examples`](https://github.com/polvallverdu/pipedog/tree/main/examples) folder, with an end-to-end
test that runs it against mock provider APIs. Clone the repository and run `bun install` once, then
start any of them from the repository root.

| Example                                                                                                                   | Run it                                                                                                         | What it is                                                                                                                                                                                                                            |
| ------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`smallwebrtc-voice-bot`](https://github.com/polvallverdu/pipedog/tree/main/examples/smallwebrtc-voice-bot)               | `OPENAI_API_KEY=sk-... bun run --cwd examples/smallwebrtc-voice-bot start`                                     | A voice assistant in the browser over SmallWebRTC, with OpenAI or Google Gemini services.                                                                                                                                             |
| [`websocket-voice-bot`](https://github.com/polvallverdu/pipedog/tree/main/examples/websocket-voice-bot)                   | `OPENAI_API_KEY=sk-... bun run --cwd examples/websocket-voice-bot start`                                       | The same assistant over a WebSocket, with protobuf frames for `@pipecat-ai/websocket-transport`.                                                                                                                                      |
| [`twilio-phone-bot`](https://github.com/polvallverdu/pipedog/tree/main/examples/twilio-phone-bot)                         | `OPENAI_API_KEY=sk-... PUBLIC_URL=https://... bun run --cwd examples/twilio-phone-bot start` (or `start:deno`) | A phone bot on Twilio Media Streams: the TwiML webhook and the media WebSocket as one fetch handler, served with `serveFetch` on Bun or Node, or on Deno and Workers. See the [Twilio quickstart](https://polvallverdu.github.io/pipedog/docs/telephony/twilio-quickstart.md). |
| [`workers-durable-voice-agent`](https://github.com/polvallverdu/pipedog/tree/main/examples/workers-durable-voice-agent)   | `bun run --cwd examples/workers-durable-voice-agent dev`                                                       | Parallel voice agents on Cloudflare Workers, one Durable Object per session, over WebSocket.                                                                                                                                          |
| [`workers-realtime-voice-agent`](https://github.com/polvallverdu/pipedog/tree/main/examples/workers-realtime-voice-agent) | `bun run --cwd examples/workers-realtime-voice-agent deploy`                                                   | A browser voice agent over WebRTC on Cloudflare Workers: Cloudflare Realtime carries the audio, a Durable Object per call runs the bot.                                                                                               |
| [`landing-demo`](https://github.com/polvallverdu/pipedog/tree/main/examples/landing-demo)                                 | `bun run --cwd examples/landing-demo dev:fakes`                                                                | The live demo on the landing page: Workers AI Flux and Aura, Claude Haiku 5.5 with typed tools, Turnstile and a session budget, over WebSocket or WebRTC, with a SvelteKit page served by the same Worker.                            |
| [`framework-snippets`](https://github.com/polvallverdu/pipedog/tree/main/examples/framework-snippets)                     | `bun test examples/framework-snippets`                                                                         | The same voice endpoints mounted in Bun, Deno, Elysia, Express, Hono, Next.js, Nuxt, SvelteKit, TanStack Start and Vercel. See [Frameworks](https://polvallverdu.github.io/pipedog/docs/frameworks.md).                                                                        |

The mock provider APIs and the recorded question the tests use are in
[`test-mocks`](https://github.com/polvallverdu/pipedog/tree/main/examples/test-mocks). The tests
need no API keys; running an example against the real providers does.

The two browser bots serve their page on [http://localhost:7860](http://localhost:7860). Set
`VOICE_PROVIDER=google` and `GOOGLE_API_KEY` to use Gemini instead of OpenAI. The Workers example
reads `OPENAI_API_KEY` from `.dev.vars`; its README shows how to stream a recording to a session.

## WebRTC or WebSocket? [#webrtc-or-websocket]

The two browser bots are the same pipeline with a different transport. Pick by where your audio
comes from:

* **WebRTC** copes better with lossy networks: it runs over UDP, so a lost packet doesn't hold up
  the audio behind it. Browser users get lower latency, the browser's echo cancellation, and Opus
  compression. See the [voice bot guide](https://polvallverdu.github.io/pipedog/docs/voice-bot.md).
* **WebSocket** is simpler: no ICE or TURN servers, it passes through HTTP proxies and load
  balancers, and it runs on Cloudflare Workers, where WebRTC can't. It is also the way to go for
  server-to-server audio and phone bridges. See the [WebSocket transport](https://polvallverdu.github.io/pipedog/docs/transports/websocket.md).
