how can I connect my agent which is running on loc...
# ask-ai
b
how can I connect my agent which is running on local system to livekit cloud application
g
To connect your locally running agent to a LiveKit Cloud application, you need to ensure that your agent is configured with the correct LiveKit Cloud server URL and authentication credentials. Here's a brief overview of the steps: 1. Set Environment Variables: Ensure your agent's environment variables are set with the LiveKit Cloud URL, API key, and API secret. These are necessary for establishing a secure connection. For example:
Copy code
export LIVEKIT_URL="wss://your-livekit-cloud-url"
   export LIVEKIT_API_KEY="your-api-key"
   export LIVEKIT_API_SECRET="your-api-secret"
2. Run the Agent: Start your agent with these environment variables. The agent will open a WebSocket connection to the LiveKit server using the provided URL and credentials. When a room is created, the server will notify the agent to join the room as a participant. 3. Join a Room: Use the agent's code to join a specific room on the LiveKit Cloud. This involves using the
connect
command with the room name. If you need more detailed guidance, please let me know. Sources: - LiveKit Agents Overview - LiveKit Agents for Node.js 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
b
@millions-hair-24956 will this work if I call using a twilio number
g
Yes, you can connect your agent running on a local system to a LiveKit Cloud application and handle calls made using a Twilio number. Here's how you can set it up: 1. Configure SIP Trunk: Set up a SIP trunk with Twilio to route calls to your LiveKit Cloud. This involves creating a SIP trunk in Twilio and associating it with your LiveKit SIP URI. Ensure that the SIP trunk is configured for both inbound and outbound calls if needed. 2. Set Up Inbound Trunk and Dispatch Rule: In LiveKit, create an inbound SIP trunk and a dispatch rule to route incoming calls to a specific room. This setup will allow calls made to your Twilio number to be directed to a LiveKit room where your agent can interact with the caller. 3. Run Your Agent: Ensure your agent is running and connected to the LiveKit Cloud. The agent should be configured to join the room specified in the dispatch rule when a call is received. 4. Test the Setup: Make a call to your Twilio number and verify that the call is routed to the LiveKit room and that your agent can interact with the caller. If you need more detailed instructions, please let me know. Sources: - Making Calls Using SIP - Configuring a SIP Provider Trunk 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
b
@millions-hair-24956 I am getting this response 2025-02-25 180011,447 - DEBUG asyncio - Using selector: KqueueSelector 2025-02-25 180011,451 - DEV livekit.agents - Watching /Users/sandeepkaushik/projects/voice-pipeline-agent-python 2025-02-25 180012,155 - DEBUG asyncio - Using selector: KqueueSelector 2025-02-25 180012,170 - INFO livekit.agents - starting worker {"version": "0.12.15", "rtc-version": "0.20.1"} 2025-02-25 180012,170 - INFO livekit.agents - starting inference executor 2025-02-25 180012,777 - INFO livekit.agents - initializing inference process {"pid": 51548, "inference": true} 2025-02-25 180012,777 - DEBUG livekit.agents - initializing inference runner {"runner": "lk_end_of_utterance", "pid": 51548, "inference": true} 2025-02-25 180016,340 - INFO livekit.agents - inference process initialized {"pid": 51548, "inference": true} 2025-02-25 180016,340 - DEBUG asyncio - Using selector: KqueueSelector {"pid": 51548, "inference": true} 2025-02-25 180016,785 - INFO livekit.agents - registered worker {"id": "AW_vU2vdiE5YPV4", "region": "India", "protocol": 15, "node_id": "NC_OMUMBAI1A_zodH9Lf9MRWg"}
g
The logs you provided indicate that your LiveKit agent is starting up and initializing correctly. Here's a breakdown of the key steps in the process: 1. Worker Initialization: The agent is starting as a worker with version
0.12.15
and RTC version
0.20.1
. This means the agent is ready to handle jobs assigned by the LiveKit server. 2. Inference Executor: The agent is starting an inference executor, which is responsible for running inference tasks such as speech-to-text (STT) or other AI model processing. 3. Inference Process: The inference process is initialized, indicating that the agent is ready to perform inference tasks. The process ID (PID) is
51548
. 4. Worker Registration: The agent successfully registers as a worker with the LiveKit server, with an ID of
AW_vU2vdiE5YPV4
, in the "India" region. This registration allows the agent to receive job requests from the server. If you have any specific issues or questions about this process, please let me know. Sources: - https://docs.livekit.io/agents/overview/ - https://livekit-users.slack.com/archives/C07FY8WHGPM/p1731772038.705719 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
b
@millions-hair-24956 my agent name is agent_name="inbound-agent" I have created a elastic sip trunk in twilio with friendly name as LiveKitTrunk with sip origination url as sip:1nf2h8hwhuw.sip.livekit.cloud;transport=tcp and no terminaton url is this correct and if correct pls tell me how can I create sip trunk, and dispatch rule at livekit
g
To set up a SIP trunk and dispatch rule in LiveKit, follow these steps: 1. Create a SIP Trunk in LiveKit: You need to create an inbound SIP trunk in LiveKit to accept calls from your Twilio SIP trunk. Use the LiveKit CLI or API to create this trunk. Here's an example using the CLI:
Copy code
{
  "trunk": {
    "name": "Twilio Inbound Trunk",
    "numbers": [
      "+your_twilio_number"
    ],
    "auth_username": "your_username",
    "auth_password": "your_password"
  }
}
Use the command:
Copy code
lk sip inbound create inbound-trunk.json
2. Create a Dispatch Rule: This rule will route incoming calls to a specific LiveKit room. Create a
dispatch-rule.json
file:
Copy code
{
  "name": "My Dispatch Rule",
  "trunk_ids": [
    "<livekit_trunk_id>"
  ],
  "rule": {
    "dispatchRuleIndividual": {
      "roomPrefix": "call"
    }
  }
}
Apply the dispatch rule using:
Copy code
lk sip dispatch create dispatch-rule.json
Ensure that the
<livekit_trunk_id>
in the dispatch rule is replaced with the actual trunk ID you receive after creating the SIP trunk. If you need more detailed guidance, please let me know. Sources: - Accepting Incoming Calls - SIP Inbound Trunk 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.