Elders
03/19/2026, 8:47 PMAI Evy
03/19/2026, 8:47 PMAI Evy
03/19/2026, 8:47 PMjavascript
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) ;
You'll first need to create a chat agent using the Create Chat Agent API. [(2) ]() The chat agent requires a response engine to be attached, which generates responses for the agent.
The Create Chat API returns a chat object that includes details like chat_id, agent_id, chat_status, and other relevant information you can use in your custom widget. [(1) ]()AI Evy
03/19/2026, 8:47 PMAI Evy
03/19/2026, 8:47 PMElders
03/24/2026, 2:21 PMAI Evy
03/24/2026, 2:21 PMAI Evy
03/24/2026, 2:21 PMcall_inbound object with a dynamic_variables key. [(1) ]() [(2) ]()
Your webhook response should look like this:
json
{
"call_inbound": {
"dynamic_variables": {
"customer_name": "John Doe",
"user_email": "john@example.com"
}
}
}
Once you've set up your webhook to return dynamic variables this way, you can use them in your agent's prompt or begin message with the {{variable_name}} syntax. [(3) ]() For example, to greet the customer by name if available, you could use:
Hello {{customer_name}}, thanks for reaching out!
If the customer name is not known, you can handle this in your webhook by returning an empty string or a default value, and then structure your prompt to check for this condition. [(4) ]() For example:
Variable:
Name: {{customer_name}}
Always say "Hello {{customer_name}}, nice of you to call, how can I help you?", if known.
If Name is empty: "Hello, I am your digital assistant. How can I help you?"
The inbound webhook should be configured at the phone number level in your dashboard or via the API. [(1) ]() [(2) ]()AI Evy
03/24/2026, 2:21 PMAI Evy
03/24/2026, 2:21 PM