vyyy_20754
10/23/2025, 2:12 PMAI Evy
10/23/2025, 2:12 PMAI Evy
10/23/2025, 2:13 PMjavascript
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") ;
}
}) ;
[(1) ]()
Or in Python:AI Evy
10/23/2025, 2:13 PMpython
@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",
post_data["event"],
post_data["data"]["call_id"],
)
return JSONResponse(status_code=401, content={"message": "Unauthorized"})
args = post_data["args"]
if args["city"] == "New York":
return JSONResponse(status_code=200, content={"result": "25f and sunny"})
else:
return JSONResponse(status_code=200, content={"result": "20f and cloudy"})
except Exception as err:
print(f"Error in webhook: {err}")
return JSONResponse(
status_code=500, content={"message": "Internal Server Error"}
)
Key points:
- Return HTTP status codes 200-299 for success [(1) ]() [(2) ]()
- Return appropriate error status codes (4xx, 5xx) for failures
- The function result is capped at 15000 characters
- When the request fails, it will be retried up to 2 times
If your function is only returning a call ID without success/error indication, ensure your endpoint is returning proper HTTP status codes and response content.AI Evy
10/23/2025, 2:13 PMAI Evy
10/23/2025, 2:13 PM