https://retellai.com/?utm_source=discord&utm_medium=seo logo
I need a custom websocket
# ❓・ai-evy-support
f
@AI Evy I need a custom websocket. How do I do that? Step 1: Update Agent Settings On that agent page, look for "Response Engine" or "LLM Configuration" Set it to: Type: Custom LLM (or WebSocket)
a
Thanks for tagging me @fiery_papaya_33507. I'll look through relevant sources and get back to you shortly.
### Answer To set up a custom WebSocket for your Retell AI agent, you'll need to follow these steps: ## Step 1: Create Your WebSocket Server First, set up a backend server that handles WebSocket connections [(1) ]() . You can use the demo repositories as a starting point: - [Node Demo Repository]() - [Python Demo Repository]() ## Step 2: Configure the WebSocket Endpoint Your WebSocket endpoint should follow this format:
{your-server-websocket-endpoint}/{call_id}
[(2) ]() . The
call_id
is a required path parameter that uniquely identifies the call . ## Step 3: Update Agent Configuration In your agent settings, you'll need to configure the response engine. According to the API documentation, you should set the
llm_websocket_url
field to point to your WebSocket endpoint . However, note that
llm_websocket_url
is now deprecated and you should use the new
response_engine
field instead [(3) ]() . ## Step 4: Implement the WebSocket Protocol Your server needs to handle the WebSocket communication protocol [(2) ]() . Key points: - Send a config event upon connection (optional) - Send response events when Retell requests them - Set
content_complete
to
true
when your response is finished to trigger the agent to speak [(4) ]()
Copy code
javascript
const res = {
    response_id,
    content,
    content_complete: true,  // Important: set to true to make agent speak
    end_call: false
};
ws.send(JSON.stringify(res) ) ;
## Step 5: Test Your Setup You can test your custom LLM setup using Retell's Dashboard audio test or via an inbound call [(5) ]() . The WebSocket will receive live transcript data and send back responses that control what the agent says and actions like ending the call [(2) ]() .
​ To learn more, see the sources I considered: [[1] Custom LLM Overview](https://docs.retellai.com/integrate-llm/overview) [[2] LLM WebSocket](https://docs.retellai.com/api-references/llm-websocket) [[3] Platform Changelogs | Retell AI](https://www.retellai.com/changelog) [[4] Custom LLM websockets don't seem to be working](https://discord.com/channels/1186424376300679209/1233976191472635977) [[5] Custom LLMs](https://discord.com/channels/1186424376300679209/1396099334432489524) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
f
Where do I find the "response engine" tab in the agent? I need that for the setup. Does it need to be published in order to find that button?
@AI Evy Where do I find the "response engine" tab in the agent? I need that for the setup. Does it need to be published in order to find that button?
a
Thanks for the follow-up, @fiery_papaya_33507. I'll get back to you soon.
### Answer Based on the API documentation, the
response_engine
is configured at the agent level when creating or updating an agent [(1) ]() [(2) ]() [(3) ]() [(4) ]() . The
response_engine
field is part of the agent's configuration and can be set through the API when creating or updating an agent [(1) ]() [(2) ]() . It's an object that specifies the Response Engine to attach to the agent, and you need to create a Response Engine first before attaching it to an agent . For draft versions specifically, you can set your agent to use the draft version at the phone number level in the dashboard [(5) ]() . According to a Discord discussion, you can "set your agent at the draft version from the dashboard at the phone numbers tab, then any change you will make through the API or the dashboard it will effect the agent without publishing it" . The agent does not need to be published to configure the response engine - you can work with draft versions [(5) ]() [(6) ]() . The response engine configuration is available whether the agent is published or not, as indicated by the
is_published
boolean field that appears alongside the
response_engine
in the API responses [(1) ]() [(2) ]() [(4) ](ht
tps://docs.retellai.com/api-references/get-agent) .
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
f
@AI Evy How do I import a number or BYON in Retell?
a
Thanks for the follow-up, @fiery_papaya_33507. I'll get back to you soon.
### Answer To import a phone number (BYON - Bring Your Own Number) in Retell, you need to use the Import Phone Number API endpoint [(1) ]() . ## API Endpoint Use a POST request to import your phone number with the required parameters . ## Required Parameters The key parameters you need to provide are : - **phone_number**: The number in E.164 format (e.g.,
"+14157774444"
) - **termination_uri**: The termination URI to identify your elastic SIP trunk, used for outbound calls (e.g.,
"someuri.pstn.twilio.com"
) - **outbound_agent_id**: Unique ID of the agent for outbound calls ## Optional Parameters You can also configure : - **sip_trunk_auth_username**: Username for SIP trunk authentication - **sip_trunk_auth_password**: Password for SIP trunk authentication - **inbound_agent_id**: Agent ID for handling inbound calls (can be null if you don't want to accept inbound calls) - **nickname**: A reference name for the number - **inbound_webhook_url**: Webhook URL for inbound call customization ## Authentication You need to include your API key in the Authorization header as
"Bearer YOUR_API_KEY"
. ## Important Notes - Each phone number can only be imported once - if you get an error saying "Phone number already exists," it means the number is already imported by someone else [(2) ]() - For Twilio elastic SIP trunks, the termination URI always ends with ".pstn.twilio.com" [(1) ]() - After importing, you can bind different agents to the same number for inbound vs outbound calls [(3) ]() The API will return a 201 status code upon successful import along with the phone number details [(1) ](
eferences/import-phone-number) .
​ To learn more, see the sources I considered: [[1] Import Phone Number](https://docs.retellai.com/api-references/import-phone-number) [[2] Unable to import Phone number](https://discord.com/channels/1186424376300679209/1346336071243403354) [[3] Outbound Calls (Make Calls)](https://docs.retellai.com/deploy/outbound-call) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.