Guía de implementación
En esta guía
Quickstart Recipe Profile
This repo is a reusable quickstart sample for building browser voice-agent experiences with Agora Conversational AI Engine.
Recipe Role
- Role:
basequickstart recipe. - Target audience: developers bootstrapping a production-style Next.js voice agent app.
- Reuse model: clone, bind project, run, then customize prompt/pipeline/UI.
Recipe Scope
This base recipe provides a copyable browser voice-agent starter with:
- browser RTC audio and RTM event transport
- server-side token, invite, stop, and optional custom LLM routes
- default GeminiSTT → Gemini
gemini-3.6-flashLLM → Gemini TTS preview provider configuration using one Google key - pre-call, in-call, transcript, metrics, and connection-status UI
Baseline Implementation Guidance
This repository is the official Agora Next.js quickstart baseline for this recipe. Agents should use this repo's source and progressive disclosure docs as the starting point, then customize.
Do not recreate Agora ConvoAI integration from memory. Provider schemas, SDK builder fields, token behavior, and RTM event details can drift. For a new baseline implementation, follow L1/L2/from_scratch_bootstrap.md while copying verified patterns from this repo.
Extension Points
api.routes: add browser-facing routes underapp/api, with shared request/response types intypes/conversation.tswhen the client consumes them.prompts.system: editADA_PROMPTandGREETINGinapp/api/invite-agent/route.ts.pipeline.providers: adjust theGeminiSTT,Gemini, andGeminiTTSbuilder chain. The defaults reuseNEXT_GOOGLE_API_KEYand use the standardAgoraClient.ui.conversation: customizeQuickstartPreCallCard,QuickstartConversationLayout,QuickstartTranscriptPanel, andQuickstartPipelineMetrics.
Invariants
- Keep
RtcTokenBuilder.buildTokenWithRtmfor RTM-capable tokens. - Treat this repo as the official baseline; customize after preserving a working token, invite, RTC, RTM, and transcript flow.
- Preserve StrictMode
isReadyguard for join/mic initialization. - Preserve UID remap (
uid="0") andINTERRUPTEDmessage-list inclusion. - Keep documentation synchronized when workflows/contracts change.
Stable Contracts
GET /api/generate-agora-tokenreturns{ token, uid, channel }.POST /api/invite-agentaccepts{ requester_id, channel_name }and returns the agent id/state payload.POST /api/stop-conversationaccepts{ agent_id }, stops the retainedAgentSession, and treats a missing session as idempotent success.- Required env vars are
NEXT_PUBLIC_AGORA_APP_ID,NEXT_AGORA_APP_CERTIFICATE, andNEXT_GOOGLE_API_KEY; the Google key serves GeminiSTT and Gemini LLM. Managed Gemini TTS requires no additional credential. components/LandingPage.tsxowns pre-call bootstrap and RTM client lifecycle.components/ConversationComponent.tsxowns joined-session RTC/toolkit lifecycle.lib/conversation.tsowns transcript normalization helpers.
Internal / Subject to Change
- Visual styling and copy in the quickstart UI.
- The exact reseller defaults for STT, LLM, and TTS models.
- Connection issue display heuristics and metric chip presentation.
Consumer Onboarding Recipe
- Clone or scaffold from template.
- Bind Agora project and write
.env.local. - Run
pnpm run doctorandpnpm run dev. - Validate with
pnpm run verifybefore sharing modifications. - Customize agent behavior and UI using the supported surfaces above.
Metadatos de Recipe
| Campo | Valor |
|---|---|
recipe_version | 0.1.0 |
recipe_status | stable |
extension_points |
|
invariants |
|
stable_contracts |
|
---
recipe_version: 0.1.0
recipe_status: stable
extension_points:
- api.routes
- prompts.system
- pipeline.providers
- ui.conversation
invariants:
- baseline.official-sample
- tokens.rtc-rtm
- lifecycle.strict-mode
- transcript.uid-remap
stable_contracts:
- env.required
- api.token
- api.invite-agent
- api.stop-conversation
---
# Quickstart Recipe Profile
This repo is a reusable quickstart sample for building browser voice-agent experiences with Agora Conversational AI Engine.
## Recipe Role
- Role: `base` quickstart recipe.
- Target audience: developers bootstrapping a production-style Next.js voice agent app.
- Reuse model: clone, bind project, run, then customize prompt/pipeline/UI.
## Recipe Scope
This base recipe provides a copyable browser voice-agent starter with:
- browser RTC audio and RTM event transport
- server-side token, invite, stop, and optional custom LLM routes
- default GeminiSTT → Gemini `gemini-3.6-flash` LLM → Gemini TTS preview provider configuration using one Google key
- pre-call, in-call, transcript, metrics, and connection-status UI
## Baseline Implementation Guidance
This repository is the official Agora Next.js quickstart baseline for this recipe. Agents should use this repo's source and progressive disclosure docs as the starting point, then customize.
Do not recreate Agora ConvoAI integration from memory. Provider schemas, SDK builder fields, token behavior, and RTM event details can drift. For a new baseline implementation, follow [L1/L2/from_scratch_bootstrap.md](https://github.com/AgoraIO-Community/Gemini-Agora-Voice-Agents-NextJS/blob/main/docs/ai/L1/L2/from_scratch_bootstrap.md) while copying verified patterns from this repo.
## Extension Points
- `api.routes`: add browser-facing routes under `app/api`, with shared request/response types in `types/conversation.ts` when the client consumes them.
- `prompts.system`: edit `ADA_PROMPT` and `GREETING` in `app/api/invite-agent/route.ts`.
- `pipeline.providers`: adjust the `GeminiSTT`, `Gemini`, and `GeminiTTS` builder chain. The defaults reuse `NEXT_GOOGLE_API_KEY` and use the standard `AgoraClient`.
- `ui.conversation`: customize `QuickstartPreCallCard`, `QuickstartConversationLayout`, `QuickstartTranscriptPanel`, and `QuickstartPipelineMetrics`.
## Invariants
- Keep `RtcTokenBuilder.buildTokenWithRtm` for RTM-capable tokens.
- Treat this repo as the official baseline; customize after preserving a working token, invite, RTC, RTM, and transcript flow.
- Preserve StrictMode `isReady` guard for join/mic initialization.
- Preserve UID remap (`uid="0"`) and `INTERRUPTED` message-list inclusion.
- Keep documentation synchronized when workflows/contracts change.
## Stable Contracts
- `GET /api/generate-agora-token` returns `{ token, uid, channel }`.
- `POST /api/invite-agent` accepts `{ requester_id, channel_name }` and returns the agent id/state payload.
- `POST /api/stop-conversation` accepts `{ agent_id }`, stops the retained `AgentSession`, and treats a missing session as idempotent success.
- Required env vars are `NEXT_PUBLIC_AGORA_APP_ID`, `NEXT_AGORA_APP_CERTIFICATE`, and `NEXT_GOOGLE_API_KEY`; the Google key serves GeminiSTT and Gemini LLM. Managed Gemini TTS requires no additional credential.
- `components/LandingPage.tsx` owns pre-call bootstrap and RTM client lifecycle.
- `components/ConversationComponent.tsx` owns joined-session RTC/toolkit lifecycle.
- `lib/conversation.ts` owns transcript normalization helpers.
## Internal / Subject to Change
- Visual styling and copy in the quickstart UI.
- The exact reseller defaults for STT, LLM, and TTS models.
- Connection issue display heuristics and metric chip presentation.
## Consumer Onboarding Recipe
1. Clone or scaffold from template.
2. Bind Agora project and write `.env.local`.
3. Run `pnpm run doctor` and `pnpm run dev`.
4. Validate with `pnpm run verify` before sharing modifications.
5. Customize agent behavior and UI using the supported surfaces above.