I am running a test. I pulled the API key with the webhook label. I hard coded it into my code to test, and still cannot authorize. Can you please provide some guidance?
import crypto from "crypto";
export default defineComponent({
async run({ steps, $ }) {
// --- HARDCODED TEST ---
// Paste the key you copied from the Retell dashboard directly here.
const RETELL_SIGNING_SECRET = "retell_api_key_added_here";
// --- END HARDCODED TEST ---
const signatureHeader = steps.trigger.event.headers["x-retell-signature"];
const requestBodyString = steps.trigger.event.raw_body;
try {
const [timestamp, receivedSignature] = signatureHeader.split(',').map(part => part.split('=')[1]);
const payload = `${timestamp}.${requestBodyString}`;
const expectedSignature = crypto.createHmac('sha256', RETELL_SIGNING_SECRET).update(payload).digest('hex');
console.log("--- SIGNATURE DEBUG ---");
console.log("Received Signature:", receivedSignature);
console.log("Calculated Signature:", expectedSignature);
console.log("Match?", receivedSignature === expectedSignature);
console.log("--- END SIGNATURE DEBUG ---");
if (receivedSignature !== expectedSignature) {
await $.respond({ status: 401, body: { error: "Unauthorized - Signatures do not match." } });
return;
}
console.log("Signature verification successful!");
await $.respond({ status: 200, body: { message: "Security check passed!" } });
return;
} catch (e) {
await $.respond({ status: 400, body: { error: "Bad request - Could not parse signature header." } });
return;
}
},
});