https://retellai.com/?utm_source=discord&utm_medium=seo logo
can i create a chat agent via API already
# ❓・ai-evy-support
m
@AI Evy can i create a chat agent via API already?
a
Thanks for tagging me @maurizio_isendoorn. I'll look through relevant sources and get back to you shortly.
### Answer Yes, you can create agents via API using the
create-agent
endpoint [(1) ]() . The API allows you to create agents that can be used for both voice and chat functionality . To create an agent, you would use the JavaScript SDK like this:
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
 apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const agentResponse = await client.agent.create({
 response_engine: { llm_id: 'llm_234sdertfsdsfsdf', type: 'retell-llm' },
 voice_id: '11labs-Adrian',
}) ;
console.log(agentResponse.agent_id) ;
Once you have an agent created, you can convert an existing voice agent to a chat agent through the dashboard, or create a new chat agent directly [(2) ]() . After creating your chat agent, you can then use it with the chat APIs to create chat sessions [(3) ]() and generate responses [(4) ]() .
​ To learn more, see the sources I considered: [[1] Create Agent](https://docs.retellai.com/api-references/create-agent) [[2] Create chat agent](https://docs.retellai.com/build/create-chat-agent) [[3] Create Chat](https://docs.retellai.com/api-references/create-chat) [[4] Create Chat Completion](https://docs.retellai.com/api-references/create-chat-completion) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
m
@AI Evy no I need to create a chat agent entirely using API
a
Thanks for the follow-up, @maurizio_isendoorn. I'll get back to you soon.
### Answer Based on the available documentation, you can create agents via API using the
create-agent
endpoint, but the documentation shows that creating a "Chat Agent" specifically requires either using the dashboard to select "Chat Agent" as the agent type or converting an existing voice agent [(1) ]() . The API documentation for creating agents [(2) ]() shows how to create a general agent:
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
 apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const agentResponse = await client.agent.create({
 response_engine: { llm_id: 'llm_234sdertfsdsfsdf', type: 'retell-llm' },
 voice_id: '11labs-Adrian',
}) ;
console.log(agentResponse.agent_id) ;
However, the documentation indicates that to specifically create a "Chat Agent" (as opposed to a voice agent) , you need to either navigate to the Agents section in your Retell dashboard and select "Chat Agent" as the agent type, or convert an existing voice agent [(1) ]() . The sources don't show a direct API parameter or endpoint specifically for creating chat agents programmatically. You would need to create the agent via API and then potentially convert it to a chat agent through the dashboard interface.
​ To learn more, see the sources I considered: [[1] Create chat agent](https://docs.retellai.com/build/create-chat-agent) [[2] Create Agent](https://docs.retellai.com/api-references/create-agent) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
m
@AI Evy any updates on if it is possible to create a chat agent via API only?
a
Thanks for the follow-up, @maurizio_isendoorn. I'll get back to you soon.
### Answer Based on the current documentation, creating a chat agent still requires using the dashboard interface [(1) ]() . The documentation shows two methods for creating a chat agent : 1. Navigate to the Agents section in your Retell dashboard, click "Create New Agent", and select "Chat Agent" as the agent type 2. Open an existing voice agent and click "Convert to Chat Agent" The API documentation shows how to create chat sessions and generate responses once you have a chat agent, but not how to create the chat agent itself programmatically. For example, you can create a chat session using [(2) ]() :
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
 apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const chatResponse = await client.chat.create({ agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD' }) ;
And generate responses with [(3) ]() :
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
 apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const response = await client.chat.createChatCompletion({
 chat_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
 content: 'hi how are you doing?',
}) ;
However, the initial creation of the chat agent itself still appears to require the dashboard interface based on the available documentation [(1) ]() .
​ To learn more, see the sources I considered: [[1] Create chat agent](https://docs.retellai.com/build/create-chat-agent) [[2] Create Chat](https://docs.retellai.com/api-references/create-chat) [[3] Create Chat Completion](https://docs.retellai.com/api-references/create-chat-completion) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
m
@AI Evy In a conversational flow agent, where you have 6+ paths to go after the welcome message, is it better to add 6 transitions of 6 global nodes?
a
Thanks for the follow-up, @maurizio_isendoorn. I'll get back to you soon.
### Answer For a conversational flow agent with 6+ paths after the welcome message, it's not recommended to use 6 global nodes. Global nodes are designed for universal scenarios that need to be accessible from anywhere in the conversation, not for regular conversation flow paths [(1) ]() . Global nodes are intended for handling scenarios like user objections such as "I don't have time / I need to call back later" that could happen at any point in the conversation . These nodes handle universal scenarios that are not specific to any other node . For your 6+ conversation paths after the welcome message, you should use regular conversation nodes with transition conditions instead [(2) ]() [(3) ]() . You can set up transition conditions using either: - Prompt conditions that are evaluated by the LLM (e.g., "User said something about booking a meeting") [(2) ]() - Equation conditions for hardcoded mathematical evaluations
Copy code
- {{user_age}} > 18
- {{current_time}} > 9 AND {{current_time}} < 18
- {{user_location}} == "New York"
- {{user_location}} != "New York"
- "New York, Los Angeles" CONTAINS {{user_location}}
- "New York, Los Angeles" NOT CONTAINS {{user_location}}

- {{user_age}} < 18 OR {{user_location}} == "New York"
- {{name}} exists
Additionally, there's an important limitation with global nodes: once a conversation flow agent transitions into a global node, there's currently no way to return to the original node it was called from [(4) ]() . This architectural limitation means you would need to restart the conversation from scratch if users change their minds after entering a global node . For your use case, create regular conversation nodes connected to your welcome message with appropriate transition conditions for each of the 6+ paths.
​ To learn more, see the sources I considered: [[1] Global Node](https://docs.retellai.com/build/conversation-flow/global-node) [[2] Step 3: Add transition conditions](https://docs.retellai.com/build/conversation-flow/transition-condition) [[3] Conversation Node](https://docs.retellai.com/build/conversation-flow/conversation-node) [[4] Is it possible to return from the Global Node](https://discord.com/channels/1186424376300679209/1399484507530334368) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
m
@AI Evy what's the best way to fix the problem of when someone is deep into a series of sequential nodes, and they ask to be transferred so the AI jumps to the escalation node, but then they change their mind and want to continue with the node they came from?
a
Thanks for the follow-up, @maurizio_isendoorn. I'll get back to you soon.
### Answer Unfortunately, Retell AI currently does not support returning from Global Nodes to the original conversation flow position [(1) ]() . This is an architectural limitation . However, there is a workaround you can implement: you can build return functionality by storing the last node in a variable and routing back manually with a Logic Split [(2) ]() . Here's the best approach to handle this scenario: Manual Return Logic Implementation: 1. Before transitioning to a global node (like an escalation node) , store the current node identifier in a dynamic variable 2. In your escalation global node, include logic to detect when the user wants to continue with the original flow 3. Use a Logic Split node to check the stored variable and route back to the appropriate node Alternative Approaches: - Consider using regular conversation nodes instead of global nodes for escalation scenarios where users might want to return - Design your conversation flow with conditional branching that handles escalation requests without leaving the main flow entirely - Create multiple paths within regular nodes that can handle both escalation and continuation scenarios This limitation affects many users with similar use cases, such as callback scenarios where users change their minds after entering a global node [(1) ]() . The Retell team has acknowledged this as a significant limitation , and users have been directed to request this feature through their feature request channels .
​ To learn more, see the sources I considered: [[1] Is it possible to return from the Global Node](https://discord.com/channels/1186424376300679209/1399484507530334368) [[2] fallback to the previous node from Global node](https://discord.com/channels/1186424376300679209/1388025209533235261) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
m
@AI Evy I have a global node that has the conditional "When the caller asks to speak with a human/representative/support, or the issue they have is clearly out of scope." Then it goes through a couple of nodes to escalate, but when in the escalation process someone says that they want to speak to a human, the global node is triggered and the flow basically restarts. What is the best way to handle this?
a
Thanks for the follow-up, @maurizio_isendoorn. I'll get back to you soon.
### Answer Based on the available sources, this is a common issue with global nodes in Retell AI. Here are the best approaches to handle this scenario: Primary Solution: Make Your Global Node Condition More Specific Refine your global node condition to exclude cases where the user is already in an escalation flow [(1) ]() . Instead of the broad condition "When the caller asks to speak with a human/representative/support", make it more specific like: - "When the caller asks to speak with a human AND they are not already in an escalation process" - "When the caller requests human support for the first time in the conversation" Alternative Approaches: 1. Use Regular Conversation Nodes Instead of Global Nodes Since global nodes can be transitioned to from anywhere and there's no way to return to the original position [(1) ]() [(2) ]() , consider using regular conversation nodes with transition conditions for your escalation logic. 2. Handle Escalation Within Your Existing Flow Build escalation handling directly into your sequential nodes rather than relying on a global node that can interrupt the flow. 3. Add Context Checks to Your Global Node Use dynamic variables to track whether the user is already in an escalation process, and include this in your global node condition. Important Limitation to Consider: Retell AI currently does not support returning from Global Nodes to the original conversation flow position [(2) ]() . This is an architectural limitation that affects scenarios like yours where users might change their mind or where the same trigger (asking for human su
pport) occurs multiple times in different contexts. The key is to make your global node conditions more contextually aware so they don't trigger inappropriately when users are already being helped with their original request.
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
​ To learn more, see the sources I considered: [[1] Global Node](https://docs.retellai.com/build/conversation-flow/global-node) [[2] Is it possible to return from the Global Node](https://discord.com/channels/1186424376300679209/1399484507530334368) ​