10v32616
08/18/2025, 4:38 AMAI Evy
08/18/2025, 4:38 AMAI Evy
08/18/2025, 4:39 AM<script>, and users can type or talk using the same flow .
You can create a chat session using the Chat API [(2) ]() :
javascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const chatResponse = await client.chat.create({ agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD' }) ;
console.log(chatResponse.agent_id) ;
This allows you to have both voice and text functionality using the same agent logic, though they would be separate interfaces rather than integrated text input within the voice call itself [(1) ]() .AI Evy
08/18/2025, 4:39 AMAI Evy
08/18/2025, 4:39 AM10v32616
08/18/2025, 6:05 AMAI Evy
08/18/2025, 6:05 AMAI Evy
08/18/2025, 6:05 AMjavascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const chatResponse = await client.chat.create({ agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD' }) ;
console.log(chatResponse.agent_id) ;
Create Web Call API tạo một cuộc gọi thoại qua web [(2) ]() :
javascript
const webCallResponse = await client.call.createWebCall({ agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD' }) ;
console.log(webCallResponse.agent_id) ;
Sự khác biệt chính:
- Create Chat trả về chat_id và được thiết kế cho tương tác văn bản [(1) ]()
- Create Web Call trả về access_token và call_id cho cuộc gọi thoại qua web [(2) ]()
- Web Call có các tính năng như transcript, recording_url, và latency tracking
- Chat có message_with_tool_calls và chat_analysis [(1) ]()
Cả hai đều sử dụng cùng agent_id nhưng tạo ra các loại phiên tương tác khác nhau [(1) ]() [(2) ]() .AI Evy
08/18/2025, 6:05 AMAI Evy
08/18/2025, 6:05 AM10v32616
08/18/2025, 6:06 AMAI Evy
08/18/2025, 6:06 AMAI Evy
08/18/2025, 6:07 AMAuthorization: Bearer YOUR_RETELL_API_KEY
3. Kiểm tra agent_id
Đảm bảo agent_id tồn tại và đã được publish . Dựa trên một trường hợp tương tự [(2) ]() , có thể agent đã được tạo nhưng không xuất hiện trong API do vấn đề hệ thống.
4. Sử dụng đúng SDK
Code mẫu chính xác từ tài liệu [(1) ]() :
javascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const chatResponse = await client.chat.create({ agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD' }) ;
console.log(chatResponse.agent_id) ;
5. Kiểm tra các tham số bắt buộc
API yêu cầu agent_id là bắt buộc .
Nếu vẫn gặp lỗi 404, hãy kiểm tra xem agent có thực sự tồn tại bằng cách sử dụng API list agents hoặc liên hệ support để xác minh vấn đề hệ thống [(2) ]() .AI Evy
08/18/2025, 6:07 AMAI Evy
08/18/2025, 6:07 AM10v32616
08/18/2025, 7:07 AM10v32616
08/18/2025, 7:07 AMAI Evy
08/18/2025, 7:07 AMAI Evy
08/18/2025, 7:07 AMjavascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const chatResponse = await client.chat.create({ agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD' }) ;
console.log(chatResponse.agent_id) ;
2. Xác minh agent configuration
Sử dụng Get Agent API để kiểm tra cấu hình agent [(2) ]() :
javascript
const agentResponse = await client.agent.retrieve('16b980523634a6dc504898cda492e939') ;
console.log(agentResponse.agent_id) ;
3. Kiểm tra response_engine
Agent phải có response_engine được cấu hình đúng . Trong response từ Get Agent API, bạn sẽ thấy:
json
{
"response_engine": {
"type": "retell-llm",
"llm_id": "llm_234sdertfsdsfsdf",
"version": 0
}
}
4. Kiểm tra trạng thái published
Agent cần được published để có thể sử dụng trong chat sessions . Kiểm tra field is_published trong response:
json
{
"is_published": false
}
Nếu is_published là false, bạn cần publish agent trước khi có thể tạo chat session .AI Evy
08/18/2025, 7:07 AMAI Evy
08/18/2025, 7:07 AM10v32616
08/18/2025, 7:17 AMAI Evy
08/18/2025, 7:17 AMAI Evy
08/18/2025, 7:18 AMjavascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const agentResponse = await client.agent.retrieve('16b980523634a6dc504898cda492e939') ;
console.log(agentResponse.agent_id) ;
2. Hiểu về agent versioning
Theo thông tin từ cộng đồng, một khi version đã được published, cấu hình agent cho version đó không thể được sửa đổi [(2) ]() . Khi bạn cập nhật agent, hệ thống tạo ra version mới với is_published: false .
3. Vấn đề với LLM updates
Từ thảo luận cộng đồng, khi bạn update LLM prompt qua API, agent sẽ tiếp tục sử dụng prompt từ published version chứ không phải draft version được tạo khi update [(3) ]() . Để giải quyết, bạn có thể:
- Tạo LLM mới qua API
- Update agent để sử dụng LLM ID mới
4. Vấn đề identity verification
Trong một số trường hợp, agent không thể publish do chưa hoàn thành identity verification [(4) ]() . Kiểm tra xem bạn đã verify identity chưa.
5. Giải pháp khuyến nghị
Thay vì patch existing LLM, hãy tạo LLM mới và update agent để sử dụng LLM mới đó [(3) ]() .
Nếu vấn đề vẫn tiếp tục, hãy liên hệ:
- Visit [Contact Sales]()
- Visit [)AI Evy
08/18/2025, 7:18 AMAI Evy
08/18/2025, 7:19 AM10v32616
08/18/2025, 7:57 AMAI Evy
08/18/2025, 7:57 AMAI Evy
08/18/2025, 7:57 AMjavascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
// Update agent với response_engine mới
const agentResponse = await client.agent.update('16b980523634a6dc504898cda492e939', {
response_engine: {
llm_id: 'llm_new_id',
type: 'retell-llm'
}
}) ;
[(2) ]()
Giải pháp từ cộng đồng:
Theo thảo luận, bạn có thể set agent ở draft version từ dashboard tại tab phone numbers, sau đó mọi thay đổi qua API hoặc dashboard sẽ có hiệu lực mà không cần publish [(3) ]() .
Tôi không tìm thấy endpoint chính thức để publish agent qua API trong tài liệu hiện có. Nếu bạn cần giải pháp chính xác cho việc publish agent, hãy liên hệ:
- Visit [Contact Sales]()
- Visit [)
Bạn có muốn tôi cung cấp thêm thông tin chung dựa trên kiến thức của mình không?AI Evy
08/18/2025, 7:57 AMAI Evy
08/18/2025, 7:57 AM10v32616
08/18/2025, 8:14 AMAI Evy
08/18/2025, 8:14 AMAI Evy
08/18/2025, 8:14 AMversion trong các API call [(1) ]() [(2) ]() :
Cách sử dụng version number trong API:
javascript
get_agent(version=2) ///# Gets the version with version number 2.
get_agent() ///# Gets the latest version of the agent.
[(1) ]()
Lấy agent với version cụ thể:
javascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const agentResponse = await client.agent.retrieve('16b980523634a6dc504898cda492e939') ;
console.log(agentResponse.agent_id) ;
[(2) ]()
Trong Get Agent API, bạn có thể thêm query parameter version :
- version (integer) : Optional version của API để sử dụng cho request này. Nếu không cung cấp, sẽ mặc định là latest version
Quản lý version qua dashboard:
Theo thông tin từ cộng đồng, bạn có thể set agent ở draft version từ dashboard tại tab "Phone Numbers", sau đó mọi thay đổi qua API hoặc dashboard sẽ có hiệu lực mà không cần publish [(3) ]() .
Xem tất cả versions của agent:
javascript
const agentResponses = await client.agent.getVersions('16b980523634a6dc504898cda492e939') ;
console.log(agentResponses) ;AI Evy
08/18/2025, 8:14 AMDraft trong Phone Numbers tab, nó sẽ luôn fetch latest version của agent
Version number có thể được sử dụng:
- Trong get_agent hoặc get_retell_llm API
- Trong creating calls như create_web_call
- Trong create_phone_number để đảm bảo phone sử dụng đúng version của agentAI Evy
08/18/2025, 8:14 AMAI Evy
08/18/2025, 8:14 AM10v32616
08/18/2025, 8:25 AMAI Evy
08/18/2025, 8:25 AMAI Evy
08/18/2025, 8:25 AMjavascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const chatResponse = await client.chat.create({ agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD' }) ;
console.log(chatResponse.agent_id) ;
2. **Agent như template**: Agent hoạt động như một template có thể được sử dụng đồng thời cho nhiều sessions khác nhau [(1) ]() [(2) ]() . Việc convert từ voice agent sang chat agent chỉ thay đổi cấu hình agent, không ảnh hưởng đến các sessions đang hoạt động.
3. **Conversation history riêng biệt**: Mỗi chat session có transcript và message_with_tool_calls riêng [(2) ]() , không chia sẻ với sessions khác.
4. **Hạn chế khi convert**: Khi convert voice agent sang chat agent, các tính năng voice-specific như call transfers, DTMF, hoặc telephony features sẽ bị loại bỏ [(1) ]() , nhưng điều này không ảnh hưởng đến sessions đang hoạt động.
**Lưu ý**: Conversation history được tự động lưu trữ trong database của Retell, và bạn không cần quản lý conversation context [(3) ]() .AI Evy
08/18/2025, 8:25 AMAI Evy
08/18/2025, 8:25 AM10v32616
08/18/2025, 9:09 AMAI Evy
08/18/2025, 9:09 AMAI Evy
08/18/2025, 9:09 AMjavascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const response = await client.chat.createChatCompletion({
chat_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
content: 'hi how are you doing?',
}) ;
console.log(response.messages) ;
**Khuyến nghị**: Nên hoàn thành voice call trước khi chuyển sang chat session, hoặc sử dụng một trong hai phương thức giao tiếp để tránh confusion và đảm bảo trải nghiệm người dùng nhất quán .AI Evy
08/18/2025, 9:09 AMAI Evy
08/18/2025, 9:09 AM10v32616
08/18/2025, 9:28 AMAI Evy
08/18/2025, 9:28 AMAI Evy
08/18/2025, 9:29 AMin_progress, trong khi chat session bắt đầu từ trạng thái mới.
2. Tool calling behavior khác biệt
Chat sessions có message_with_tool_calls , trong khi voice calls có cơ chế tool calling khác. Nếu agent đang chờ tool response từ voice call, việc chuyển sang chat có thể gây confusion.
3. Timing và latency issues
Voice calls có real-time constraints với end-to-end latency < 800ms, trong khi chat không có yêu cầu này. Việc chuyển đổi có thể tạo ra timing mismatch.
4. Session cleanup
Voice call gốc vẫn cần được properly terminated để tránh resource leaks:
javascript
// Voice call cần được end properly
const callResponse = await client.call.end('call_id') ;
5. Analytics và tracking
Hai sessions sẽ tạo ra separate analytics records, có thể gây khó khăn trong việc tracking complete conversation journey.
6. Concurrent limitations
Nếu có rate limits hoặc concurrent session limits, việc có cả voice call và chat session đồng thời có thể gây vấn đề.
**Khuyến nghị**: Ngay cả khi quản lý transcription tốt, nên implement proper session transition logic để ensure clean handoff giữa voice và chat modes.
To learn more, see the sources I considered:
[[1] Create Chat]()
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.AI Evy
08/18/2025, 9:29 AMAI Evy
08/18/2025, 9:29 AM