hundreds-king-75485
10/23/2025, 12:12 PMtall-airline-16756
10/23/2025, 12:13 PMtall-airline-16756
10/23/2025, 12:13 PMhundreds-king-75485
10/23/2025, 12:29 PMtall-airline-16756
10/23/2025, 12:30 PMconst sipClient = new SipClient(LIVEKIT_URL, LIVEKIT_API_KEY, LIVEKIT_API_SECRET);
// Create SIP inbound trunk
const trunk = await sipClient.createSipInboundTrunk(
'inbound-trunk',
[TWILIO_PHONE_NUMBER],
{
auth_username: TWILIO_SIP_USERNAME,
auth_password: TWILIO_SIP_PASSWORD,
}
);
// Create dispatch rule to route calls to rooms and dispatch agents
await sipClient.createSipDispatchRule(
{
type: 'individual',
roomPrefix: 'call',
},
{
name: 'inbound-dispatch-rule',
trunkIds: [trunk.sipTrunkId],
}
);
3. Deploy and Run the LiveKit Agent:
Next, implement an agent that listens for rooms matching your dispatch rule. When a call comes in, the SIP call is bridged into a LiveKit room, and the agent joins right away to engage with the caller.
4. Environment Setup:
Make sure to define environment variables like LIVEKIT_URL, LIVEKIT_API_KEY, LIVEKIT_API_SECRET, TWILIO_PHONE_NUMBER, and LIVEKIT_SIP_URI. These will be essential for your setup scripts and agent logic.
5. Automate Configuration:
To save time and reduce manual steps, you can use setup scripts that automate creating SIP trunks and dispatch rules.
This approach ensures your users only need to interact via phone calls, while your application gracefully manages all the LiveKit configurations behind the scenes. If you want to dive deeper, feel free to check out the SIP Integration Guide and the LiveKit SIP Agent Example Repository. I'm here if you have any questions along the way!
Sources: Agents telephony integration | LiveKit Docs | Create and configure a Twilio SIP trunk | LiveKit Docs | README.md | packages/sip--um-actually/README.mdhundreds-king-75485
10/23/2025, 12:32 PMtall-airline-16756
10/23/2025, 12:33 PMnumbers field. This way, the trunk will happily accept calls only if the destination number matches one of the numbers in your list.
For instance, when you're creating the trunk using the LiveKit Server SDK, you can include several numbers like this:
const trunk = await sipClient.createSipInboundTrunk(
'inbound-trunk',
[TWILIO_PHONE_NUMBER_1, TWILIO_PHONE_NUMBER_2, TWILIO_PHONE_NUMBER_3],
{
auth_username: TWILIO_SIP_USERNAME,
auth_password: TWILIO_SIP_PASSWORD,
}
);
Plus, you have the flexibility to update the list of numbers dynamically through the API, which makes routing calls from multiple Twilio numbers through a single LiveKit SIP trunk both easy and scalable.
If you'd like, I'm here to help you with the setup or guide you through the API usage—just let me know!
Sources: SIP APIs | LiveKit Docs | protobufs/livekit_sip.proto | src/setup-livekit.ts | packages/sip--um-actually/src/setup-livekit.ts | SIP overview | LiveKit Docshundreds-king-75485
10/23/2025, 12:35 PMtall-airline-16756
10/23/2025, 12:38 PMconst subaccountNumbers = await client.api.accounts(subaccountSid)
.incomingPhoneNumbers.list();
2. Set Up Twilio SIP Trunk Automatically:
Once you find a new number, you can connect it to an existing SIP trunk or create a new one. The Twilio API lets you link the number with the trunk and set the origination URL to your LiveKit SIP endpoint—making the process smooth and efficient.
3. Keep Your LiveKit Inbound Trunk Updated:
You have a couple of options here:
◦ Add the new number to your current LiveKit SIP trunk using the updateSipInboundTrunk API.
◦ Or, use a wildcard setup to accept calls from any number on the Twilio SIP trunk, so you won’t need to update for each number individually.
1. Use Dispatch Rules to Route Calls:
Set up dispatch rules in LiveKit that route calls to specific rooms based on the phone number (like call-+1234567890). This way, agents get dispatched automatically to handle incoming calls smoothly.
This method helps ensure that any new phone numbers you add to your Twilio subaccounts get integrated into your LiveKit setup effortlessly—no manual work needed! If you’d like, I’m more than happy to help you implement this workflow or even assist with writing the scripts. Just let me know!
Sources: packages/sip--um-actually/README.md | SIP inbound trunk | LiveKit Docs | Inbound calls with Twilio Voice | LiveKit Docs | Create and configure a Twilio SIP trunk | LiveKit Docs | README.mdhundreds-king-75485
10/23/2025, 12:43 PMtall-airline-16756
10/23/2025, 12:44 PMcall. This way, each incoming call will generate its own unique room, such as call_+1234567890. This setup ensures every call gets its own space, even when several calls happen at once.
If you'd like, I’m here to help you with setting up these dispatch rules or configuring your SIP trunk to make this work smoothly!
Sources: Inbound calls with Twilio Voice | LiveKit Docs | SIP overview | LiveKit Docs | protobufs/livekit_sip.protohundreds-king-75485
10/23/2025, 12:44 PMtall-airline-16756
10/23/2025, 12:45 PMX-*) can be mapped to participant attributes and used to route calls to specific workflows or rooms.
For instance, you can set up an Individual Dispatch rule that creates a new room for each call, with room names prefixed according to the business (like business1_call_+1234567890).
This way, a single SIP trunk can serve multiple businesses while keeping their calls nicely separated. If you'd like, I’m here to help you with the configuration—just let me know!
Sources: livekit-protocol/src/livekit.rs | Accepting inbound calls | LiveKit Docs | SIP APIs | LiveKit Docs | protobufs/livekit_sip.proto | SIP overview | LiveKit Docshundreds-king-75485
10/23/2025, 12:55 PMtall-airline-16756
10/23/2025, 12:55 PMhundreds-king-75485
10/23/2025, 1:00 PMtall-airline-16756
10/23/2025, 1:01 PM// Node.js Example
await sipClient.createSipInboundTrunk(
"My Inbound Trunk",
["+1234567890"],
{ krispEnabled: true }
);
For outbound SIP trunks, here's how you can do it:
// Node.js Example
await sipClient.createSipOutboundTrunk(
"My Outbound Trunk",
"sip.provider.com",
["+0987654321"]
);
Editing SIP Trunks
If you need to update an existing SIP trunk, simply use the update API like this:
// Node.js Example
await sipClient.updateSipInboundTrunk(
"trunk_id",
{
name: "Updated Name",
authUsername: "new_user",
authPassword: "new_pass"
}
);
Authentication
Just a quick note: all these operations require SIP admin permissions and authentication with your LiveKit API key and secret.
If you'd like, I’m here to help with more examples or answer any questions you have, maybe in a specific programming language you prefer. Just let me know!
Sources: Creating SIP Inbound Trunks and Dispatch Rules with Python SDK | SIP Integration & Telephony | livekit/livekit_composite | DeepWiki | packages/livekit-server-sdk/src/SipClient.ts | src/main/kotlin/io/livekit/server/SipServiceClient.kt | cmd/lk/sip.gohundreds-king-75485
10/23/2025, 1:10 PMtall-airline-16756
10/23/2025, 1:11 PMnumbers field in the SIP trunk to a wildcard (like *) or simply leaving it empty, your trunk can accept calls to any phone number without the need to register each one individually. This way, you can enjoy dynamic routing without the hassle of manually adding numbers for every business.
If you'd like, I’d be more than happy to guide you through setting up this wildcard configuration or help you manage routing rules dynamically to fit your needs. Just let me know!
Sources: livekit-api/src/services/sip.rs | livekit/livekit_sip.pb.go | SIP inbound trunk | LiveKit Docs | SIP outbound trunk | LiveKit Docshundreds-king-75485
10/23/2025, 1:14 PMtall-airline-16756
10/23/2025, 1:16 PM.env.local file and add these variables:
LIVEKIT_API_KEY=your_livekit_api_key
LIVEKIT_API_SECRET=your_livekit_api_secret
LIVEKIT_URL=your_livekit_server_url
LIVEKIT_SIP_URI=your_livekit_sip_uri
TWILIO_PHONE_NUMBER=your_twilio_phone_number
TWILIO_ACCOUNT_SID=your_twilio_account_sid
TWILIO_AUTH_TOKEN=your_twilio_auth_token
TWILIO_SIP_USERNAME=your_twilio_sip_username
TWILIO_SIP_PASSWORD=your_twilio_sip_password
Step 2: Twilio SIP Trunk Setup
1. Let’s create a SIP trunk in Twilio:
trunk = await twilioClient.trunking.v1.trunks.create({
friendlyName: 'LiveKit SIP trunk',
});
2. Next, configure the trunk with an origination URL that points to your LiveKit SIP URI:
originationUrl = await trunk.originationUrls().create({
weight: 1,
priority: 1,
friendlyName: 'LiveKit SIP URI',
sipUrl: sipUri,
enabled: true,
});
3. Then, associate your Twilio phone number with this trunk:
phoneNumber = await trunk.phoneNumbers().create({
phoneNumberSid: incomingPhoneNumber.sid,
});
Step 3: LiveKit Inbound Trunk Setup
1. Now, create an inbound SIP trunk in LiveKit:
trunk = await sipClient.createSipInboundTrunk(
'My Inbound Trunk',
[TWILIO_PHONE_NUMBER],
{
auth_username: TWILIO_SIP_USERNAME,
auth_password: TWILIO_SIP_PASSWORD,
},
);
2. Then, set up a dispatch rule for dynamic routing:
dispatchRule = await sipClient.createSipDispatchRule(
{
type: 'individual',
roomPrefix: 'call',
},
{
name: 'Dynamic Dispatch Rule',
trunkIds: [trunk.sipTrunkId],
},
);
Step 4: Dynamic Routing for New Businesses
This dispatch rule is a key part—it makes sure every incoming call creates a new room dynamically, with names prefixed like call_+1234567890. This way, your routing stays smooth and automatic.
Step 5: Run Setup Scripts
1. Go ahead and run the Twilio setup script:
npm run setup:twilio
2. Then run the LiveKit setup:
npm run setup:livekit
Step 6: Start Your Agent
Finally, start the SIP agent to handle your calls:
npm run agent
This setup is designed to make your life easier by automating dynamic routing for each business without needing manual steps. If anything feels unclear or you want me to walk you through any part again, just let me know—I’m here to help!
Sources: README.mdhundreds-king-75485
10/26/2025, 7:27 PMtall-airline-16756
10/26/2025, 7:27 PMentrypoint function via job.metadata. For instance, you might pass user details like this:
{ "userId": "12345", "name": "John Doe" }
2. Participant Attributes:
Another option is to attach custom attributes directly to the SIP participant:
◦ Via Dispatch Rules: You can define these attributes right in the SIP dispatch rule configuration.
◦ Using SIP Headers: You can map custom X-* SIP headers (like X-Custom-ID: 12345) to participant attributes using headers_to_attributes. These will then be accessible as sip.h.x-custom-id.
Once you've passed this data, the agent can easily retrieve it inside the entrypoint function. Here's a quick example:
const metadata = job.metadata; // Access job metadata
const participantAttributes = participant.attributes; // Access participant attributes
If you'd like, I'm here to help you step-by-step with implementing this. Just let me know!
Sources: Job lifecycle | LiveKit Docs | SIP participant | LiveKit Docs | rpc/sip.pb.go | Agent dispatch | LiveKit Docshundreds-king-75485
10/26/2025, 7:39 PMtall-airline-16756
10/26/2025, 7:40 PMJobContext and can include important details such as the business ID, name, or any preferences.
2. Single SIP Trunk:
By configuring a single SIP trunk to handle all calls, you can simplify things. Then, use dispatch rules to route calls dynamically based on things like phone numbers, PIN codes, or other criteria.
3. Dispatch Rules:
These rules help you control how calls are routed to different rooms. For instance, you could route calls from different businesses into separate rooms or workflows, all while using the same trunk.
4. Agent Logic:
The agent can use the metadata provided during dispatch to decide how to behave for each business. For example, it might determine which number to call or the best way to handle the interaction based on that information.
This approach allows one agent to smartly handle calls for multiple businesses without needing separate trunks or agents. If you'd like, I'm here to help you set this up or answer any questions you have!
Sources: Agent dispatch | LiveKit Docs | SIP APIs | LiveKit Docs | SIP overview | LiveKit Docshundreds-king-75485
10/26/2025, 7:44 PMtall-airline-16756
10/26/2025, 7:45 PMbusiness1_call_+1234567890).
How to Use Dispatch Rules for Your Scenario:
1. Route Calls to Separate Rooms:
By setting the dispatch rule with type: 'individual', each incoming call will dynamically get its own room. This way, calls from different businesses stay nicely separated.
2. Attach Metadata:
You can include custom metadata in the dispatch rule for each call, such as business ID or name. This information is then available to the agent when they join the room, making it easier to personalize the experience.
3. Dynamic Room Naming:
Using a roomPrefix helps keep your rooms organized. For example, calls for Business A could be routed to rooms that start with businessA_call.
Example Dispatch Rule Configuration:
dispatchRule = await sipClient.createSipDispatchRule(
{
type: 'individual',
roomPrefix: 'business_call',
},
{
name: 'Dynamic Dispatch Rule',
trunkIds: [trunk.sipTrunkId],
},
);
Agent Metadata:
All the metadata you define in the dispatch rule is accessible to the agent through the JobContext. This really helps the agent handle calls with the right business-specific details.
If you have any questions or want a hand setting up your dispatch rules or metadata, just let me know—I’m here to help!
Sources: SIP dispatch rule | LiveKit Docs | protobufs/livekit_sip.proto | livekit-protocol/src/livekit.rshundreds-king-75485
10/26/2025, 7:47 PMtall-airline-16756
10/26/2025, 7:47 PMparticipant_attributes field of a SIP dispatch rule. These attributes will be inherited by SIP participants and are accessible to the agent. For example:
{ "business_id": "123", "department": "sales" }
2. Participant Metadata:
Another option is to attach structured data (like JSON) to the participant_metadata field in the dispatch rule. This metadata is stored on the participant and can provide detailed business context.
3. Job Metadata:
When you dispatch an agent explicitly, you can pass job metadata (such as JSON) to the agent’s JobContext. This is great for sharing session-specific or business-specific information.
4. SIP Headers to Attributes Mapping:
You can also configure your SIP trunk to map custom X-* SIP headers to participant attributes. For instance, a header like X-Business-Unit: sales can be mapped to sip.h.x-business-unit.
Accessing the Data:
When you’re working on the agent’s side, you can retrieve:
• Job Metadata: Via JobContext.Metadata.
• Participant Attributes: Through the participant object in the room.
If you’d like, I’m here to help you implement any of these methods or answer any questions you might have!
Sources: Agent dispatch | LiveKit Docs | SIP participant | LiveKit Docs | SIP dispatch rule | LiveKit Docs | Job lifecycle | LiveKit Docs | rpc/sip.pb.gohundreds-king-75485
10/26/2025, 7:49 PMtall-airline-16756
10/26/2025, 7:50 PMdispatchRule = await sipClient.createSipDispatchRule(
{
type: 'individual',
roomPrefix: 'business_call',
metadata: JSON.stringify({ business_id: '123', department: 'sales' })
},
{
name: 'Business Dispatch Rule',
trunkIds: [trunk.sipTrunkId],
},
);
2. Access Metadata in the Agent:
Then, in your agent’s code, you can retrieve the metadata from the JobContext while the call is running:
const metadata = job.metadata; // Access metadata passed via dispatch rule
console.log(metadata.business_id); // Example usage
This way, your agent will have all the relevant business details needed to handle the call smoothly. If you have any questions or need a hand with anything else, just let me know—I’m here to help!hundreds-king-75485
10/26/2025, 7:51 PMtall-airline-16756
10/26/2025, 7:52 PMtext-embedding-3-small.
iii. Then, store those embeddings in an Annoy index file and save the metadata in a pickled file.
iv. Finally, load the RAG handler in the agent so it can retrieve the right info during calls.
◦ Example:
rag_handler = RAGHandler(
index_path="vdb_data",
data_path="business_info.pkl",
thinking_style="message"
)
rag_handler.start(agent)
1. Direct Large Context Loading:
If your dataset is smaller, you might find it easier to load the information directly into the agent’s instructions.
◦ Steps:
i. Save your business data in a text file.
ii. Read that file and include its content when initializing the agent.
iii. For better handling, use a large-context LLM like Google Gemini 2.0 Flash.
◦ Example:
with open("business_handbook.txt", "r", encoding="utf-8") as f:
handbook_text = f.read()
agent = Agent(
instructions=f"""
You are a customer support assistant.
Use the following company handbook to answer questions:
{handbook_text}
""",
llm=google.LLM(model="gemini-2.0-flash")
)
1. Session-Specific Metadata:
You can also pass dynamic data like user profiles or order history at the start of each session using job metadata, room metadata, or participant attributes. This helps tailor the experience even more.
Best Practices:
If you'd like, I’d be more than happy to help you implement RAG or direct context loading for your business data. Just let me know!
Sources: pipeline-llm/large_context.py | agent_extensions/agent_extensions/rag/handler.py | External data and RAG | LiveKit Docshundreds-king-75485
10/26/2025, 7:54 PMtall-airline-16756
10/26/2025, 7:54 PMdispatchRule = await sipClient.createSipDispatchRule(
{
type: 'individual',
roomPrefix: 'business_call',
metadata: JSON.stringify({
business_id: '123',
business_name: 'ABC Corp',
support_info: 'Contact support@abccorp.com for details',
faq: '<BUSINESS_FAQ_URL>'
})
},
{
name: 'Business Dispatch Rule',
trunkIds: [trunk.sipTrunkId],
},
);
2. Access Metadata in the Agent:
Then, in your agent’s code, you can retrieve this metadata from the JobContext during execution like this:
const metadata = job.metadata; // Access metadata passed via dispatch rule
console.log(metadata.business_name); // Example usage
This method lets you smoothly pass all the key business details to your agent, so it’s fully equipped to handle calls for each business accurately. If you’d like, I’m here to help you through any part of this setup—just let me know!hundreds-king-75485
10/26/2025, 8:00 PMtall-airline-16756
10/26/2025, 8:00 PMbusiness_id or other relevant details, which the agent can then use to query a database or API for more information.
Here’s a friendly example workflow to guide you:
1. Pass Metadata in Dispatch Rule:
Include key identifiers in the metadata, such as:
metadata: JSON.stringify({
business_id: '123',
business_name: 'ABC Corp'
})
2. Access Metadata in the Agent:
You can retrieve the metadata in the agent’s JobContext like this:
const metadata = job.metadata;
const businessId = metadata.business_id;
3. Fetch Additional Data:
Then, use that metadata to query a database or API for more details:
const businessDetails = await database.getBusinessDetails(businessId);
console.log(businessDetails);
This method helps keep your dispatch rule metadata light while giving your agent the flexibility to dynamically fetch and use extra data whenever needed. If you’d like, I’m here to help you set up the database queries or API integration—just let me know!hundreds-king-75485
10/26/2025, 8:10 PMtall-airline-16756
10/26/2025, 8:11 PMnumbers list.
◦ Source IP Address: It matches IPs listed in the trunk’s allowed_addresses (like Twilio’s IP range).
1. Dispatch Rule Application:
After matching the trunk, dispatch rules help decide how the call gets routed. These rules can use:
◦ Called Number: To route calls based on the number dialed.
◦ Custom SIP Headers: You can map headers (like X-Call-Source) to participant attributes for more tailored routing.
◦ Twilio-Specific Attributes: Attributes such as sip.twilio.callSid and sip.twilio.accountSid are available automatically.
1. Custom Header Mapping:
You have the option to configure the trunk to map custom SIP headers to participant attributes. For example:
{
"headers_to_attributes": {
"X-Call-Source": "source_label",
"X-Department-ID": "caller.department"
}
}
Example:
If your single trunk handles multiple numbers, you can set up dispatch rules to route calls dynamically like this:
• Calls to +1234567890 are directed to a support room.
• Calls to +1234567891 create new sales rooms with a prefix like sales-.
This way, even with just one trunk, LiveKit can clearly distinguish and route calls based on where they come from, their context, and the metadata. If you’d like, I’m here to help you set this up or answer any questions you have!
Sources: SIP dispatch rule | LiveKit Docs | protobufs/livekit_sip.proto | pkg/service/ioservice_sip.go | SIP inbound trunk | LiveKit Docs | SIP participant | LiveKit Docshundreds-king-75485
10/26/2025, 8:12 PMtall-airline-16756
10/26/2025, 8:13 PMnumbers field empty or using a wildcard (*). This way, your trunk will be ready to handle all incoming calls, no matter the dialed number.
2. Custom SIP Headers:
With Twilio, you have the flexibility to send custom SIP headers like X-Business-ID or X-Source with each call. These headers can then be mapped to participant attributes in your trunk configuration:
{
"headers_to_attributes": {
"X-Business-ID": "business_id",
"X-Source": "source_label"
}
}
3. Dispatch Rules:
Next, you can set up dispatch rules that dynamically route calls based on those mapped attributes. For instance, you might route calls to rooms that start with the business ID:
dispatchRule = await sipClient.createSipDispatchRule(
{
type: 'individual',
roomPrefix: 'business_',
metadata: JSON.stringify({
routing_info: 'Dynamic routing based on business ID'
})
},
{
name: 'Dynamic Business Routing',
trunkIds: [trunk.sipTrunkId],
},
);
4. Agent Access:
Your agents will be able to access the metadata and participant attributes, helping them understand the business context and handle each call just right.
This setup is a wonderful way to have a single trunk smoothly manage calls for multiple businesses, even without predefined numbers. If you have any questions or want me to clarify anything, please don’t hesitate to ask—I’m here to help!hundreds-king-75485
10/26/2025, 8:14 PMtall-airline-16756
10/26/2025, 8:15 PMfrom.User field. That’s super handy! However, for any additional business-specific information like business_id, Twilio will need to provide this data explicitly.
Here’s how Twilio can share that business information with you:
1. Custom SIP Headers:
Twilio can send custom headers (like X-Business-ID) with each call. These headers can carry business-specific details such as business_id, department, or anything else you might need. You can then configure LiveKit to map these headers to participant attributes using the headers_to_attributes field in your trunk configuration.
2. Mapping Example:
{
"headers_to_attributes": {
"X-Business-ID": "business_id",
"X-Department": "department"
}
}
3. Dynamic Routing:
Once you’ve mapped the headers, you can use dispatch rules to route calls dynamically or pass that information along to your agents for even better handling.
This way, Twilio provides the important business context, and LiveKit can use it to make routing and agent interactions smoother. If you'd like, I’m here to help you set up those custom headers or guide you through mapping them in LiveKit—just let me know!hundreds-king-75485
10/26/2025, 8:17 PMtall-airline-16756
10/26/2025, 8:18 PMbusiness_id based on the phone number the caller dials. Each business can have its own unique Twilio phone number, so when a call comes in to that number, Twilio can connect it to the right business_id.
Here’s a simple way to set this up:
1. Assign Unique Numbers:
Give each business in your application a unique Twilio phone number.
2. Set Up Twilio Webhooks:
Configure Twilio to send a webhook whenever a call is received. This webhook will include the dialed number (To) and other important call details.
3. Map Numbers to Business IDs:
In your webhook handler, match the dialed number to the correct business_id using your database or a configuration file.
4. Send Custom SIP Headers:
When you forward the call to LiveKit through the SIP trunk, include the business_id as a custom SIP header (for example, X-Business-ID).
Here’s how it could work:
A caller dials +1234567890 → Twilio’s webhook recognizes this number belongs to Business A → Twilio adds X-Business-ID: A to the SIP headers → LiveKit uses this info to route the call and connect the right agent.
If you’d like, I’m here to help you with setting up the Twilio webhook or mapping those numbers to business IDs. Just let me know!hundreds-king-75485
10/26/2025, 8:19 PMtall-airline-16756
10/26/2025, 8:19 PMbusiness_id with incoming calls:
1. Use a Single Twilio Number with IVR:
You can set up an Interactive Voice Response (IVR) system in Twilio. When someone calls, they’ll be able to choose their business or department by pressing keys. That choice can then be linked to a business_id and sent to LiveKit as a custom SIP header.
2. Caller-Specific Identification:
If you already know the caller’s phone number, you could keep a handy database that matches caller numbers to their business_id. When a call comes in, Twilio can check the number and include the right business_id in the SIP headers.
3. Dynamic Input via Twilio Studio:
Twilio Studio lets you create a flow where callers enter a unique identifier—like an account number or business code—using their keypad or voice. This identifier can then be tied to a business_id and sent along to LiveKit.
4. Custom Twilio Application:
You might also consider developing a custom Twilio app that figures out the business_id based on the call’s context—like the time of day, location, or other info—and includes it in the SIP headers.
These options give you flexible ways to connect calls to a business_id without needing a unique phone number for each business. If you’d like, I’m here to help with more details on any of these ideas!hundreds-king-75485
11/02/2025, 6:33 PMtall-airline-16756
11/02/2025, 6:34 PMfrom livekit.plugins import cartesia
tts = cartesia.TTS(
model="sonic-2",
voice="f786b574-daa5-4673-aa0c-cbe3e8534c02" # Voice ID
)
2. Custom Voices:
If you’re interested in voice cloning or creating a truly unique voice, you can use a provider-specific plugin (like Cartesia or ElevenLabs) with your own API account. This way, you can create or use cloned voices tailored just for you.
Here’s how you can get started:Here’s a quick example to guide you:
import requests
import os
headers = {
"X-API-Key": os.getenv("CARTESIA_API_KEY"),
"Content-Type": "application/json",
}
response = requests.get("https://api.cartesia.ai/voices", headers=headers)
if response.status_code == 200:
voices = response.json()
custom_voice = voices[0]["embedding"]
tts = cartesia.TTS(model="sonic-2", voice=custom_voice)
◦ Create an account with your chosen TTS provider (for example, Cartesia or ElevenLabs).
◦ Install the plugin you need (for example, pip install livekit-plugins-cartesia).
◦ Authenticate with your API key and retrieve your custom voices.
If you’d like, I’m here to walk you through setting up voice cloning or help you pick the perfect voice. Just let me know how I can assist!
Sources: Cartesia TTS | LiveKit docs | ElevenLabs TTS | LiveKit Docs | pipeline-tts/tts_comparison/README.md | Text-to-speech (TTS) models | LiveKit Docshundreds-king-75485
11/25/2025, 1:25 PMtall-airline-16756
11/25/2025, 1:26 PMAPIConnectionError in LiveKit STT inference typically occurs due to network or connection issues when establishing a WebSocket connection to the LiveKit server. Here are the common causes and resolutions:
Causes:
• Network connectivity problems: Unstable or interrupted internet connection.
• WebSocket connection failure: Issues during the WebSocket handshake or setup.
• Invalid URL scheme: Malformed or inaccessible base_url.
• DNS resolution failures: The server may be unreachable due to DNS or network issues.
Resolutions:
1. Verify network connectivity: Ensure stable internet access and that the LiveKit server is reachable.
2. Check API credentials: Confirm that the api_key and api_secret are valid.
3. Validate base URL: Ensure the base_url is correct (e.g., `wss://agent-gateway.livekit.cloud/v1`).
4. Retry logic: Implement retry attempts with exponential backoff to handle transient network issues.
5. Firewall or proxy settings: Ensure WebSocket traffic (port 443 or WSS port) is allowed through firewalls.
Let me know if you need help troubleshooting further or implementing these fixes!
Sources: agents/src/inference/utils.ts | AI Service Plugin Ecosystem | livekit/livekit_composite | DeepWiki | livekit-agents/livekit/agents/inference/tts.pyhundreds-king-75485
12/31/2025, 2:06 PMtall-airline-16756
12/31/2025, 2:07 PMtext-embedding-3-small for semantic embeddings (dimension 1536).
◦ Other models compatible with LangChain or LlamaIndex can also be used.
1. RAG Implementation:
◦ Preprocess your data into embeddings and store it in a vector database (e.g., Annoy).
◦ Query the database during inference to retrieve relevant context and inject it into the agent’s responses.
Example Workflow:
Use LlamaIndex to preprocess data and query it dynamically:
builder = RAGBuilder(index_path="vdb_data", data_path="my_data.pkl")
await builder.build_from_file("raw_data.txt")
Let me know if you need help setting up RAG with any of these tools!
Sources: examples/voice_agents/llamaindex-rag/README.md | LangChain integration guide | LiveKit docs | docs/examples/rag/README.md | agent_extensions/agent_extensions/rag/builder.py | External data and RAG | LiveKit docshundreds-king-75485
12/31/2025, 2:10 PMtall-airline-16756
12/31/2025, 2:10 PMpip install chromadb
2. Build a ChromaDB Collection:
Index your documents with embeddings (e.g., OpenAI embeddings):
import chromadb
from chromadb.config import Settings
client = chromadb.Client(Settings())
collection = client.create_collection("my_collection")
# Add documents with embeddings
collection.add(
documents=["Document 1", "Document 2"],
metadatas=[{"id": 1}, {"id": 2}],
embeddings=[[0.1, 0.2, 0.3], [0.4, 0.5, 0.6]]
)
3. Query the Collection:
Retrieve relevant context during inference:
results = collection.query(
query_embeddings=[[0.1, 0.2, 0.3]],
n_results=1
)
print(results)
4. Integrate with LiveKit:
Use the retrieved context in your agent’s pipeline, either via a function tool or the on_user_turn_completed hook.
Let me know if you’d like detailed guidance on integrating ChromaDB with your LiveKit agent!
Sources: docs/examples/rag/rag_db_builder.py | External data and RAG | LiveKit docshundreds-king-75485
12/31/2025, 3:56 PMtall-airline-16756
12/31/2025, 3:56 PMmodule 'livekit.agents.llm' has no attribute 'ai_callable' occurs because the ai_callable decorator is not a publicly exported attribute in the current version of the LiveKit Agents SDK. Instead, you should use the @function_tool decorator to define callable functions for your tools.
Resolution:
1. Replace @ai_callable with `@function_tool`:
Update your code to use the correct decorator. For example:
from livekit.agents import function_tool
@function_tool()
def get_weather(location: str) -> dict:
"""Get the current weather in a given location.
Args:
location: The city and state, e.g. San Francisco, CA
"""
# Implementation here
return {"weather": "sunny", "temperature": 70}
2. Ensure SDK is Up-to-Date:
Update to the latest version of the LiveKit Agents SDK to ensure compatibility with current features and practices.
Let me know if you need further assistance with updating your tools or resolving this issue!
Sources: livekit-agents/livekit/agents/voice/generation.py | Tool definition and use | LiveKit docs