tin_developer
10/05/2025, 11:51 AMAI Evy
10/05/2025, 11:51 AMAI Evy
10/05/2025, 11:52 AMpython
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
from retell import Retell
retell = Retell(api_key=os.environ["RETELL_API_KEY"])
@app.post("/check-weather")
async def check-weather(request: Request) :
try:
post_data = await request.json()
valid_signature = retell.verify(
json.dumps(post_data, separators=(",", ":") , ensure_ascii=False) ,
api_key=str(os.environ["RETELL_API_KEY"]) ,
signature=str(request.headers.get("X-Retell-Signature") ) ,
)
if not valid_signature:
print(
"Received Unauthorized",
Your custom function endpoint would handle the database connection logic and return the results to the Retell AI agent . The function result is capped at 15000 characters to prevent overloading the LLM context window .AI Evy
10/05/2025, 11:52 AMjavascript
import { Retell } from "retell-sdk";
this.app.post("/check-weather", async (req: Request, res: Response) => {
if (
!Retell.verify(
JSON.stringify(req.body) ,
process.env.RETELL_API_KEY,
req.headers["x-retell-signature"] as string,
)
) {
console.error("Invalid signature") ;
return;
}
const content = req.body;
if (content.args.city === "New York") {
return res.json("25f and sunny") ;
} else {
return res.json("20f and cloudy") ;
}
}) ;AI Evy
10/05/2025, 11:52 AMAI Evy
10/05/2025, 11:52 AMtin_developer
10/05/2025, 11:52 AMtin_developer
10/05/2025, 11:54 AMAI Evy
10/05/2025, 11:54 AMAI Evy
10/05/2025, 11:54 AMAI Evy
10/05/2025, 11:54 AMAI Evy
10/05/2025, 11:54 AMAI Evy
10/05/2025, 11:55 AMtin_developer
10/05/2025, 11:55 AMAI Evy
10/05/2025, 11:56 AMAI Evy
10/05/2025, 11:56 AMjavascript
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 can also list all chats [(3) ]() :
javascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const chatResponses = await client.chat.list() ;
console.log(chatResponses) ;AI Evy
10/05/2025, 11:56 AMAI Evy
10/05/2025, 11:56 AM