https://retellai.com/?utm_source=discord&utm_medium=seo logo
can i access the functions of agents using the sdk
# ❓・ai-evy-support
d
@AI Evy can i access the functions of agents using the sdk? i want to add end_call,check_availability_cal,book_appointment_cal to my agent using the sdk.
a
Thanks for tagging me @detraxsenpai. I'll look through relevant sources and get back to you shortly.
### Answer Yes, you can add functions to your agent using the SDK [(1) ]() . You can add the tools you mentioned (
end_call
,
check_availability_cal
,
book_appointment_cal
) through the
general_tools
parameter when updating your Retell LLM [(2) ]() . Here's how to add these functions using the SDK:
Copy code
javascript
import Retell from 'retell-sdk';

const client = new Retell({
  apiKey: 'YOUR_RETELL_API_KEY',
}) ;

const llmResponse = await client.llm.update('16b980523634a6dc504898cda492e939', {
  begin_message: 'Hey I am a virtual assistant calling from Retell Hospital.',
}) ;
The
general_tools
array can include predefined tools like
end_call
[(3) ]() [(2) ]() . For appointment booking tools like
book_appointment_cal
, you would configure them with your Cal.com credentials :
Copy code
javascript
[  
  {  
    "type": "end_call",  
    "name": "end_call",  
    "description": "End the call with user."  
  }  
]
Copy code
javascript
{  
  "type": "book_appointment_cal",  
  "name": "book_appointment",  
  "description": "Book an annual check up.",  
  "cal_api_key": "cal_live_xxxxxxxxxxxx",  
  "event_type_id": 60444,  
  "timezone": "America/Los_Angeles"  
}
The tools can be added either as
general_tools
(available in all states) or within specific
states
if you're using a multi-state agent . For appointment booking setup, you'll need to connect your agent to a Cal.com account with the necessary credentials and event ID [(4) ]() .
​ To learn more, see the sources I considered: [[1] SDKs](https://docs.retellai.com/get-started/sdk) [[2] Update Retell LLM](https://docs.retellai.com/api-references/update-retell-llm) [[3] Get Retell LLM](https://docs.retellai.com/api-references/get-retell-llm) [[4] AI Appointment Scheduling with Voice AI Booking Assistant](https://www.retellai.com/features/book-appointments) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
d
@AI Evy can you write the complete snippet code of sdk on how how to add -[ { "type": "end_call", "name": "end_call", "description": "End the call with user." } ] and { "type": "book_appointment_cal", "name": "book_appointment", "description": "Book an annual check up.", "cal_api_key": "cal_live_xxxxxxxxxxxx", "event_type_id": 60444, "timezone": "America/Los_Angeles" }
a
Thanks for the follow-up, @detraxsenpai. I'll get back to you soon.
### Answer Here's the complete SDK code snippet to add both the
end_call
and
book_appointment_cal
tools to your Retell LLM using the
general_tools
parameter [(1) ]() :
Copy code
javascript
import Retell from 'retell-sdk';

const client = new Retell({
  apiKey: 'YOUR_RETELL_API_KEY',
}) ;

const llmResponse = await client.llm.update('16b980523634a6dc504898cda492e939', {
  general_tools: [
    {
      "type": "end_call",
      "name": "end_call",
      "description": "End the call with user."
    },
    {
      "type": "book_appointment_cal",
      "name": "book_appointment",
      "description": "Book an annual check up.",
      "cal_api_key": "cal_live_xxxxxxxxxxxx",
      "event_type_id": 60444,
      "timezone": "America/Los_Angeles"
    }
  ]
}) ;

console.log(llmResponse.llm_id) ;
This code updates an existing Retell LLM with both tools in the
general_tools
array . The tools will be available to the LLM regardless of which state the agent is in . Make sure to replace: -
'16b980523634a6dc504898cda492e939'
with your actual LLM ID -
'YOUR_RETELL_API_KEY'
with your actual API key -
"cal_live_xxxxxxxxxxxx"
with your actual Cal.com API key -
60444
with your actual Cal.com event type ID
​ To learn more, see the sources I considered: [[1] Update Retell LLM](https://docs.retellai.com/api-references/update-retell-llm) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
d
@AI Evy can you also ad how to add - check_availability_cal
a
Thanks for the follow-up, @detraxsenpai. I'll get back to you soon.
### Answer Here's the complete SDK code snippet to add
end_call
,
book_appointment_cal
, and
check_availability_cal
tools to your Retell LLM [(1) ]() :
Copy code
javascript
import Retell from 'retell-sdk';

const client = new Retell({
  apiKey: 'YOUR_RETELL_API_KEY',
}) ;

const llmResponse = await client.llm.update('16b980523634a6dc504898cda492e939', {
  general_tools: [
    {
      "type": "end_call",
      "name": "end_call",
      "description": "End the call with user."
    },
    {
      "type": "book_appointment_cal",
      "name": "book_appointment",
      "description": "Book an annual check up.",
      "cal_api_key": "cal_live_xxxxxxxxxxxx",
      "event_type_id": 60444,
      "timezone": "America/Los_Angeles"
    },
    {
      "type": "check_availability_cal",
      "name": "check_calendar_availability",
      "description": "Checks availability for 30-minute consultation calls",
      "cal_api_key": "cal_live_xxxxxxxxxxxx",
      "event_type_id": 60444,
      "timezone": "America/Los_Angeles"
    }
  ]
}) ;

console.log(llmResponse.llm_id) ;
, [(2) ]() For the check calendar availability function, you'll need the same Cal.com credentials as the booking function [(3) ]() : - Your Cal.com API key - Your event type ID from the Cal.com dashboard - Optional timezone specification Make sure to replace the placeholder values with your actual credentials and LLM ID .
​ To learn more, see the sources I considered: [[1] Update Retell LLM](https://docs.retellai.com/api-references/update-retell-llm) [[2] Create Retell LLM](https://docs.retellai.com/api-references/create-retell-llm) [[3] Check Calendar Availability](https://docs.retellai.com/build/check-availability) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
d
@AI Evy i already bought a phone number now i am just reassinging the number to another llm agent then why i am getting billed for it?
a
Thanks for the follow-up, @detraxsenpai. I'll get back to you soon.
### Answer When you purchase a phone number through Retell AI, you're charged monthly for owning that number [(1) ]() . Phone numbers are yours once purchased and can be used indefinitely . Reassigning the number to a different agent doesn't create additional charges for the number itself . The billing you're seeing is likely the monthly recurring charge for the phone number itself . Retell AI supports both Twilio and Telnyx numbers with the following pricing : - **Twilio**: US numbers cost $2/month, US toll-free numbers cost $5/month, Canadian numbers cost $2/month - **Telnyx**: US numbers only cost $2/month Reassigning a phone number to a different inbound or outbound agent through the dashboard or API doesn't incur additional phone number charges . You can assign different inbound and outbound agents to the same number without additional fees . If you're seeing unexpected charges beyond the monthly number fee, I'd recommend checking your usage for call minutes or other services, as toll-free numbers do cost $0.06 per minute for inbound calls .
​ To learn more, see the sources I considered: [[1] Purchase phone number](https://docs.retellai.com/deploy/purchase-number) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
d
@AI Evy under phone numbers it is showng 2 numbers but in my bill it is showing - Phone Number $20.00 10 numbers explain
a
Thanks for the follow-up, @detraxsenpai. I'll get back to you soon.
### Answer Based on the pricing information, Retell AI charges $100.00 per phone number per month for verified phone numbers [(1) ]() . However, there appears to be a discrepancy between what you're seeing in your dashboard (2 numbers) and what you're being billed for (10 numbers at $20.00) . This type of billing discrepancy has occurred before with other users. In a similar case documented in the Discord community, a user was charged for 66 numbers when they only had 5 numbers, and the Retell AI team provided a refund and updated the subscription [(2) ]() . Since you're seeing 2 numbers in your dashboard but being billed for 10 numbers, this appears to be a billing error. The billing should reflect the actual number of phone numbers you have active in your account [(1) ]() . I recommend contacting Retell AI support directly about this billing discrepancy. You can: - Visit [Contact Sales]() - Visit [) When contacting support, provide your workspace ID and specific details about the billing discrepancy (showing 2 numbers but being charged for 10) . Based on the previous case, they should be able to investigate and provide a refund for the incorrect charges [(2) ]() .
​ To learn more, see the sources I considered: [[1] AI Phone Agent Pricing | Retell AI](https://www.retellai.com/pricing) [[2] Billing Bug and Question](https://discord.com/channels/1186424376300679209/1425198807116812318) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
d
@AI Evy is this approach correct -
a
Thanks for the follow-up, @detraxsenpai. I'll get back to you soon.
### Answer I don't see the specific approach you're referring to in your message. Could you please share the complete approach or code snippet you'd like me to review? However, based on our conversation thread, if you're asking about the SDK approach for adding functions to your agent, the approach we discussed earlier is correct according to the available sources. The method of using the SDK to update an LLM with
general_tools
containing
end_call
,
book_appointment_cal
, and
check_availability_cal
functions follows the standard Retell AI implementation pattern. If you could share the specific approach you're asking about, I'd be happy to review it against the available documentation and provide feedback on whether it's correct.
message has been deleted
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
d
@AI Evy is there any method to check the current llm's geneal tool that the llm is using currently.
a
Thanks for the follow-up, @detraxsenpai. I'll get back to you soon.
### Answer Yes, you can check the current LLM's general tools using the SDK's retrieve method [(1) ]() . Here's how to get the current configuration:
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
 apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const llmResponse = await client.llm.retrieve('16b980523634a6dc504898cda492e939') ;
console.log(llmResponse.llm_id) ;
The response will include the
general_tools
array showing all currently configured tools . The returned object contains all the LLM configuration including: -
general_tools
- the tools available to the LLM -
states
- if using multi-state configuration -
general_prompt
- the current prompt - Other configuration details like
model_temperature
,
tool_call_strict_mode
, etc. You can access the general tools specifically by checking
llmResponse.general_tools
in the response . This will show you exactly which tools like
end_call
,
book_appointment_cal
, and
check_availability_cal
are currently configured for that LLM .
​ To learn more, see the sources I considered: [[1] Get Retell LLM](https://docs.retellai.com/api-references/get-retell-llm) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
d
@AI Evy how to add a custom tool from api call to the agent
a
Thanks for the follow-up, @detraxsenpai. I'll get back to you soon.
### Answer To add a custom tool to your agent using the API, you need to include it in the
general_tools
array when creating or updating your Retell LLM [(1) ]() . Based on the Discord discussion, here's the structure for custom tools [(2) ]() :
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
  apiKey: 'YOUR_RETELL_API_KEY',
}) ;

const llmResponse = await client.llm.update('16b980523634a6dc504898cda492e939', {
  general_tools: [
    {
      "execution_message_description": "The message you will say to user when calling this tool. Make sure it fits into the conversation smoothly. Do not use a question. Use everyday language.",
      "speak_after_execution": true,
      "name": "send_SMS",
      "description": "sends signup link to caller",
      "type": "custom",
      "speak_during_execution": true,
      "url": "<https://your-endpoint.com/api/custom-function%22>
    }
  ]
}) ;
For custom functions, you can configure several HTTP methods including GET, POST, PUT, PATCH, and DELETE [(1) ]() . You can also define parameters using JSON schema format :
Copy code
json
{
  "type": "object",
  "properties": {
    "city": {
      "type": "string",
      "description": "The city of the weather"
    }
  },
  "required": [
    "city"
  ]
}
When Retell calls your custom function, it will send a request to your endpoint with the following structure : - Header:
X-Retell-Signature
for verification - Header:
Content-Type: application/json
- Body: Contains
name
,
call
object, and
args
with the function arguments Make sure your endpoint URL doesn't have a trailing slash, as this can cause issues where Retell sends GET requests instead of POST requests [(3) ]() .
​ To learn more, see the sources I considered: [[1] Integrate any system with custom function](https://docs.retellai.com/build/single-multi-prompt/custom-function) [[2] Discord message from @hello_14019 on 2024-12-17](https://discord.com/channels/1186424376300679209/1186462578310910112/1318449184713478208) [[3] Custom Tool Function Call sends a "GET" from Retell to my URL and not a "POST" . Empty request body.](https://discord.com/channels/1186424376300679209/1284824056801132678) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
d
@AI Evy how to add the end_call tool to my llm using js sdk
a
Thanks for the follow-up, @detraxsenpai. I'll get back to you soon.
### Answer ### Answer You can add the
end_call
tool to your LLM using the JavaScript SDK by updating the
general_tools
array [(1) ]() . Here's the complete code snippet:
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
 apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const llmResponse = await client.llm.update('16b980523634a6dc504898cda492e939', {
 start_speaker: 'user',
 begin_message: 'Hey I am a virtual assistant calling from Retell Hospital.',
}) ;
console.log(llmResponse.llm_id) ;
To specifically add the
end_call
tool, you'll need to include it in the
general_tools
parameter :
Copy code
javascript
[  
 {  
 "type": "end_call",  
 "name": "end_call",  
 "description": "End the call with user."  
 }  
]
The complete SDK call with the
end_call
tool would look like this:
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
 apiKey: 'YOUR_RETELL_API_KEY',
}) ;

const llmResponse = await client.llm.update('YOUR_LLM_ID', {
 general_tools: [
   {
     "type": "end_call",
     "name": "end_call", 
     "description": "End the call with user."
   }
 ]
}) ;
console.log(llmResponse.llm_id) ;
Make sure to replace
'YOUR_RETELL_API_KEY'
with your actual API key and
'YOUR_LLM_ID'
with your actual LLM ID . The
end_call
tool will be available to the LLM in all states when added to
general_tools
.
​ To learn more, see the sources I considered: [[1] Update Retell LLM](https://docs.retellai.com/api-references/update-retell-llm) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.