https://retellai.com/?utm_source=discord&utm_medium=seo logo
Retell Webhook Verification keeps failing
# ❓・bug-report
i
I'm trying to verify the webhook requests using the code provided in the docs: https://docs.retellai.com/features/webhook Unfortunately though, it keeps hitting the console.error statement and can't get passed the if statement I've made sure that my API key is correctly stored in my environment variable. Not sure what to do. The only workaround I have right now is to bypass verification by just commenting out the code
r
Hmmm... looks correct -- my hunch is that your environment variable, for some reason, is not being set though, so it's evaluating to "". I'd try logging request.body, JSON.stringify(request.body), making sure the x-retell-signature header is there, and making sure the environment variable is there. (just console.log after request, or before you do if !Retell.verify.
i
Thanks for the help! Forgot that I was testing in Postman where there's no x-retell-signature header. Switched over to web chat testing on Retell so I could get the x-retell-signature header, and now the verification is just returning false even though I've double checked the header, API key is correct through logging it. Any idea on what it could be?
r
hmmm, did you try logging the request.body, JSON.stringify, etc.? I still suspect something is not loading properly into Retell.verify.
like throw in console.log(JSON.stringify(request.body)), etc., immediately after the try { and verify they're populating properly.
i
Just tried a couple more times, here's what I was able to get: request.body logged ReadableStream { locked: false, state: 'readable', supportsBYOB: true } JSON.stringify(request.body) logged {} not sure why the JSON stringify is returning an empty object? Seems to be the issue unless that's expected.
r
@Ibrahim naming convention is a bit weird (I'd call that function something other than POST), but... are you sure the endpoint you're sending the webhooks to in your backend is a.) calling that function and b.) passing along the request?
f
I just tried it like this
It works for me
I just turned on ngrok and redirected the webhook to localhost and ran it and it works.
Do you have something like this in your code? do you use the latest version?
i
Aha! I was passing in the stringify variable incorrectly to the Retell.verify
I was doing JSON.stringify(request.body) instead of doing something like JSON.stringify(data) where data is just the request.json() as Florian has in the picture
Much appreciated to both of you for helping me get to the bottom of this! @Reece - Integration @ Retell AI @Florian - support @ Retell AI
r
Hurray!
f
wohoo