Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions agents/nextjs/guardrails/PROMPT.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Before writing any code, invoke the `/agents` skill to learn the correct ElevenL

## 1. `package.json`

- Add `@elevenlabs/react` (with `onGuardrailTriggered` support) and `elevenlabs` SDK dependencies.
- Add `@elevenlabs/react` (with `onGuardrailTriggered` support) and `@elevenlabs/elevenlabs-js` dependencies.

## 2. `app/api/agent/route.ts`

Expand All @@ -26,9 +26,12 @@ Never expose `ELEVENLABS_API_KEY` to the client.

Minimal Next.js voice guardrails demo page.

- Use `@elevenlabs/react` and `useConversation` with `onGuardrailTriggered`.
- Use `ConversationProvider` from `@elevenlabs/react`.
- Use the granular conversation hooks `useConversationControls`, `useConversationStatus`, and `useConversationMode`.
- Register `onGuardrailTriggered` on the provider.
- Show a `Create Agent` button and an editable agent-id input. Auto-populate on create; allow pasting a different id to load it instead.
- Start WebRTC sessions with a fresh token from `/api/conversation-token`. Request mic access before starting.
- Start voice sessions with a fresh token from `/api/conversation-token`. Request mic access before starting.
- Rely on the SDK's connection-type inference when starting the session; do not hardcode `connectionType: "webrtc"` unless there is a specific reason.
- Show a Start/Stop toggle, connection status, and running conversation transcript (append messages, don't replace).
- Surface example prompts for testing the guardrail (e.g., asking about investments or Bitcoin).
- If the guardrail triggers, show a persistent status message and append a note to the transcript.
Expand Down
Loading
Loading