faizaz_50459
11/05/2025, 10:04 PMAI Evy
11/05/2025, 10:04 PMAI Evy
11/05/2025, 10:04 PMAI Evy
11/05/2025, 10:04 PMget_case_number)
- **Description**: Briefly describe the purpose (e.g., "Retrieve case number from CRM after creation")
- **Specify the Endpoint URL**: Enter the URL where Retell AI will send POST requests to your n8n webhook
- **Define Parameters**: Use JSON schema format to specify any parameters your function requires
- **Configure Speech Behavior**:
- Enable "Speak During Execution" if the agent should speak while the function runs (e.g., "Let me retrieve your case number")
- Enable "Speak After Execution" if the agent should provide feedback after the function completes (e.g., "Your case number is...")
Step 2: Set Up n8n Webhook to Return Case Number
- Create an n8n webhook endpoint that your Custom Function will call
- After your n8n workflow saves data to CRM and generates the case number, have it return the case number in JSON format to Retell
- Verify the request's authenticity by checking the X-Retell-Signature header
Step 3: Add Function Node to Your Conversation Flow
- In your Conversation Flow, add a Function Node at the point where you want to retrieve the case number [(2) ]()
- Configure this node to call your custom function
- The function will execute when the agent reaches this node, callAI Evy
11/05/2025, 10:04 PMAI Evy
11/05/2025, 10:04 PMfaizaz_50459
11/05/2025, 10:19 PMfaizaz_50459
11/05/2025, 10:22 PMAI Evy
11/05/2025, 10:22 PMAI Evy
11/05/2025, 10:23 PMjson
{
"case_number": "CASE-12345"
}
[(1) ]() , [(2) ]()
The function result is capped at 15000 characters [(1) ]() [(2) ]() .
## Step 2: Verify the X-Retell-Signature Header
To verify that the request is coming from Retell, check the X-Retell-Signature header . The value is an encrypted request body using your secret key .
In n8n, you can add a verification step using the Retell SDK. Here's example code for verification:
Node.js example:
javascript
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
11/05/2025, 10:23 PMpython
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",
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"}
)
You can also secure your server by only allowlisting Retell IP addresses: 100.20.5.228 .
**AI Evy
11/05/2025, 10:23 PMAI Evy
11/05/2025, 10:23 PMfaizaz_50459
11/05/2025, 10:40 PMAI Evy
11/05/2025, 10:40 PMAI Evy
11/05/2025, 10:41 PMx-retell-signature header [(2) ]()
Here's the verification code that should work in your n8n setup:
Node.js:
javascript
import { Retell } from "retell-sdk";
import express, { Request, Response } from "express";
const app = express() ;
app.use(express.json() ) ;
app.post("/webhook", (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 {event, call} = req.body;
// process the webhook
// Acknowledge the receipt of the event
res.status(204) .send() ;
}) ;
Python:AI Evy
11/05/2025, 10:41 PMpython
# install the sdk: <https://docs.retellai.com/get-started/sdk>
from retell import Retell
from flask import Flask, request, jsonify
app = Flask(__name__)
retell = Retell(api_key="YOUR_API_KEY")
@app.route("/webhook", methods=["POST"])
def webhook() :
if not retell.verify(
request.get_data(as_text=True) ,
api_key="YOUR_API_KEY",
signature=request.headers.get("X-Retell-Signature") ,
) :
print("Invalid signature")
return jsonify({"message": "Unauthorized"}) , 401
event = request.json.get("event")
call = request.json.get("call")
# process the webhook
return "", 204
For the n8n-specific "unused webhook response node" error, you'll need to consult n8n's documentation or their support channels, as this is outside Retell AI's scope.
**AI Evy
11/05/2025, 10:41 PMAI Evy
11/05/2025, 10:41 PMfaizaz_50459
11/05/2025, 11:58 PMAI Evy
11/05/2025, 11:58 PMAI Evy
11/05/2025, 11:59 PMAuthorization: Bearer YOUR_RETELL_API_KEY
[(1) ]() , [(2) ]()
Example usage in code:
javascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
[(3) ]()
The API key is required for all authenticated requests to the Retell AI API [(1) ]() [(2) ]() .
---
**AI Evy
11/05/2025, 11:59 PMAI Evy
11/05/2025, 11:59 PM