fiery_papaya_33507
10/20/2025, 5:03 AMAI Evy
10/20/2025, 5:03 AMAI Evy
10/20/2025, 5:03 AM{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) ]()
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) ) ;AI Evy
10/20/2025, 5:03 AMAI Evy
10/20/2025, 5:03 AMAI Evy
10/20/2025, 5:03 AMfiery_papaya_33507
10/20/2025, 5:12 AMfiery_papaya_33507
10/20/2025, 5:14 AMAI Evy
10/20/2025, 5:14 AMAI Evy
10/20/2025, 5:14 AMresponse_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) ](htAI Evy
10/20/2025, 5:14 AMAI Evy
10/20/2025, 5:14 AMAI Evy
10/20/2025, 5:14 AMfiery_papaya_33507
10/20/2025, 5:36 AMAI Evy
10/20/2025, 5:36 AMAI Evy
10/20/2025, 5:36 AM"+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) ](AI Evy
10/20/2025, 5:36 AMAI Evy
10/20/2025, 5:36 AMAI Evy
10/20/2025, 5:36 AM