dsh-agora 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +88 -0
- package/assets/agora/SKILL.md +113 -0
- package/assets/agora/references/cli/README.md +161 -0
- package/assets/agora/references/cli/automation.md +189 -0
- package/assets/agora/references/cli/doctor.md +129 -0
- package/assets/agora/references/cli/env.md +158 -0
- package/assets/agora/references/cli/install-auth.md +152 -0
- package/assets/agora/references/cli/projects.md +116 -0
- package/assets/agora/references/cli/quickstarts.md +117 -0
- package/assets/agora/references/cloud-recording/README.md +86 -0
- package/assets/agora/references/conversational-ai/README.md +285 -0
- package/assets/agora/references/conversational-ai/agent-client-toolkit-react.md +182 -0
- package/assets/agora/references/conversational-ai/agent-samples.md +101 -0
- package/assets/agora/references/conversational-ai/agent-toolkit-android.md +209 -0
- package/assets/agora/references/conversational-ai/agent-toolkit-ios.md +208 -0
- package/assets/agora/references/conversational-ai/agent-toolkit.md +201 -0
- package/assets/agora/references/conversational-ai/agent-ui-kit.md +63 -0
- package/assets/agora/references/conversational-ai/architecture.md +221 -0
- package/assets/agora/references/conversational-ai/auth-flow.md +154 -0
- package/assets/agora/references/conversational-ai/conversational-ai-studio.md +173 -0
- package/assets/agora/references/conversational-ai/go-sdk.md +184 -0
- package/assets/agora/references/conversational-ai/integration-from-quickstart.md +203 -0
- package/assets/agora/references/conversational-ai/python-sdk.md +122 -0
- package/assets/agora/references/conversational-ai/quickstarts.md +710 -0
- package/assets/agora/references/conversational-ai/server-custom-llm.md +45 -0
- package/assets/agora/references/conversational-ai/server-mcp.md +40 -0
- package/assets/agora/references/conversational-ai/server-sdk-rename.md +78 -0
- package/assets/agora/references/conversational-ai/server-sdks.md +128 -0
- package/assets/agora/references/doc-fetching.md +67 -0
- package/assets/agora/references/integration-patterns.md +201 -0
- package/assets/agora/references/mcp-tools.md +49 -0
- package/assets/agora/references/rtc/README.md +104 -0
- package/assets/agora/references/rtc/android.md +344 -0
- package/assets/agora/references/rtc/cross-platform-coordination.md +61 -0
- package/assets/agora/references/rtc/flutter.md +282 -0
- package/assets/agora/references/rtc/ios.md +306 -0
- package/assets/agora/references/rtc/nextjs.md +87 -0
- package/assets/agora/references/rtc/react-native.md +266 -0
- package/assets/agora/references/rtc/react.md +186 -0
- package/assets/agora/references/rtc/web.md +506 -0
- package/assets/agora/references/rtm/README.md +80 -0
- package/assets/agora/references/rtm/android.md +277 -0
- package/assets/agora/references/rtm/ios.md +231 -0
- package/assets/agora/references/rtm/web.md +348 -0
- package/assets/agora/references/server/README.md +22 -0
- package/assets/agora/references/server/tokens.md +74 -0
- package/assets/agora/references/server-gateway/README.md +80 -0
- package/assets/agora/references/server-gateway/linux-cpp.md +251 -0
- package/assets/agora/references/testing-guidance/SKILL.md +65 -0
- package/assets/agora/references/testing-guidance/completeness-gate.md +28 -0
- package/assets/agora/references/testing-guidance/convoai-rest.md +83 -0
- package/assets/agora/references/testing-guidance/mobile-rtm-and-renewal.md +109 -0
- package/assets/agora/references/testing-guidance/rtc-android.md +70 -0
- package/assets/agora/references/testing-guidance/rtc-ios.md +73 -0
- package/assets/agora/references/testing-guidance/rtc-react.md +51 -0
- package/assets/agora/references/testing-guidance/rtc-web.md +94 -0
- package/cordis.patch.yml +5 -0
- package/index.js +53 -0
- package/package.json +49 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Agora Cloud Recording
|
|
2
|
+
|
|
3
|
+
Server-side recording of RTC channel audio/video. REST API only — no client SDK needed.
|
|
4
|
+
|
|
5
|
+
## Quick Reference
|
|
6
|
+
|
|
7
|
+
| Item | Value |
|
|
8
|
+
|------|-------|
|
|
9
|
+
| What it does | Records RTC channel audio/video to cloud storage |
|
|
10
|
+
| Interface | REST API only — no client SDK needed |
|
|
11
|
+
| Auth | HTTP Basic Auth (`AGORA_CUSTOMER_KEY:AGORA_CUSTOMER_SECRET`) |
|
|
12
|
+
| Prerequisite | Cloud Recording enabled in Agora Console |
|
|
13
|
+
| Depends on | Active RTC channel with participants |
|
|
14
|
+
| Full REST API reference | <https://docs-md.agora.io/en/cloud-recording/reference/restful-api.md> |
|
|
15
|
+
|
|
16
|
+
## Recording Lifecycle
|
|
17
|
+
|
|
18
|
+
```text
|
|
19
|
+
acquire → start → [query] → stop
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**TTL gotcha:** `resourceId` expires 5 minutes after `acquire` — you must call `start` within that window.
|
|
23
|
+
|
|
24
|
+
### Step 1: Acquire Resource
|
|
25
|
+
|
|
26
|
+
```text
|
|
27
|
+
POST /v1/apps/{appId}/cloud_recording/acquire
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Returns a `resourceId`. Valid for 5 minutes — call `start` immediately.
|
|
31
|
+
|
|
32
|
+
### Step 2: Start Recording
|
|
33
|
+
|
|
34
|
+
```text
|
|
35
|
+
POST /v1/apps/{appId}/cloud_recording/resourceid/{resourceId}/mode/{mode}/start
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Choose a recording mode (see Recording Modes below). Returns a `sid` (session ID).
|
|
39
|
+
|
|
40
|
+
### Step 3: Query Status (optional)
|
|
41
|
+
|
|
42
|
+
```text
|
|
43
|
+
GET /v1/apps/{appId}/cloud_recording/resourceid/{resourceId}/sid/{sid}/mode/{mode}/query
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Use to check recording status or verify the session is active.
|
|
47
|
+
|
|
48
|
+
### Step 4: Stop Recording
|
|
49
|
+
|
|
50
|
+
```text
|
|
51
|
+
POST /v1/apps/{appId}/cloud_recording/resourceid/{resourceId}/sid/{sid}/mode/{mode}/stop
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Always call `stop` when recording is no longer needed to avoid unnecessary billing.
|
|
55
|
+
|
|
56
|
+
## Recording Modes
|
|
57
|
+
|
|
58
|
+
| Mode | Output | Use case |
|
|
59
|
+
|------|--------|----------|
|
|
60
|
+
| `individual` | Separate audio/video file per user | Post-processing, transcription |
|
|
61
|
+
| `mix` | Single mixed audio/video file | Archival, playback |
|
|
62
|
+
| `web` | Records a web page as video | Web app recording, whiteboard |
|
|
63
|
+
|
|
64
|
+
## Error Handling
|
|
65
|
+
|
|
66
|
+
| Error | Cause | Fix |
|
|
67
|
+
|-------|-------|-----|
|
|
68
|
+
| 403 | Cloud Recording not enabled in Console | Enable in Agora Console |
|
|
69
|
+
| 404 | Resource expired or invalid sid | Re-acquire resource; check sid |
|
|
70
|
+
| 432 | Recording already in progress | Query existing recording first |
|
|
71
|
+
| 435 | No users in channel | Ensure RTC channel has active participants before starting |
|
|
72
|
+
| Storage error | Wrong storage config | Verify bucket name, access keys, region |
|
|
73
|
+
|
|
74
|
+
## Auth Pattern
|
|
75
|
+
|
|
76
|
+
Same as all Agora REST APIs — HTTP Basic Auth:
|
|
77
|
+
|
|
78
|
+
```text
|
|
79
|
+
Authorization: Basic base64("{AGORA_CUSTOMER_KEY}:{AGORA_CUSTOMER_SECRET}")
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Credentials must come from environment variables — never hardcoded.
|
|
83
|
+
|
|
84
|
+
## When to Fetch More
|
|
85
|
+
|
|
86
|
+
Always use Level 2 fetch for: full REST API field details, storage config options (S3/OSS/GCS), composite layout parameters, error code listings. Fetch directly: <https://docs-md.agora.io/en/cloud-recording/reference/restful-api.md>
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
# Agora Conversational AI Engine
|
|
2
|
+
|
|
3
|
+
REST API-driven voice AI agents. Create agents that join RTC channels and converse with users via speech. Front-end clients connect via RTC+RTM.
|
|
4
|
+
|
|
5
|
+
> **HARD GATE:** If the user does not have a working ConvoAI baseline, route to [quickstarts.md](quickstarts.md) and use the official quickstart as the source of truth. Do not generate code from memory, scaffold a replacement project, or invent custom architecture. Runtime proof validates the user's environment and Agora project before declaring success.
|
|
6
|
+
|
|
7
|
+
> **OFFICIAL SOURCE FIRST:** When the user wants to try ConvoAI, build a demo, or prototype a voice AI agent, always clone or inspect the official sample repo first. Use its source files and documented startup commands for the first-success path. Do not replace the flow with a self-built implementation. Do not use web search for Agora integration details — use only the skill reference files.
|
|
8
|
+
|
|
9
|
+
> **POLICY CHECK:** Generating `package.json`, backend routes, UI/client code, SDK implementation files, or `/join` payloads from memory before inspecting the official quickstart source is a policy violation. In user-visible replies, explain this in plain language: "I need to pull this from the official quickstart first, then adapt it to your app."
|
|
10
|
+
|
|
11
|
+
## Routing: Classify the Request
|
|
12
|
+
|
|
13
|
+
The key question: does the user already have a **working ConvoAI baseline**?
|
|
14
|
+
|
|
15
|
+
- **Working baseline** = an Agora ConvoAI agent has already been started successfully end to end, and the client can join the same RTC channel and interact with it.
|
|
16
|
+
- **Not a working baseline** = only RTC code exists, a sample repo is cloned but not proven, env vars are present, or the user only knows the target backend language.
|
|
17
|
+
|
|
18
|
+
| Mode | When | Route to |
|
|
19
|
+
|---|---|---|
|
|
20
|
+
| `quickstart` | New project, first demo, wants the official baseline, or has a cloned sample that is not proven end to end | [quickstarts.md](quickstarts.md) |
|
|
21
|
+
| `integration` | Has an existing application or multi-project workspace and wants ConvoAI added | [quickstarts.md](quickstarts.md) to clone/inspect the official source, then [integration-from-quickstart.md](integration-from-quickstart.md) for app integration |
|
|
22
|
+
| `backend-implementation` | Working baseline confirmed, now needs server code or lifecycle/auth changes | [server-sdks.md](server-sdks.md), [python-sdk.md](python-sdk.md), [go-sdk.md](go-sdk.md), or [auth-flow.md](auth-flow.md) |
|
|
23
|
+
| `server-sdk-rename` | Existing project uses outdated server SDK package/module names, or user asks to migrate | [server-sdk-rename.md](server-sdk-rename.md) |
|
|
24
|
+
| `client-customization` | Working baseline confirmed, now needs transcripts, hooks, UI, or mobile client work | [agent-toolkit.md](agent-toolkit.md), [agent-client-toolkit-react.md](agent-client-toolkit-react.md), [agent-ui-kit.md](agent-ui-kit.md), [agent-toolkit-ios.md](agent-toolkit-ios.md), [agent-toolkit-android.md](agent-toolkit-android.md) |
|
|
25
|
+
| `studio-agent` | The user already has an Agora Studio Agent ID and wants to reuse that Studio-managed agent config | [quickstarts.md](quickstarts.md), then [conversational-ai-studio.md](conversational-ai-studio.md) |
|
|
26
|
+
| `advanced-feature` / `debugging` / `ops-hardening` | Working baseline confirmed, wants custom LLM, memory, webhooks, production hardening, or error diagnosis | Start in this file, then route to the relevant reference below |
|
|
27
|
+
| `architecture` / `call sequence` / `how does ConvoAI work` | Needs system overview, init order, token roles, or start/stop lifecycle before implementation | [architecture.md](architecture.md) |
|
|
28
|
+
|
|
29
|
+
### Routing Rules
|
|
30
|
+
|
|
31
|
+
- If the user does **not** have a working baseline yet, read only this file and [quickstarts.md](quickstarts.md).
|
|
32
|
+
- While quickstart is unresolved, do **not** generate `/join` payloads, propose a custom project structure, or jump straight into SDK code.
|
|
33
|
+
- Existing RTC code, a checked-out repo, or a cloned quickstart is not enough to skip quickstart; the ConvoAI path must already work once.
|
|
34
|
+
- If the user has an existing app, classify the request as `integration`: first clone or inspect the official quickstart as source, then use [integration-from-quickstart.md](integration-from-quickstart.md) to detect the app shape, produce a copy map, and adapt only the needed pieces. Runtime proof should happen before declaring the integration works, but the reason for the quickstart is source alignment, not proving Agora's sample exists.
|
|
35
|
+
- Before generating server SDK install or import changes in an existing codebase, scan dependency manifests and import strings. If outdated server SDK names are present, load [server-sdk-rename.md](server-sdk-rename.md) first, apply the rename map, then continue in [server-sdks.md](server-sdks.md) / [python-sdk.md](python-sdk.md) / [go-sdk.md](go-sdk.md).
|
|
36
|
+
- For `integration`, detect first and ask last: use session memory, then read-only workspace detection, then one focused question only if required. Do not re-ask for values the user already provided.
|
|
37
|
+
- Follow the silent-by-default response contract and recovery rule from [../../SKILL.md](../../SKILL.md) and [quickstarts.md](quickstarts.md): check the baseline gate internally on every actionable reply, but show user-facing state only on first reply, gate flips, blocked actions, or status requests.
|
|
38
|
+
- If the user explicitly says the baseline already works, skip quickstart and route directly to the relevant implementation file.
|
|
39
|
+
- If the user explicitly says they already have an **Agora Studio Agent ID** from `https://console.agora.io/studio/agents`, treat that as a dedicated ConvoAI path rather than re-running the provider-choice flow.
|
|
40
|
+
- If the user needs Java, Ruby, PHP, C#, or another non-SDK backend language, use [auth-flow.md](auth-flow.md) after the quickstart path is chosen.
|
|
41
|
+
- If the user asks to use the CLI to speed up ConvoAI onboarding, keep the request in the ConvoAI path first. Use the CLI as an onboarding helper for login, project binding, official quickstart cloning, env writing, feature readiness, and `project doctor`, then continue the ConvoAI quickstart.
|
|
42
|
+
- For the first-success gate, treat the sample README commands as exact. If a documented command fails because of sandbox, permission, port-binding, filesystem, or network restrictions, re-run the exact documented command with escalation if available. Do not add flags, host overrides, alternate entrypoints, or equivalent replacement commands.
|
|
43
|
+
- When starting from scratch in the official quickstart, it is allowed and expected to update the agent's prompt, greeting, persona, scenario details, or documented join/config fields to match the user's requested agent. Keep the sample architecture, env names, token flow, lifecycle, and documented commands intact.
|
|
44
|
+
|
|
45
|
+
## Fast Onboarding With Agora CLI
|
|
46
|
+
|
|
47
|
+
For `quickstart` and `integration` mode, the fastest first-mile path is often:
|
|
48
|
+
|
|
49
|
+
0. run **[CLI readiness](../cli/README.md#cli-readiness-agents)** — version gate, upgrade if below `0.1.7`, confirm PATH before any mutating CLI command
|
|
50
|
+
1. use `agora init <name> --template <template> --json` for a new official quickstart, or `agora quickstart env write` to bind an existing official quickstart
|
|
51
|
+
2. use the Agora CLI to verify login, current project, `convoai` feature readiness, and other basic project checks such as App ID/App Certificate presence
|
|
52
|
+
3. run `project doctor` to catch missing setup early
|
|
53
|
+
4. then run the official sample's documented startup commands until the agent joins a real RTC channel and completes one end-to-end conversation
|
|
54
|
+
|
|
55
|
+
Use the CLI references as the source of truth for command details:
|
|
56
|
+
|
|
57
|
+
- [../cli/README.md](../cli/README.md)
|
|
58
|
+
- [../cli/quickstarts.md](../cli/quickstarts.md)
|
|
59
|
+
- [../cli/env.md](../cli/env.md)
|
|
60
|
+
- [../cli/projects.md](../cli/projects.md)
|
|
61
|
+
- [../cli/doctor.md](../cli/doctor.md)
|
|
62
|
+
|
|
63
|
+
Important:
|
|
64
|
+
|
|
65
|
+
- a healthy CLI readiness check does **not** replace a working ConvoAI baseline
|
|
66
|
+
- the CLI can help clone or bind an official quickstart, verify login, project context, feature readiness, App Certificate presence, and basic project config, but it does **not** by itself prove RTM runtime availability or sample-ready status
|
|
67
|
+
- for the full combined onboarding flow, use the matching path in [quickstarts.md](quickstarts.md) once the baseline path is clear
|
|
68
|
+
|
|
69
|
+
## SDK vs. Direct REST API
|
|
70
|
+
|
|
71
|
+
**Default to the SDK for the user's backend language.** The TypeScript, Go, and Python SDKs wrap the REST API and handle auth, token generation, and session lifecycle automatically.
|
|
72
|
+
|
|
73
|
+
| Backend language | Path |
|
|
74
|
+
|---|---|
|
|
75
|
+
| TypeScript / Node.js | `agora-agents` — see [server-sdks.md](server-sdks.md) |
|
|
76
|
+
| Python | `agora-agents` (import `agora_agent`) — see [python-sdk.md](python-sdk.md) |
|
|
77
|
+
| Go | `github.com/AgoraIO/agora-agents-go` — see [go-sdk.md](go-sdk.md) |
|
|
78
|
+
| Java, Ruby, PHP, C#, other | Call the REST API directly — see [auth-flow.md](auth-flow.md) |
|
|
79
|
+
|
|
80
|
+
Direct REST API use is fully supported for languages without an SDK. The [auth-flow.md](auth-flow.md) file covers the end-to-end auth and token flow for REST API implementors. If the user has an SDK available, start with that instead — the SDK eliminates the need to manually build tokens for the ConvoAI server.
|
|
81
|
+
The live OpenAPI spec is the authoritative source for request/response schemas:
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
GET https://docs-md.agora.io/api/conversational-ai-api-v2.x.yaml
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Architecture
|
|
88
|
+
|
|
89
|
+
For system components, call sequence, initialization order, token roles, agent lifecycle, and stop/cleanup flow, read **[architecture.md](architecture.md)** first.
|
|
90
|
+
|
|
91
|
+
Quick overview:
|
|
92
|
+
|
|
93
|
+
```text
|
|
94
|
+
Your Server (REST API calls)
|
|
95
|
+
↓ POST /join with config
|
|
96
|
+
Agora ConvoAI Engine
|
|
97
|
+
↓ creates agent
|
|
98
|
+
Agent joins RTC channel ←→ Front-end client (RTC + RTM)
|
|
99
|
+
↓ ↓
|
|
100
|
+
ASR → LLM → TTS Receives audio + transcripts
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Cross-product RTC + RTM coordination: [../integration-patterns.md](../integration-patterns.md).
|
|
104
|
+
|
|
105
|
+
## Documentation Lookup
|
|
106
|
+
|
|
107
|
+
The bundled references in this file cover gotchas, generation rules, and the stable
|
|
108
|
+
behavioral contracts. Read the relevant local ConvoAI reference first, then use Level 2 only
|
|
109
|
+
if the local file does not cover the detail needed.
|
|
110
|
+
|
|
111
|
+
For vendor/provider questions, use the official current provider docs as the source of truth
|
|
112
|
+
once the question moves beyond the default quickstart combo. The bundled quickstart references
|
|
113
|
+
are still the right source for the first-success default path, but the current provider matrix,
|
|
114
|
+
vendor availability, beta status, and vendor-specific configs should come from live docs.
|
|
115
|
+
|
|
116
|
+
For content that still needs live docs after the local check, use Level 2:
|
|
117
|
+
|
|
118
|
+
1. Fetch `https://docs.agora.io/en/llms.txt`
|
|
119
|
+
2. Scan for a URL matching your topic (e.g., `conversational-ai`, `quick-start`, `rest-api`)
|
|
120
|
+
3. Fetch that URL
|
|
121
|
+
|
|
122
|
+
Common topics to fetch via Level 2 after the local reference check: quick-start code (Python, Go, Java), provider matrices, vendor-specific configs, full request/response schemas, newly changed vendor configs, error code listings.
|
|
123
|
+
|
|
124
|
+
For full request/response schemas, fetch the OpenAPI spec directly — it is always
|
|
125
|
+
current and covers every endpoint and field:
|
|
126
|
+
`https://docs-md.agora.io/api/conversational-ai-api-v2.x.yaml`
|
|
127
|
+
|
|
128
|
+
See [../doc-fetching.md](../doc-fetching.md) for the full procedure.
|
|
129
|
+
|
|
130
|
+
## Authentication (Direct REST API)
|
|
131
|
+
|
|
132
|
+
This section covers auth for implementors calling the REST API directly (non-SDK languages). **If the user has a TypeScript/Python/Go SDK available, skip this — the SDK handles auth automatically in App Credentials mode.** See [server-sdks.md](server-sdks.md) instead.
|
|
133
|
+
|
|
134
|
+
Two methods are supported for direct REST API calls. **Token-based auth is preferred** — it avoids storing long-lived Customer Secret credentials on your server.
|
|
135
|
+
|
|
136
|
+
### Option A: Agora Token (recommended)
|
|
137
|
+
|
|
138
|
+
Use a combined RTC + RTM token generated with `RtcTokenBuilder.buildTokenWithRtm` from the [`agora-token`](https://www.npmjs.com/package/agora-token) npm package:
|
|
139
|
+
|
|
140
|
+
```javascript
|
|
141
|
+
import { RtcTokenBuilder, RtcRole } from 'agora-token';
|
|
142
|
+
|
|
143
|
+
const token = RtcTokenBuilder.buildTokenWithRtm(
|
|
144
|
+
appId, appCertificate, channelName, account, RtcRole.PUBLISHER,
|
|
145
|
+
tokenExpire, privilegeExpire
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
const response = await fetch(
|
|
149
|
+
`${baseUrl}/${appId}/join`,
|
|
150
|
+
{
|
|
151
|
+
method: 'POST',
|
|
152
|
+
headers: {
|
|
153
|
+
'Content-Type': 'application/json',
|
|
154
|
+
Authorization: `agora token=${token}`,
|
|
155
|
+
},
|
|
156
|
+
body: JSON.stringify(requestBody),
|
|
157
|
+
}
|
|
158
|
+
);
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
> **Rule:** Use token auth (`Authorization: agora token=<RTC+RTM token>`) as the default for new direct REST implementations. Basic Auth remains available, but grants broader account-level access.
|
|
162
|
+
|
|
163
|
+
See [../server/tokens.md](../server/tokens.md) for `buildTokenWithRtm` parameter reference.
|
|
164
|
+
|
|
165
|
+
### Option B: HTTP Basic Auth (Customer ID + Secret)
|
|
166
|
+
|
|
167
|
+
- Credentials: Customer ID + Customer Secret from [Agora Console](https://console.agora.io) → Developer Toolkit → RESTful API
|
|
168
|
+
- Header: `Authorization: Basic <base64(customerID:customerSecret)>`
|
|
169
|
+
- HTTPS required (TLS 1.0/1.1/1.2)
|
|
170
|
+
|
|
171
|
+
## Base URL
|
|
172
|
+
|
|
173
|
+
```text
|
|
174
|
+
https://api.agora.io/api/conversational-ai-agent/v2/projects/{appid}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Agent Lifecycle
|
|
178
|
+
|
|
179
|
+
| Status | Code | Description |
|
|
180
|
+
| ---------- | ---- | -------------------------- |
|
|
181
|
+
| IDLE | 0 | Ready, not active |
|
|
182
|
+
| STARTING | 1 | Initialization in progress |
|
|
183
|
+
| RUNNING | 2 | Active, processing audio |
|
|
184
|
+
| STOPPING | 3 | Shutdown in progress |
|
|
185
|
+
| STOPPED | 4 | Exited channel |
|
|
186
|
+
| RECOVERING | 5 | Error recovery |
|
|
187
|
+
| FAILED | 6 | Execution failure |
|
|
188
|
+
|
|
189
|
+
## Gotchas & Quirks
|
|
190
|
+
|
|
191
|
+
Things the official docs don't emphasize that cause frequent mistakes:
|
|
192
|
+
|
|
193
|
+
- **`agent_rtc_uid` is a string, not an int** — pass `"0"` (string) for auto-assignment, not `0`. Passing an integer will cause a type error at the API boundary.
|
|
194
|
+
- **`remote_rtc_uids` is an array of strings** — use `["*"]` to subscribe to all users, not `"*"` or `["0"]`. The wildcard must be in array form.
|
|
195
|
+
- **Agent name must be unique per project** — collisions return HTTP 409. Use a short UUID suffix: `agent_{uuid[:8]}`. On 409, generate a new name and retry; do not retry with the same name.
|
|
196
|
+
- **Use token auth as the default for new direct REST integrations.** The ConvoAI REST API accepts `Authorization: agora token=<token>` using a combined RTC + RTM token from `RtcTokenBuilder.buildTokenWithRtm`. This is **safer than Basic Auth**: tokens are scoped to a single App ID + channel, while Customer ID/Secret grants access to every project on the account. Use Basic Auth only when a user explicitly needs that mode.
|
|
197
|
+
- **POST `/join` success does not mean the agent is already in the RTC channel** — the request was accepted and the agent is starting. The client should wait for the RTC `user-joined` event before expecting agent audio or querying media state.
|
|
198
|
+
- **`/update` overwrites `params` entirely** — sending `{ "llm": { "params": { "max_tokens": 2048 } } }` erases `model` and everything else in `params`. Always send the full object.
|
|
199
|
+
- **Agora Studio Agent ID is not the same thing as the runtime `agent_id` returned by `/join`** — the Studio Agent ID comes from the Studio Agents page and identifies a Studio-managed agent configuration. In the Studio-managed start path, that value maps to the request field `pipeline_id`. The runtime `agent_id` identifies a started live session returned by the REST API. Do not use one in place of the other.
|
|
200
|
+
- **`/speak` priority enum** — `"INTERRUPT"` (immediate, default), `"APPEND"` (queued after current speech), `"IGNORE"` (skip if agent is busy). `interruptable: false` prevents users from cutting in.
|
|
201
|
+
- **20 PCU default limit** — max 20 concurrent agents per App ID. Exceeding returns error on `/join`. Contact Agora support to increase.
|
|
202
|
+
- **Event notifications require two flags** — `advanced_features.enable_rtm: true` AND `parameters.data_channel: "rtm"` in the join config. Without both, `onAgentStateChanged`/`onAgentMetrics`/`onAgentError` won't fire. Additionally: `parameters.enable_metrics: true` for metrics, `parameters.enable_error_message: true` for errors.
|
|
203
|
+
- **RTM channel name matches the RTC channel name** — the agent publishes transcripts and state events to the RTM channel with the same name as the RTC channel it joined. Subscribe the RTM client to the same channel name you passed to the agent's `properties.channel`.
|
|
204
|
+
- **RTM login identity must match the RTM token subject** — if the RTM token was minted for `String(rtcUid)`, the RTM client must log in with that same identity. Do not mint a token for one user identity and then log in RTM with another random user ID; this can surface as generic startup failures such as "Failed to start conversation".
|
|
205
|
+
- **RTM enablement can lag behind control-plane state** — after enabling RTM or related project capabilities, CLI/control-plane checks may report the feature as enabled before the RTM service is actually usable. For first-success flows, treat RTM availability as a bounded wait/retry condition for up to about 5 minutes before concluding the project still needs intervention.
|
|
206
|
+
- **Custom LLM interruptable metadata** — the first SSE chunk can be `{"object": "chat.completion.custom_metadata", "metadata": {"interruptable": false}}` to prevent user speech from interrupting critical responses (e.g., compliance disclaimers). Subsequent chunks use standard `chat.completion.chunk` format.
|
|
207
|
+
- **Error response format** — non-200 responses return `{ "detail": "...", "reason": "..." }`.
|
|
208
|
+
- **MLLM `location` not `region`** — use `params.location: "us-central1"`, not `region`. The field name is `location` at every level (join payload and backend env vars).
|
|
209
|
+
|
|
210
|
+
For test setup and mocking patterns, see [references/testing-guidance/SKILL.md](../testing-guidance/SKILL.md).
|
|
211
|
+
|
|
212
|
+
## REST API Endpoints
|
|
213
|
+
|
|
214
|
+
| Method | Path | Description |
|
|
215
|
+
| ------ | ----------------------------- | -------------------------------- |
|
|
216
|
+
| POST | `/join` | Start agent — joins channel |
|
|
217
|
+
| POST | `/agents/{agentId}/leave` | Stop agent — leaves channel |
|
|
218
|
+
| POST | `/agents/{agentId}/update` | Update agent config (token, LLM) |
|
|
219
|
+
| GET | `/agents/{agentId}` | Query agent status |
|
|
220
|
+
| GET | `/agents` | List agents (with filters) |
|
|
221
|
+
| POST | `/agents/{agentId}/speak` | Broadcast TTS message |
|
|
222
|
+
| POST | `/agents/{agentId}/interrupt` | Interrupt agent speech |
|
|
223
|
+
| GET | `/agents/{agentId}/history` | Get conversation history |
|
|
224
|
+
|
|
225
|
+
## Reference Files
|
|
226
|
+
|
|
227
|
+
Use the file that matches what the user is building:
|
|
228
|
+
|
|
229
|
+
| User's question / task | Read this file |
|
|
230
|
+
|---|---|
|
|
231
|
+
| How ConvoAI works — components, call sequence, init order, lifecycle, start/stop flow | [architecture.md](architecture.md) |
|
|
232
|
+
| No working ConvoAI baseline yet — choose the baseline path, setup order, and readiness gates | [quickstarts.md](quickstarts.md) |
|
|
233
|
+
| Existing app integration — detect app shape, create a copy map, and adapt from the official baseline after first success | [integration-from-quickstart.md](integration-from-quickstart.md) |
|
|
234
|
+
| Node.js/Python/Go backend — starting agent, auth, session lifecycle | [server-sdks.md](server-sdks.md) |
|
|
235
|
+
| Python SDK specifics (async, deprecations, debug) | [python-sdk.md](python-sdk.md) |
|
|
236
|
+
| Go SDK specifics (context, builder, status constants) | [go-sdk.md](go-sdk.md) |
|
|
237
|
+
| Supported vendors and current vendor-specific configs | Fetch the official ConvoAI provider docs after reading this file |
|
|
238
|
+
| Existing Agora Studio Agent ID from `console.agora.io/studio/agents` | [conversational-ai-studio.md](conversational-ai-studio.md) |
|
|
239
|
+
| Auth flow, token types, direct REST API (non-SDK languages) | [auth-flow.md](auth-flow.md) |
|
|
240
|
+
| Full working demo app architecture, profiles, MLLM/Gemini | [agent-samples.md](agent-samples.md) |
|
|
241
|
+
| Web/React client: transcripts, agent state, sendText, interrupt | [agent-toolkit.md](agent-toolkit.md) |
|
|
242
|
+
| React hooks in depth (useTranscript, useAgentState, provider) | [agent-client-toolkit-react.md](agent-client-toolkit-react.md) |
|
|
243
|
+
| React UI components (voice visualizer, chat UI, video) | [agent-ui-kit.md](agent-ui-kit.md) |
|
|
244
|
+
| iOS client: ConversationalAIAPIImpl, Swift | [agent-toolkit-ios.md](agent-toolkit-ios.md) |
|
|
245
|
+
| Android client: ConversationalAIAPIImpl, Kotlin | [agent-toolkit-android.md](agent-toolkit-android.md) |
|
|
246
|
+
| Custom LLM backend: RAG, tool calling, conversation memory | [server-custom-llm.md](server-custom-llm.md) |
|
|
247
|
+
| Persistent per-user memory via MCP | [server-mcp.md](server-mcp.md) |
|
|
248
|
+
|
|
249
|
+
## REST API Reference
|
|
250
|
+
|
|
251
|
+
Full request/response details for all endpoints — **always fetch these; do not answer from memory:**
|
|
252
|
+
|
|
253
|
+
- **[Start Agent (Join)](https://docs-md.agora.io/en/conversational-ai/rest-api/agent/join.md)** — POST /join: start agent with LLM/TTS/ASR config
|
|
254
|
+
- **[Stop Agent (Leave)](https://docs-md.agora.io/en/conversational-ai/rest-api/agent/leave.md)** — POST /leave: stop agent
|
|
255
|
+
- **[Update Agent](https://docs-md.agora.io/en/conversational-ai/rest-api/agent/update.md)** — POST /update: update token, LLM config
|
|
256
|
+
- **[Query Agent Status](https://docs-md.agora.io/en/conversational-ai/rest-api/agent/query.md)** — GET /agents/{id}: query status
|
|
257
|
+
- **[List Agents](https://docs-md.agora.io/en/conversational-ai/rest-api/agent/list.md)** — GET /agents: list with filters
|
|
258
|
+
- **[Broadcast Message (Speak)](https://docs-md.agora.io/en/conversational-ai/rest-api/agent/speak.md)** — POST /speak: broadcast TTS
|
|
259
|
+
- **[Interrupt Agent](https://docs-md.agora.io/en/conversational-ai/rest-api/agent/interrupt.md)** — POST /interrupt
|
|
260
|
+
- **[Conversation History](https://docs-md.agora.io/en/conversational-ai/rest-api/agent/history.md)** — GET /history
|
|
261
|
+
|
|
262
|
+
## Production: Platform Webhooks
|
|
263
|
+
|
|
264
|
+
The ConvoAI platform can POST event notifications to your server endpoint when agent state changes. These are distinct from:
|
|
265
|
+
- The SDK's in-process `session.on()` events (fire in your Node.js/Python/Go process)
|
|
266
|
+
- The client toolkit's `AGENT_STATE_CHANGED` event (fires in the browser via RTM)
|
|
267
|
+
|
|
268
|
+
Webhooks are the correct pattern for **production stateless deployments** where you do not hold the `AgentSession` object in memory between requests. Your server receives a POST when agent state changes, correlates using the agent ID (returned by `session.start()` / the `/join` response), and updates your application state accordingly.
|
|
269
|
+
|
|
270
|
+
Webhook payload schemas and registration are REST API surface — do not rely on inline content here. Fetch from the Agora docs:
|
|
271
|
+
|
|
272
|
+
```
|
|
273
|
+
GET https://docs-md.agora.io/en/conversational-ai/rest-api/agent/join.md
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
or via MCP: search for "conversational AI webhook" in the Agora docs tool.
|
|
277
|
+
|
|
278
|
+
## Agent Configuration (join payload `properties` object)
|
|
279
|
+
|
|
280
|
+
Fetch these before answering questions about vendor configs, model names, or join payload fields:
|
|
281
|
+
|
|
282
|
+
- **[Custom LLM Guide](https://docs-md.agora.io/en/conversational-ai/develop/custom-llm.md)** — LLM vendor, model, url, api_key, system prompt, greeting, style; TTS vendor, model, voice settings; ASR vendor, language, model
|
|
283
|
+
- **[Gemini Live MLLM](https://docs-md.agora.io/en/conversational-ai/models/mllm/gemini.md)** — Multimodal: vendor, model, credentials, location
|
|
284
|
+
- **[Join Endpoint (full schema)](https://docs-md.agora.io/en/conversational-ai/rest-api/agent/join.md)** — Complete properties schema: channel, token, turn detection, VAD, tools, avatars, encryption, filler words
|
|
285
|
+
- **[Release Notes](https://docs-md.agora.io/en/conversational-ai/overview/release-notes.md)** — New parameters and features
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agora-agent-client-toolkit-react
|
|
3
|
+
description: |
|
|
4
|
+
React hooks for Agora Conversational AI client integration. Use when the user is building
|
|
5
|
+
a React app with Agora ConvoAI and needs agora-agent-client-toolkit-react hooks.
|
|
6
|
+
Triggers on useTranscript, useAgentState, useAgentError, useAgentMetrics,
|
|
7
|
+
ConversationalAIProvider, agora-agent-client-toolkit-react, React ConvoAI hooks,
|
|
8
|
+
agent transcript React, agent state React hook.
|
|
9
|
+
license: MIT
|
|
10
|
+
metadata:
|
|
11
|
+
author: agora
|
|
12
|
+
version: '1.0.0'
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# Agent Client Toolkit — React
|
|
16
|
+
|
|
17
|
+
React hooks for `agora-agent-client-toolkit`. Wraps the `AgoraVoiceAI` singleton into React state and effects. Must be used alongside `agora-rtc-react` — this package handles ConvoAI concerns only, not RTC primitives (mic tracks, camera, remote users).
|
|
18
|
+
|
|
19
|
+
**npm:** `agora-agent-client-toolkit-react`
|
|
20
|
+
**Requires:** `agora-agent-client-toolkit`, `agora-rtc-react`, React >= 18
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install agora-agent-client-toolkit-react agora-agent-client-toolkit agora-rtc-react agora-rtm
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
Use `ConversationalAIProvider` + standalone hooks. The provider manages the `AgoraVoiceAI` lifecycle — standalone hooks connect via context so only the components that need updates re-render.
|
|
31
|
+
|
|
32
|
+
> For simple single-component cases, `useConversationalAI` is available as a batteries-included alternative. See the [package README](https://github.com/AgoraIO-Conversational-AI/agent-client-toolkit-ts/blob/main/packages/react/README.md) for details.
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import { useMemo } from 'react';
|
|
36
|
+
import AgoraRTC, { AgoraRTCProvider, useJoin, useLocalMicrophoneTrack, usePublish } from 'agora-rtc-react';
|
|
37
|
+
import AgoraRTM from 'agora-rtm';
|
|
38
|
+
import {
|
|
39
|
+
ConversationalAIProvider,
|
|
40
|
+
useTranscript,
|
|
41
|
+
useAgentState,
|
|
42
|
+
useAgentError,
|
|
43
|
+
useAgentMetrics,
|
|
44
|
+
} from 'agora-agent-client-toolkit-react';
|
|
45
|
+
|
|
46
|
+
const rtcClient = AgoraRTC.createClient({ mode: 'rtc', codec: 'vp8' });
|
|
47
|
+
const rtmClient = new AgoraRTM.RTM('APP_ID', 'RTM_USER_ID'); // must match the RTM token subject; often String(rtcUid)
|
|
48
|
+
await rtmClient.login({ token: 'RTM_TOKEN' });
|
|
49
|
+
|
|
50
|
+
function App() {
|
|
51
|
+
const config = useMemo(() => ({
|
|
52
|
+
channel: 'my-channel',
|
|
53
|
+
rtmConfig: { rtmEngine: rtmClient },
|
|
54
|
+
}), []);
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
// AgoraRTCProvider (outer) → ConversationalAIProvider (inner)
|
|
58
|
+
<AgoraRTCProvider client={rtcClient}>
|
|
59
|
+
<ConversationalAIProvider config={config}>
|
|
60
|
+
<VoiceSession />
|
|
61
|
+
</ConversationalAIProvider>
|
|
62
|
+
</AgoraRTCProvider>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function VoiceSession() {
|
|
67
|
+
// Agora RTC hooks — your existing integration
|
|
68
|
+
useJoin({ appid: 'APP_ID', channel: 'my-channel', token: 'RTC_TOKEN' });
|
|
69
|
+
const { localMicrophoneTrack } = useLocalMicrophoneTrack();
|
|
70
|
+
usePublish([localMicrophoneTrack]);
|
|
71
|
+
|
|
72
|
+
// ConvoAI hooks — added on top
|
|
73
|
+
const transcript = useTranscript();
|
|
74
|
+
const { agentState } = useAgentState();
|
|
75
|
+
const { error, clearError } = useAgentError();
|
|
76
|
+
const { metrics } = useAgentMetrics();
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<div>
|
|
80
|
+
<p>Agent: {agentState ?? 'idle'}</p>
|
|
81
|
+
{error && <p onClick={clearError}>Error: {error.error.message}</p>}
|
|
82
|
+
<ul>{transcript.map((t) => <li key={t.turn_id}>{t.text}</li>)}</ul>
|
|
83
|
+
</div>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Hooks Reference
|
|
89
|
+
|
|
90
|
+
### `useTranscript()`
|
|
91
|
+
|
|
92
|
+
Subscribe to transcript updates. Returns the full conversation history — replace, don't append.
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
const transcript = useTranscript();
|
|
96
|
+
// transcript: TranscriptHelperItem[]
|
|
97
|
+
// Each item: { uid, turn_id, text, status, metadata }
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### `useAgentState()`
|
|
101
|
+
|
|
102
|
+
Subscribe to `AGENT_STATE_CHANGED` events.
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
const { agentState, stateEvent, agentUserId } = useAgentState();
|
|
106
|
+
// agentState: 'idle' | 'listening' | 'thinking' | 'speaking' | 'silent' | null
|
|
107
|
+
// stateEvent: { state, turnID, timestamp, reason } | null
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Only fires when RTM is configured and agent start config includes `advanced_features.enable_rtm: true` + `parameters.data_channel: "rtm"`.
|
|
111
|
+
|
|
112
|
+
### `useAgentError()`
|
|
113
|
+
|
|
114
|
+
Subscribe to `AGENT_ERROR` and `MESSAGE_ERROR` events. Returns a discriminated union.
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
const { error, clearError } = useAgentError();
|
|
118
|
+
// error: { source: 'agent', agentUserId, error: ModuleError }
|
|
119
|
+
// | { source: 'message', agentUserId, error: { type, code, message, timestamp } }
|
|
120
|
+
// | null
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Call `clearError()` after dismissing (e.g. closing a toast).
|
|
124
|
+
|
|
125
|
+
### `useAgentMetrics()`
|
|
126
|
+
|
|
127
|
+
Subscribe to `AGENT_METRICS` events.
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
const { metrics, agentUserId } = useAgentMetrics();
|
|
131
|
+
// metrics: { type: ModuleType, name: string, value: number, timestamp: number } | null
|
|
132
|
+
// ModuleType: 'llm' | 'mllm' | 'tts' | 'context' | 'unknown'
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Only fires when agent start config includes `parameters.enable_metrics: true`.
|
|
136
|
+
|
|
137
|
+
## `useConversationalAI` — Batteries-Included Alternative
|
|
138
|
+
|
|
139
|
+
For simple single-page apps or demos where all ConvoAI state is consumed in one component, `useConversationalAI` is a drop-in alternative to the full Provider + hooks pattern. If multiple components need transcript, agent state, or errors independently, use `ConversationalAIProvider` + standalone hooks instead.
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
import { useConversationalAI } from 'agora-agent-client-toolkit-react';
|
|
143
|
+
import { useMemo } from 'react';
|
|
144
|
+
|
|
145
|
+
function VoiceSession() {
|
|
146
|
+
const config = useMemo(() => ({
|
|
147
|
+
channel: 'my-channel',
|
|
148
|
+
rtmConfig: { rtmEngine: rtmClient },
|
|
149
|
+
}), []);
|
|
150
|
+
|
|
151
|
+
const {
|
|
152
|
+
transcript,
|
|
153
|
+
agentState,
|
|
154
|
+
isConnected,
|
|
155
|
+
error,
|
|
156
|
+
interrupt,
|
|
157
|
+
sendMessage,
|
|
158
|
+
metrics,
|
|
159
|
+
} = useConversationalAI(config);
|
|
160
|
+
|
|
161
|
+
return (
|
|
162
|
+
<div>
|
|
163
|
+
<p>Agent: {agentState ?? 'idle'}</p>
|
|
164
|
+
<button onClick={() => interrupt(agentUserId)}>Interrupt</button>
|
|
165
|
+
<ul>{transcript.map((t) => <li key={t.turn_id}>{t.text}</li>)}</ul>
|
|
166
|
+
</div>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**Config stability rule** — same as `ConversationalAIProvider`: wrap config in `useMemo`. The hook re-initializes if the config object identity changes.
|
|
172
|
+
|
|
173
|
+
The hook internally calls `AgoraVoiceAI.init()`, `subscribeMessage()`, and `destroy()` automatically. No manual lifecycle management needed.
|
|
174
|
+
|
|
175
|
+
## Critical Rules
|
|
176
|
+
|
|
177
|
+
1. **Wrap `config` in `useMemo`** — `ConversationalAIProvider` depends on `config.channel`. An inline object creates a new reference every render, causing unnecessary re-init cycles.
|
|
178
|
+
2. **`AgoraRTCProvider` must be the outer wrapper** — `ConversationalAIProvider` calls `useRTCClient()` internally and will throw if rendered outside `AgoraRTCProvider`.
|
|
179
|
+
3. **All standalone hooks require `ConversationalAIProvider`** — `useTranscript`, `useAgentState`, `useAgentError`, and `useAgentMetrics` won't receive events without it.
|
|
180
|
+
4. **Use `agora-rtc-react` for RTC primitives** — mic tracks, camera, remote users, join, and publish are handled by `agora-rtc-react` hooks. This package covers ConvoAI concerns only.
|
|
181
|
+
5. **RTM must be logged in before passing to config** — call `rtmClient.login()` before passing `rtmEngine` into the provider config. The provider does not manage RTM login/logout.
|
|
182
|
+
6. **RTM userId must match the RTM token subject** — if your server minted the RTM token for `String(rtcUid)`, do not construct `new AgoraRTM.RTM(appId, ...)` with a different user ID. In first-success flows, identity mismatches can bubble up as generic startup failures instead of a clean RTM auth error.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Agent Samples
|
|
2
|
+
|
|
3
|
+
Backend + frontend clients for Agora Conversational AI.
|
|
4
|
+
|
|
5
|
+
**Repo:** <https://github.com/AgoraIO-Conversational-AI/agent-samples>
|
|
6
|
+
**Coding Guide:** <https://github.com/AgoraIO-Conversational-AI/agent-samples/blob/main/AGENT.md>
|
|
7
|
+
|
|
8
|
+
## Prerequisites
|
|
9
|
+
|
|
10
|
+
- **Node.js >= 20.9.0** — required by Next.js 16 (used by both React clients). The repo includes `.nvmrc`. Run `nvm install` (or `nvm use`) in the repo root to auto-select the correct version. If nvm sourcing fails in non-interactive shells, use the full binary path: `$NVM_DIR/versions/node/v<VERSION>/bin/node`.
|
|
11
|
+
- **Python 3.x** — required by simple-backend
|
|
12
|
+
|
|
13
|
+
## Local Setup Steps
|
|
14
|
+
|
|
15
|
+
1. Clone: `git clone https://github.com/AgoraIO-Conversational-AI/agent-samples.git`
|
|
16
|
+
2. Node.js: `cd agent-samples && nvm install` (reads `.nvmrc`, installs if needed)
|
|
17
|
+
3. Backend: `cd simple-backend && python3 -m venv venv && source venv/bin/activate && pip install -r requirements-local.txt && cp .env.example .env`
|
|
18
|
+
4. Configure `.env` with `VOICE_*` or `VIDEO_*` credentials (see [Profile System](#profile-system) below)
|
|
19
|
+
5. Start backend: `python3 local_server.py` (port 8082)
|
|
20
|
+
6. Frontend (voice): `cd react-voice-client && npm install --legacy-peer-deps && npm run dev` (port 8083)
|
|
21
|
+
7. Frontend (video+avatar): `cd react-video-client-avatar && npm install --legacy-peer-deps && npm run dev` (port 8084)
|
|
22
|
+
|
|
23
|
+
> **[AGENT.md — Local Development Quick Start](https://github.com/AgoraIO-Conversational-AI/agent-samples/blob/main/AGENT.md#local-development-quick-start)** — Full details
|
|
24
|
+
> **[README — Backend Sample](https://github.com/AgoraIO-Conversational-AI/agent-samples#backend-sample)** — Setup overview
|
|
25
|
+
|
|
26
|
+
## Backend (simple-backend/)
|
|
27
|
+
|
|
28
|
+
- Python Flask server on port 8082
|
|
29
|
+
- Profile-based config system (`<PROFILE>_<VARIABLE>`)
|
|
30
|
+
- Agent lifecycle management, token generation
|
|
31
|
+
- `AGENT_AUTH_HEADER` — sets the `Authorization` header on ConvoAI REST API calls. Now optional: if not set, the backend auto-generates an Agora token (`agora token=<AccessToken2>`) from `APP_ID` + `APP_CERTIFICATE`. Override only if you need Basic Auth (`Basic <base64(customerId:secret)>`) or lack an App Certificate. See [ConvoAI Authentication](./README.md#authentication) for context.
|
|
32
|
+
|
|
33
|
+
> **[AGENT.md — Backend Configuration](https://github.com/AgoraIO-Conversational-AI/agent-samples/blob/main/AGENT.md#backend-configuration)** — Profile system, variable naming, active profiles
|
|
34
|
+
|
|
35
|
+
## Profile System
|
|
36
|
+
|
|
37
|
+
- Default profiles: `VOICE` (Rime TTS + OpenAI), `VIDEO` (ElevenLabs + GPT-4o + HeyGen)
|
|
38
|
+
- Profile names are case-insensitive
|
|
39
|
+
- Client sends `profile=VOICE` → backend loads all `VOICE_*` env vars
|
|
40
|
+
- `NEXT_PUBLIC_DEFAULT_PROFILE` env var overrides the client's default profile
|
|
41
|
+
- URL params: `?profile=VOICE` overrides profile selection, `?autoconnect=true` auto-starts conversation
|
|
42
|
+
|
|
43
|
+
> **[AGENT.md — Profile System Mechanics](https://github.com/AgoraIO-Conversational-AI/agent-samples/blob/main/AGENT.md#profile-system-mechanics)**
|
|
44
|
+
|
|
45
|
+
## MLLM / Gemini Live Configuration
|
|
46
|
+
|
|
47
|
+
- Required vars: `VOICE_ENABLE_MLLM`, `VOICE_MLLM_VENDOR`, `VOICE_MLLM_MODEL`, `VOICE_MLLM_LOCATION` (NOT REGION!)
|
|
48
|
+
- `MLLM_LOCATION` not `MLLM_REGION` — the backend expects LOCATION
|
|
49
|
+
|
|
50
|
+
> **[AGENT.md — Required MLLM Variables](https://github.com/AgoraIO-Conversational-AI/agent-samples/blob/main/AGENT.md#required-mllm-variables-for-gemini-live)**
|
|
51
|
+
> **[AGENT.md — Configuration Translation Guide](https://github.com/AgoraIO-Conversational-AI/agent-samples/blob/main/AGENT.md#configuration-translation-guide)**
|
|
52
|
+
|
|
53
|
+
## OpenAI Realtime MLLM
|
|
54
|
+
|
|
55
|
+
Alternative to Gemini Live for multimodal voice:
|
|
56
|
+
- `MLLM_VENDOR=openai`, `MLLM_MODEL=gpt-4o-realtime-preview`
|
|
57
|
+
- Built-in TTS (no separate TTS vendor needed), set voice with `MLLM_VOICE=alloy`
|
|
58
|
+
|
|
59
|
+
> **[AGENT.md — MLLM Configuration](https://github.com/AgoraIO-Conversational-AI/agent-samples/blob/main/AGENT.md#required-mllm-variables-for-gemini-live)**
|
|
60
|
+
|
|
61
|
+
## React Voice Client (react-voice-client/)
|
|
62
|
+
|
|
63
|
+
- Next.js voice AI client, port 8083
|
|
64
|
+
- Uses `@agora/conversational-ai` + `@agora/agent-ui-kit`
|
|
65
|
+
|
|
66
|
+
## React Video Client (react-video-client-avatar/)
|
|
67
|
+
|
|
68
|
+
- Next.js video+avatar client, port 8084
|
|
69
|
+
- HeyGen/Anam avatar integration
|
|
70
|
+
|
|
71
|
+
## Simple HTML Clients
|
|
72
|
+
|
|
73
|
+
- `simple-voice-client-no-backend/` — standalone, no backend needed
|
|
74
|
+
- `simple-voice-client-with-backend/` — uses simple-backend
|
|
75
|
+
|
|
76
|
+
## Debugging Agent Failures
|
|
77
|
+
|
|
78
|
+
- RTM error `-11033: user offline` → agent failed to create (400 from Agora API)
|
|
79
|
+
- Check backend logs for `Response status: 400`
|
|
80
|
+
- Common: missing `location` field in MLLM config
|
|
81
|
+
|
|
82
|
+
> **[AGENT.md — Debugging Agent Creation Failures](https://github.com/AgoraIO-Conversational-AI/agent-samples/blob/main/AGENT.md#debugging-agent-creation-failures)**
|
|
83
|
+
|
|
84
|
+
## Production Deployment (EC2 + nginx)
|
|
85
|
+
|
|
86
|
+
- Gotcha: `NEXT_PUBLIC_*` env vars must be set at both **build time** AND runtime for Next.js
|
|
87
|
+
|
|
88
|
+
> **[AGENT.md — Production Deployment](https://github.com/AgoraIO-Conversational-AI/agent-samples/blob/main/AGENT.md#production-deployment-ec2--nginx-on-port-443)** — nginx config, PM2 ecosystem, basePath, gotchas
|
|
89
|
+
|
|
90
|
+
## Companion Servers
|
|
91
|
+
|
|
92
|
+
- **server-custom-llm** → see [server-custom-llm.md](server-custom-llm.md)
|
|
93
|
+
- **server-mcp** → see [server-mcp.md](server-mcp.md)
|
|
94
|
+
|
|
95
|
+
## Port Reference
|
|
96
|
+
|
|
97
|
+
| Server | Port |
|
|
98
|
+
|--------|------|
|
|
99
|
+
| simple-backend | 8082 |
|
|
100
|
+
| react-voice-client | 8083 |
|
|
101
|
+
| react-video-client-avatar | 8084 |
|